Skip to content

Commit

Permalink
fix output and input parameter grammar error
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhu36 committed Dec 3, 2019
1 parent 2fa4c11 commit 8d42aa1
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 21 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
## 1.1.0 (Unreleased)
## 1.2.0 (Unreleased)
## 1.1.0 (December 3, 2019)

BUG FIXES:

- fix output and input parameter grammar error [GH-5](https://github.com/terraform-alicloud-modules/terraform-alicloud-managed-kubernetes/pull/5)

## 1.0.0 (December 3, 2019)

IMPROVEMENTS:
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ If you have not set them yet, please install [aliyun-cli](https://github.com/ali

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

### 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.
```hcl
// Create a scaling group using autoscaling module at first.
module "managed-k8s" {
source = "terraform-alicloud-modules/managed-kubernetes/alicloud"
profile = "Your-profile-name"
Expand All @@ -66,12 +64,12 @@ In other words, the specified vpc has a nat gateway and there are several snat e

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

1. Create a new sls project with `new_sls_project`:
1. Create a new sls project with `new_sls_project`:
```hcl
new_sls_project = true
```
1. Using existing sls project with `sls_project_name`:
1. Using existing sls project with `sls_project_name`:
```hcl
sls_project_name = "Your-sls-project-name"
```
Expand Down
4 changes: 2 additions & 2 deletions locals.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
locals {
k8s_name = substr(join("-", [var.k8s_name_prefix, "", random_uuid.this.result]), 0, 63)
k8s_name = substr(join("-", [var.k8s_name_prefix, random_uuid.this.result]), 0, 63)
new_vpc_name = "for-${local.k8s_name}"
new_vpc_tags = {
Created = "Terraform"
For = "modules/terraform-alicloud-managed-kubernetes"
K8s = local.k8s_name
}
vswitch_ids = length(var.vswitch_ids) > 0 ? var.vswitch_ids : alicloud_vswitch.new.*.id
sls_project = var.sls_project_name == "" ? alicloud_log_project.new.0.id : var.sls_project_name
sls_project = var.sls_project_name == "" ? concat(alicloud_log_project.new.*.id, [""])[0] : var.sls_project_name
instance_types = length(var.worker_instance_types) > 0 ? var.worker_instance_types : [data.alicloud_instance_types.default.ids.0]
}

Expand Down
7 changes: 4 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ provider "alicloud" {
}

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

Expand All @@ -29,7 +30,7 @@ resource "alicloud_cs_managed_kubernetes" "this" {
worker_instance_types = var.worker_instance_types
worker_number = var.worker_number
log_config {
type = local.sls_project == "" ? null : "SLS"
type = "SLS"
project = local.sls_project == "" ? null : local.sls_project
}
depends_on = [alicloud_snat_entry.new]
Expand Down
10 changes: 5 additions & 5 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// Output kubernetes resource
output "this_k8s_name" {
description = "Name of the kunernetes cluster."
value = alicloud_cs_managed_kubernetes.this.0.id
value = concat(alicloud_cs_managed_kubernetes.this.*.name, [""])[0]
}
output "this_k8s_id" {
description = "ID of the kunernetes cluster."
value = alicloud_cs_managed_kubernetes.this.0.id
value = concat(alicloud_cs_managed_kubernetes.this.*.id, [""])[0]
}
output "this_k8s_nodes" {
description = "List nodes of cluster."
value = alicloud_cs_managed_kubernetes.this.0.worker_nodes
value = concat(alicloud_cs_managed_kubernetes.this.*.worker_nodes, [""])[0]
}
// Output VPC
output "this_vpc_id" {
description = "The ID of the VPC."
value = alicloud_cs_managed_kubernetes.this.0.vpc_id
value = concat(alicloud_cs_managed_kubernetes.this.*.vpc_id, [""])[0]
}

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

//Output SLS
Expand Down
12 changes: 6 additions & 6 deletions vpc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ resource "alicloud_vpc" "new" {
// According to the vswitch cidr blocks to launch several vswitches
resource "alicloud_vswitch" "new" {
count = var.new_vpc == true ? length(var.vswitch_cidrs) : 0
vpc_id = alicloud_vpc.new.0.id
vpc_id = concat(alicloud_vpc.new.*.id, [""])[0]
cidr_block = var.vswitch_cidrs[count.index]
availability_zone = length(var.availability_zones) > 0 ? element(var.availability_zones, count.index) : element(data.alicloud_zones.default.ids.*, count.index)
name = local.new_vpc_name
Expand All @@ -30,7 +30,7 @@ resource "alicloud_vswitch" "new" {

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

resource "alicloud_eip_association" "new" {
count = var.new_vpc == true ? 1 : 0
allocation_id = alicloud_eip.new.0.id
instance_id = alicloud_nat_gateway.new.0.id
allocation_id = concat(alicloud_eip.new.*.id, [""])[0]
instance_id = concat(alicloud_nat_gateway.new.*.id, [""])[0]
}

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

0 comments on commit 8d42aa1

Please sign in to comment.