Skip to content

Commit 2c088af

Browse files
committed
module: remove unused variables
1 parent 351383d commit 2c088af

File tree

9 files changed

+137
-67
lines changed

9 files changed

+137
-67
lines changed

README.md

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,88 @@ and then run `terraform init` and `terraform apply` to make the defined provider
224224

225225
More details see [How to use provider in the module](https://www.terraform.io/docs/language/modules/develop/providers.html#passing-providers-explicitly)
226226

227-
## Terraform versions
227+
<!-- BEGIN_TF_DOCS -->
228+
## Requirements
228229

229230
| Name | Version |
230231
|------|---------|
231-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.0 |
232-
| <a name="requirement_alicloud"></a> [alicloud](#requirement\_alicloud) | >= 1.75.0 |
232+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
233+
234+
## Providers
235+
236+
| Name | Version |
237+
|------|---------|
238+
| <a name="provider_alicloud"></a> [alicloud](#provider\_alicloud) | n/a |
239+
240+
## Modules
241+
242+
No modules.
243+
244+
## Resources
245+
246+
| Name | Type |
247+
|------|------|
248+
| [alicloud_cs_kubernetes.k8s](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/cs_kubernetes) | resource |
249+
| [alicloud_cs_kubernetes_node_pool.default](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/cs_kubernetes_node_pool) | resource |
250+
| [alicloud_eip.default](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/eip) | resource |
251+
| [alicloud_eip_association.default](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/eip_association) | resource |
252+
| [alicloud_nat_gateway.default](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/nat_gateway) | resource |
253+
| [alicloud_snat_entry.default](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/snat_entry) | resource |
254+
| [alicloud_vpc.vpc](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/vpc) | resource |
255+
| [alicloud_vswitch.vswitches](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/vswitch) | resource |
256+
| [alicloud_instance_types.default](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/data-sources/instance_types) | data source |
257+
| [alicloud_zones.default](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/data-sources/zones) | data source |
258+
259+
## Inputs
260+
261+
| Name | Description | Type | Default | Required |
262+
|------|-------------|------|---------|:--------:|
263+
| <a name="input_cluster_addons"></a> [cluster\_addons](#input\_cluster\_addons) | Addon components in kubernetes cluster | <pre>list(object({<br> name = string<br> config = string<br> }))</pre> | `[]` | no |
264+
| <a name="input_cpu_core_count"></a> [cpu\_core\_count](#input\_cpu\_core\_count) | CPU core count is used to fetch instance types. | `number` | `1` | no |
265+
| <a name="input_cpu_policy"></a> [cpu\_policy](#input\_cpu\_policy) | kubelet cpu policy. Valid values: 'none','static'. Default to 'none'. | `string` | `"none"` | no |
266+
| <a name="input_create_vpc"></a> [create\_vpc](#input\_create\_vpc) | Boolean. If you have a vpc already, use that one, else make this true and one will be created. | `bool` | `false` | no |
267+
| <a name="input_data_disks"></a> [data\_disks](#input\_data\_disks) | Additional data disks to attach to the scaled ECS instance. | `list(map(string))` | `[]` | no |
268+
| <a name="input_enable_ssh"></a> [enable\_ssh](#input\_enable\_ssh) | Enable login to the node through SSH. | `bool` | `false` | no |
269+
| <a name="input_example_name"></a> [example\_name](#input\_example\_name) | The name as prefix used to create resources. | `string` | `"tf-example-kubernetes"` | no |
270+
| <a name="input_install_cloud_monitor"></a> [install\_cloud\_monitor](#input\_install\_cloud\_monitor) | Install cloud monitor agent on ECS. | `bool` | `true` | no |
271+
| <a name="input_instance_charge_type"></a> [instance\_charge\_type](#input\_instance\_charge\_type) | The charge type of instance. Choices are 'PostPaid' and 'PrePaid'. | `string` | `"PostPaid"` | no |
272+
| <a name="input_k8s_name_prefix"></a> [k8s\_name\_prefix](#input\_k8s\_name\_prefix) | The name prefix used to create several kubernetes clusters. Default to variable `example_name` | `string` | `""` | no |
273+
| <a name="input_k8s_number"></a> [k8s\_number](#input\_k8s\_number) | The number of kubernetes cluster. | `number` | `1` | no |
274+
| <a name="input_k8s_pod_cidr"></a> [k8s\_pod\_cidr](#input\_k8s\_pod\_cidr) | The kubernetes pod cidr block. It cannot be equals to vpc's or vswitch's and cannot be in them. | `string` | `"172.20.0.0/16"` | no |
275+
| <a name="input_k8s_service_cidr"></a> [k8s\_service\_cidr](#input\_k8s\_service\_cidr) | The kubernetes service cidr block. It cannot be equals to vpc's or vswitch's or pod's and cannot be in them. | `string` | `"172.21.0.0/20"` | no |
276+
| <a name="input_k8s_version"></a> [k8s\_version](#input\_k8s\_version) | The version of the kubernetes version. | `string` | `""` | no |
277+
| <a name="input_k8s_worker_number"></a> [k8s\_worker\_number](#input\_k8s\_worker\_number) | The number of worker nodes in kubernetes cluster. | `number` | `2` | no |
278+
| <a name="input_master_instance_types"></a> [master\_instance\_types](#input\_master\_instance\_types) | The ecs instance types used to launch master nodes. | `list(string)` | `[]` | no |
279+
| <a name="input_master_password"></a> [master\_password](#input\_master\_password) | The password of master ECS instance. | `string` | `"Just4Test"` | no |
280+
| <a name="input_memory_size"></a> [memory\_size](#input\_memory\_size) | Memory size used to fetch instance types. | `number` | `2` | no |
281+
| <a name="input_new_nat_gateway"></a> [new\_nat\_gateway](#input\_new\_nat\_gateway) | Whether to create a new nat gateway. In this template, a new nat gateway will create a nat gateway, eip and server snat entries. | `bool` | `true` | no |
282+
| <a name="input_node_cidr_mask"></a> [node\_cidr\_mask](#input\_node\_cidr\_mask) | The node cidr block to specific how many pods can run on single node. Valid values: [24-28]. | `number` | `24` | no |
283+
| <a name="input_number_format"></a> [number\_format](#input\_number\_format) | The number format used to output. | `string` | `"%02d"` | no |
284+
| <a name="input_proxy_mode"></a> [proxy\_mode](#input\_proxy\_mode) | Proxy mode is option of kube-proxy. Valid values: 'ipvs','iptables'. Default to 'iptables'. | `string` | `"iptables"` | no |
285+
| <a name="input_subscription"></a> [subscription](#input\_subscription) | A mapping of fields for Prepaid ECS instances created. | `map(string)` | <pre>{<br> "auto_renew": false,<br> "auto_renew_period": 1,<br> "period": 1,<br> "period_unit": "Month"<br>}</pre> | no |
286+
| <a name="input_system_disk_category"></a> [system\_disk\_category](#input\_system\_disk\_category) | The system disk category used to launch one or more worker ecs instances. | `string` | `"cloud_efficiency"` | no |
287+
| <a name="input_system_disk_size"></a> [system\_disk\_size](#input\_system\_disk\_size) | The system disk size used to launch one or more worker ecs instances. | `number` | `40` | no |
288+
| <a name="input_vpc_cidr"></a> [vpc\_cidr](#input\_vpc\_cidr) | The cidr block used to launch a new vpc when 'vpc\_id' is not specified. | `string` | `"10.0.0.0/8"` | no |
289+
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | Existing vpc id used to create several vswitches and other resources. | `string` | `""` | no |
290+
| <a name="input_vpc_name"></a> [vpc\_name](#input\_vpc\_name) | The vpc name used to create a new vpc when 'vpc\_id' is not specified. Default to variable `example_name` | `string` | `""` | no |
291+
| <a name="input_vswitch_cidrs"></a> [vswitch\_cidrs](#input\_vswitch\_cidrs) | List of cidr blocks used to create several new vswitches when 'vswitch\_ids' is not specified. | `list(string)` | <pre>[<br> "10.1.0.0/16",<br> "10.2.0.0/16",<br> "10.3.0.0/16"<br>]</pre> | no |
292+
| <a name="input_vswitch_ids"></a> [vswitch\_ids](#input\_vswitch\_ids) | List of existing vswitch id. | `list(string)` | `[]` | no |
293+
| <a name="input_vswitch_name_prefix"></a> [vswitch\_name\_prefix](#input\_vswitch\_name\_prefix) | The vswitch name prefix used to create several new vswitches. Default to variable 'example\_name'. | `string` | `""` | no |
294+
| <a name="input_worker_instance_types"></a> [worker\_instance\_types](#input\_worker\_instance\_types) | The ecs instance types used to launch worker nodes. | `list(string)` | `[]` | no |
295+
| <a name="input_worker_password"></a> [worker\_password](#input\_worker\_password) | The password of worker ECS instance. | `list(string)` | <pre>[<br> "Just4Test"<br>]</pre> | no |
296+
297+
## Outputs
298+
299+
| Name | Description |
300+
|------|-------------|
301+
| <a name="output_cluster_id"></a> [cluster\_id](#output\_cluster\_id) | ID of the kunernetes cluster. |
302+
| <a name="output_cluster_nodes"></a> [cluster\_nodes](#output\_cluster\_nodes) | List nodes of cluster. |
303+
| <a name="output_nat_gateway_id"></a> [nat\_gateway\_id](#output\_nat\_gateway\_id) | The ID of the NAT Gateway. |
304+
| <a name="output_security_group_id"></a> [security\_group\_id](#output\_security\_group\_id) | ID of the Security Group used to deploy kubernetes cluster. |
305+
| <a name="output_this_k8s_node_ids"></a> [this\_k8s\_node\_ids](#output\_this\_k8s\_node\_ids) | List ids of of cluster node. |
306+
| <a name="output_vpc_id"></a> [vpc\_id](#output\_vpc\_id) | The ID of the VPC. |
307+
| <a name="output_vswitch_ids"></a> [vswitch\_ids](#output\_vswitch\_ids) | List ID of the VSwitches. |
308+
<!-- END_TF_DOCS -->
233309

234310
Submit Issues
235311
-------------

examples/complete/main.tf

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
variable "profile" {
2-
default = "default"
3-
}
41

52
data "alicloud_zones" "default" {
63
available_resource_creation = "VSwitch"
@@ -18,14 +15,21 @@ resource "alicloud_vswitch" "default" {
1815
zone_id = data.alicloud_zones.default.zones[0].id
1916
}
2017

18+
data "alicloud_instance_types" "cloud_essd" {
19+
availability_zone = data.alicloud_zones.default.zones[0].id
20+
cpu_core_count = 4
21+
memory_size = 8
22+
system_disk_category = "cloud_essd"
23+
}
24+
2125
module "k8s" {
2226
source = "../.."
2327

2428
new_nat_gateway = false
2529
vpc_id = alicloud_vpc.default.id
26-
vswitch_ids = alicloud_vswitch.default.*.id
27-
master_instance_types = ["ecs.n1.medium", "ecs.c5.large", "ecs.n1.medium"]
28-
worker_instance_types = ["ecs.n1.medium"]
30+
vswitch_ids = alicloud_vswitch.default[*].id
31+
master_instance_types = [data.alicloud_instance_types.cloud_essd.instance_types[0].id, data.alicloud_instance_types.cloud_essd.instance_types[1].id, data.alicloud_instance_types.cloud_essd.instance_types[2].id]
32+
worker_instance_types = [data.alicloud_instance_types.cloud_essd.instance_types[0].id]
2933
k8s_pod_cidr = "10.72.0.0/16"
3034
k8s_service_cidr = "172.18.0.0/16"
3135
k8s_worker_number = 2
@@ -40,4 +44,4 @@ data "alicloud_cs_cluster_credential" "auth" {
4044
cluster_id = module.k8s.cluster_id[0]
4145
temporary_duration_minutes = 60
4246
output_file = "~/.kube/config"
43-
}
47+
}

examples/complete/outputs.tf

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Output VPC
1+
# Output VPC
22
output "vpc_id" {
33
description = "The ID of the VPC."
44
value = module.k8s.vpc_id
@@ -10,10 +10,11 @@ output "vswitch_ids" {
1010
}
1111

1212
output "nat_gateway_id" {
13-
value = module.k8s.nat_gateway_id
13+
description = "The ID of the NAT Gateway."
14+
value = module.k8s.nat_gateway_id
1415
}
1516

16-
// Output kubernetes resource
17+
# Output kubernetes resource
1718
output "cluster_id" {
1819
description = "ID of the kunernetes cluster."
1920
value = module.k8s.cluster_id
@@ -32,4 +33,10 @@ output "cluster_nodes" {
3233
output "this_k8s_node_ids" {
3334
description = "List ids of of cluster node."
3435
value = module.k8s.this_k8s_node_ids
35-
}
36+
}
37+
38+
output "output_file" {
39+
description = "The name of the output file."
40+
value = data.alicloud_cs_cluster_credential.auth.output_file
41+
42+
}

examples/complete/variables.tf

Whitespace-only changes.

examples/complete/versions.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
terraform {
2+
required_version = ">= 0.13"
3+
required_providers {
4+
alicloud = {
5+
source = "hashicorp/alicloud"
6+
}
7+
}
8+
}

main.tf

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
// Instance_types data source for instance_type
1+
# Instance_types data source for instance_type
22
data "alicloud_instance_types" "default" {
33
cpu_core_count = var.cpu_core_count
44
memory_size = var.memory_size
55
}
66

7-
// Zones data source for availability_zone
7+
# Zones data source for availability_zone
88
data "alicloud_zones" "default" {
99
available_instance_type = data.alicloud_instance_types.default.instance_types[0].id
1010
}
1111

12-
// If there is not specifying vpc_id, the module will launch a new vpc
12+
# If there is not specifying vpc_id, the module will launch a new vpc
1313
resource "alicloud_vpc" "vpc" {
1414
count = var.create_vpc ? 1 : 0
1515
cidr_block = var.vpc_cidr
1616
vpc_name = var.vpc_name == "" ? var.example_name : var.vpc_name
1717
}
1818

19-
// According to the vswitch cidr blocks to launch several vswitches
19+
# According to the vswitch cidr blocks to launch several vswitches
2020
resource "alicloud_vswitch" "vswitches" {
2121
count = length(var.vswitch_ids) > 0 ? 0 : length(var.vswitch_cidrs)
22-
vpc_id = var.vpc_id == "" ? join("", alicloud_vpc.vpc.*.id) : var.vpc_id
22+
vpc_id = var.vpc_id == "" ? join("", alicloud_vpc.vpc[*].id) : var.vpc_id
2323
cidr_block = var.vswitch_cidrs[count.index]
2424
zone_id = data.alicloud_zones.default.zones[count.index % length(data.alicloud_zones.default.zones)]["id"]
2525
vswitch_name = var.vswitch_name_prefix == "" ? format(
@@ -34,9 +34,9 @@ resource "alicloud_vswitch" "vswitches" {
3434
}
3535

3636
resource "alicloud_nat_gateway" "default" {
37-
count = var.new_nat_gateway == true ? 1 : 0
38-
vpc_id = var.vpc_id == "" ? join("", alicloud_vpc.vpc.*.id) : var.vpc_id
39-
name = var.example_name
37+
count = var.new_nat_gateway == true ? 1 : 0
38+
vpc_id = var.vpc_id == "" ? join("", alicloud_vpc.vpc[*].id) : var.vpc_id
39+
nat_gateway_name = var.example_name
4040
}
4141

4242
resource "alicloud_eip" "default" {
@@ -53,7 +53,7 @@ resource "alicloud_eip_association" "default" {
5353
resource "alicloud_snat_entry" "default" {
5454
count = var.new_nat_gateway == false ? 0 : length(var.vswitch_ids) > 0 ? length(var.vswitch_ids) : length(var.vswitch_cidrs)
5555
snat_table_id = alicloud_nat_gateway.default[0].snat_table_ids
56-
source_vswitch_id = length(var.vswitch_ids) > 0 ? split(",", join(",", var.vswitch_ids))[count.index % length(split(",", join(",", var.vswitch_ids)))] : length(var.vswitch_cidrs) < 1 ? "" : split(",", join(",", alicloud_vswitch.vswitches.*.id))[count.index % length(split(",", join(",", alicloud_vswitch.vswitches.*.id)))]
56+
source_vswitch_id = length(var.vswitch_ids) > 0 ? split(",", join(",", var.vswitch_ids))[count.index % length(split(",", join(",", var.vswitch_ids)))] : length(var.vswitch_cidrs) < 1 ? "" : split(",", join(",", alicloud_vswitch.vswitches[*].id))[count.index % length(split(",", join(",", alicloud_vswitch.vswitches[*].id)))]
5757
snat_ip = alicloud_eip.default[0].ip_address
5858
depends_on = [alicloud_eip_association.default]
5959
}
@@ -70,7 +70,7 @@ resource "alicloud_cs_kubernetes" "k8s" {
7070
var.k8s_name_prefix,
7171
format(var.number_format, count.index + 1),
7272
)
73-
master_vswitch_ids = length(var.vswitch_ids) > 0 ? split(",", join(",", var.vswitch_ids)) : length(var.vswitch_cidrs) < 1 ? [] : split(",", join(",", alicloud_vswitch.vswitches.*.id))
73+
master_vswitch_ids = length(var.vswitch_ids) > 0 ? split(",", join(",", var.vswitch_ids)) : length(var.vswitch_cidrs) < 1 ? [] : split(",", join(",", alicloud_vswitch.vswitches[*].id))
7474
master_instance_types = var.master_instance_types
7575
node_cidr_mask = var.node_cidr_mask
7676
enable_ssh = var.enable_ssh
@@ -95,7 +95,7 @@ resource "alicloud_cs_kubernetes_node_pool" "default" {
9595

9696
name = alicloud_cs_kubernetes.k8s[count.index].name
9797
cluster_id = alicloud_cs_kubernetes.k8s[count.index].id
98-
vswitch_ids = length(var.vswitch_ids) > 0 ? split(",", join(",", var.vswitch_ids)) : length(var.vswitch_cidrs) < 1 ? [] : split(",", join(",", alicloud_vswitch.vswitches.*.id))
98+
vswitch_ids = length(var.vswitch_ids) > 0 ? split(",", join(",", var.vswitch_ids)) : length(var.vswitch_cidrs) < 1 ? [] : split(",", join(",", alicloud_vswitch.vswitches[*].id))
9999
password = var.worker_password[count.index]
100100

101101
desired_size = var.k8s_worker_number

outputs.tf

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
// Output VPC
1+
# Output VPC
22
output "vpc_id" {
33
description = "The ID of the VPC."
44
value = alicloud_cs_kubernetes.k8s[0].vpc_id
55
}
66

77
output "vswitch_ids" {
88
description = "List ID of the VSwitches."
9-
value = [alicloud_cs_kubernetes.k8s.*.vswitch_ids]
9+
value = [alicloud_cs_kubernetes.k8s[*].vswitch_ids]
1010
}
1111

1212
output "nat_gateway_id" {
13-
value = alicloud_cs_kubernetes.k8s[0].nat_gateway_id
13+
description = "The ID of the NAT Gateway."
14+
value = alicloud_cs_kubernetes.k8s[0].nat_gateway_id
1415
}
1516

16-
// Output kubernetes resource
17+
# Output kubernetes resource
1718
output "cluster_id" {
1819
description = "ID of the kunernetes cluster."
19-
value = alicloud_cs_kubernetes.k8s.*.id
20+
value = alicloud_cs_kubernetes.k8s[*].id
2021
}
2122

2223
output "security_group_id" {
@@ -26,10 +27,10 @@ output "security_group_id" {
2627

2728
output "cluster_nodes" {
2829
description = "List nodes of cluster."
29-
value = alicloud_cs_kubernetes.k8s.*.worker_nodes
30+
value = alicloud_cs_kubernetes.k8s[*].worker_nodes
3031
}
3132

3233
output "this_k8s_node_ids" {
3334
description = "List ids of of cluster node."
34-
value = [for _, obj in concat(alicloud_cs_kubernetes.k8s.*.worker_nodes, [{}])[0] : lookup(obj,"id")]
35-
}
35+
value = [for _, obj in concat(alicloud_cs_kubernetes.k8s[*].worker_nodes, [{}])[0] : obj["id"]]
36+
}

variables.tf

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
1-
######################
2-
# provider
3-
######################
4-
variable "region" {
5-
description = "(Deprecated from version 1.4.0) The region used to launch this module resources."
6-
type = string
7-
default = ""
8-
}
9-
variable "profile" {
10-
description = "(Deprecated from version 1.4.0) The profile name as set in the shared credentials file. If not set, it will be sourced from the ALICLOUD_PROFILE environment variable."
11-
type = string
12-
default = ""
13-
}
14-
variable "shared_credentials_file" {
15-
description = "(Deprecated from version 1.4.0) This is the path to the shared credentials file. If this is not set and a profile is specified, $HOME/.aliyun/config.json will be used."
16-
type = string
17-
default = ""
18-
}
19-
variable "skip_region_validation" {
20-
description = "(Deprecated from version 1.4.0) Skip static validation of region ID. Used by users of alternative AlibabaCloud-like APIs or users w/ access to regions that are not public (yet)."
21-
type = bool
22-
default = false
23-
}
241

252
######################
263
# Instance typs variables
@@ -242,14 +219,3 @@ variable "data_disks" {
242219
default = []
243220
}
244221

245-
variable "disk_category" {
246-
description = "The system disk category used to launch one or more worker ecs instances."
247-
type = string
248-
default = "cloud_efficiency"
249-
}
250-
251-
variable "disk_size" {
252-
description = "The system disk size used to launch one or more worker ecs instances."
253-
type = number
254-
default = 40
255-
}

versions.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
terraform {
2+
required_version = ">= 0.13"
3+
required_providers {
4+
alicloud = {
5+
source = "hashicorp/alicloud"
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)