Skip to content

Commit 8d42aa1

Browse files
committed
fix output and input parameter grammar error
1 parent 2fa4c11 commit 8d42aa1

File tree

6 files changed

+26
-21
lines changed

6 files changed

+26
-21
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
## 1.1.0 (Unreleased)
1+
## 1.2.0 (Unreleased)
2+
## 1.1.0 (December 3, 2019)
3+
4+
BUG FIXES:
5+
6+
- fix output and input parameter grammar error [GH-5](https://github.com/terraform-alicloud-modules/terraform-alicloud-managed-kubernetes/pull/5)
7+
28
## 1.0.0 (December 3, 2019)
39

410
IMPROVEMENTS:

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ If you have not set them yet, please install [aliyun-cli](https://github.com/ali
2424

2525
### 1 Create a new vpc, several new vswitches and a new nat gateway for the cluster.
2626
```hcl
27-
// Create a scaling group using autoscaling module at first.
2827
module "managed-k8s" {
2928
source = "terraform-alicloud-modules/managed-kubernetes/alicloud"
3029
profile = "Your-profile-name"
@@ -45,7 +44,6 @@ a new EIP with `new_eip_bandwidth` and several snat entries for vswitches.
4544

4645
### 2 Using existing vpc and vswitches by specifying `vswitch_ids`. Setting `new_nat_gateway=true` to add a new nat gateway in the vswitches' vpc.
4746
```hcl
48-
// Create a scaling group using autoscaling module at first.
4947
module "managed-k8s" {
5048
source = "terraform-alicloud-modules/managed-kubernetes/alicloud"
5149
profile = "Your-profile-name"
@@ -66,12 +64,12 @@ In other words, the specified vpc has a nat gateway and there are several snat e
6664

6765
This moudle can set [sls project](https://www.terraform.io/docs/providers/alicloud/r/log_project.html) config for this module
6866

69-
1. Create a new sls project with `new_sls_project`:
67+
1. Create a new sls project with `new_sls_project`:
7068
```hcl
7169
new_sls_project = true
7270
```
7371
74-
1. Using existing sls project with `sls_project_name`:
72+
1. Using existing sls project with `sls_project_name`:
7573
```hcl
7674
sls_project_name = "Your-sls-project-name"
7775
```

locals.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
locals {
2-
k8s_name = substr(join("-", [var.k8s_name_prefix, "", random_uuid.this.result]), 0, 63)
2+
k8s_name = substr(join("-", [var.k8s_name_prefix, random_uuid.this.result]), 0, 63)
33
new_vpc_name = "for-${local.k8s_name}"
44
new_vpc_tags = {
55
Created = "Terraform"
66
For = "modules/terraform-alicloud-managed-kubernetes"
77
K8s = local.k8s_name
88
}
99
vswitch_ids = length(var.vswitch_ids) > 0 ? var.vswitch_ids : alicloud_vswitch.new.*.id
10-
sls_project = var.sls_project_name == "" ? alicloud_log_project.new.0.id : var.sls_project_name
10+
sls_project = var.sls_project_name == "" ? concat(alicloud_log_project.new.*.id, [""])[0] : var.sls_project_name
1111
instance_types = length(var.worker_instance_types) > 0 ? var.worker_instance_types : [data.alicloud_instance_types.default.ids.0]
1212
}
1313

main.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ provider "alicloud" {
99
}
1010

1111
resource "alicloud_log_project" "new" {
12-
count = var.new_sls_project == true ? 1 : 0
13-
name = "for-${local.k8s_name}"
12+
count = var.new_sls_project == true ? 1 : 0
13+
// sls project name must end with lower letter
14+
name = format("%s-end", substr("for-${local.k8s_name}", 0, 59))
1415
description = "created by terraform for managedkubernetes cluster"
1516
}
1617

@@ -29,7 +30,7 @@ resource "alicloud_cs_managed_kubernetes" "this" {
2930
worker_instance_types = var.worker_instance_types
3031
worker_number = var.worker_number
3132
log_config {
32-
type = local.sls_project == "" ? null : "SLS"
33+
type = "SLS"
3334
project = local.sls_project == "" ? null : local.sls_project
3435
}
3536
depends_on = [alicloud_snat_entry.new]

outputs.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
// Output kubernetes resource
22
output "this_k8s_name" {
33
description = "Name of the kunernetes cluster."
4-
value = alicloud_cs_managed_kubernetes.this.0.id
4+
value = concat(alicloud_cs_managed_kubernetes.this.*.name, [""])[0]
55
}
66
output "this_k8s_id" {
77
description = "ID of the kunernetes cluster."
8-
value = alicloud_cs_managed_kubernetes.this.0.id
8+
value = concat(alicloud_cs_managed_kubernetes.this.*.id, [""])[0]
99
}
1010
output "this_k8s_nodes" {
1111
description = "List nodes of cluster."
12-
value = alicloud_cs_managed_kubernetes.this.0.worker_nodes
12+
value = concat(alicloud_cs_managed_kubernetes.this.*.worker_nodes, [""])[0]
1313
}
1414
// Output VPC
1515
output "this_vpc_id" {
1616
description = "The ID of the VPC."
17-
value = alicloud_cs_managed_kubernetes.this.0.vpc_id
17+
value = concat(alicloud_cs_managed_kubernetes.this.*.vpc_id, [""])[0]
1818
}
1919

2020
output "this_vswitch_ids" {
@@ -23,7 +23,7 @@ output "this_vswitch_ids" {
2323
}
2424
output "this_security_group_id" {
2525
description = "ID of the Security Group used to deploy kubernetes cluster."
26-
value = alicloud_cs_managed_kubernetes.this.0.security_group_id
26+
value = concat(alicloud_cs_managed_kubernetes.this.*.security_group_id, [""])[0]
2727
}
2828

2929
//Output SLS

vpc.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ resource "alicloud_vpc" "new" {
2121
// According to the vswitch cidr blocks to launch several vswitches
2222
resource "alicloud_vswitch" "new" {
2323
count = var.new_vpc == true ? length(var.vswitch_cidrs) : 0
24-
vpc_id = alicloud_vpc.new.0.id
24+
vpc_id = concat(alicloud_vpc.new.*.id, [""])[0]
2525
cidr_block = var.vswitch_cidrs[count.index]
2626
availability_zone = length(var.availability_zones) > 0 ? element(var.availability_zones, count.index) : element(data.alicloud_zones.default.ids.*, count.index)
2727
name = local.new_vpc_name
@@ -30,7 +30,7 @@ resource "alicloud_vswitch" "new" {
3030

3131
resource "alicloud_nat_gateway" "new" {
3232
count = var.new_vpc == true ? 1 : 0
33-
vpc_id = alicloud_vpc.new.0.id
33+
vpc_id = concat(alicloud_vpc.new.*.id, [""])[0]
3434
name = local.new_vpc_name
3535
// tags = local.new_vpc_tags
3636
}
@@ -44,13 +44,13 @@ resource "alicloud_eip" "new" {
4444

4545
resource "alicloud_eip_association" "new" {
4646
count = var.new_vpc == true ? 1 : 0
47-
allocation_id = alicloud_eip.new.0.id
48-
instance_id = alicloud_nat_gateway.new.0.id
47+
allocation_id = concat(alicloud_eip.new.*.id, [""])[0]
48+
instance_id = concat(alicloud_nat_gateway.new.*.id, [""])[0]
4949
}
5050

5151
resource "alicloud_snat_entry" "new" {
5252
count = var.new_vpc == true ? length(var.vswitch_cidrs) : 0
53-
snat_table_id = alicloud_nat_gateway.new.0.snat_table_ids
53+
snat_table_id = concat(alicloud_nat_gateway.new.*.snat_table_ids, [""])[0]
5454
source_vswitch_id = alicloud_vswitch.new[count.index].id
55-
snat_ip = alicloud_eip.new.0.ip_address
55+
snat_ip = concat(alicloud_eip.new.*.ip_address, [""])[0]
5656
}

0 commit comments

Comments
 (0)