From e0b1942f8e1f105e274f1071508e08005ea3ec32 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 28 Oct 2021 16:54:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?nat=E5=8F=98=E4=B8=BA=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/complete/main.tf | 2 +- main.tf | 8 +++++--- variables.tf | 24 +++++++++++++++++------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/examples/complete/main.tf b/examples/complete/main.tf index cc3ba6a..e17bf27 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -3,7 +3,7 @@ variable "profile" { } variable "region" { - default = "cn-hangzhou" + default = "cn-shanghai" } data "alicloud_vpcs" "default" { diff --git a/main.tf b/main.tf index d600fb9..22a8efc 100644 --- a/main.tf +++ b/main.tf @@ -43,9 +43,11 @@ resource "alicloud_vswitch" "vswitches" { } resource "alicloud_nat_gateway" "default" { - count = var.new_nat_gateway == true ? 1 : 0 - vpc_id = var.vpc_id == "" ? join("", alicloud_vpc.vpc.*.id) : var.vpc_id - name = var.example_name + count = var.new_nat_gateway == true ? 1 : 0 + vpc_id = var.vpc_id == "" ? join("", alicloud_vpc.vpc.*.id) : var.vpc_id + name = var.example_name + nat_type = var.nat_type + 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)))] } resource "alicloud_eip" "default" { diff --git a/variables.tf b/variables.tf index 42d2daa..5dc69e1 100644 --- a/variables.tf +++ b/variables.tf @@ -4,12 +4,12 @@ variable "region" { description = "The region used to launch this module resources." type = string - default = "" + default = "cn-shanghai" } variable "profile" { description = "The profile name as set in the shared credentials file. If not set, it will be sourced from the ALICLOUD_PROFILE environment variable." type = string - default = "" + default = "default" } variable "shared_credentials_file" { description = "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." @@ -112,13 +112,13 @@ variable "new_nat_gateway" { variable "master_instance_types" { description = "The ecs instance types used to launch master nodes." type = list(string) - default = [] + default = ["ecs.n1.medium", "ecs.c5.large", "ecs.n1.medium"] } variable "worker_instance_types" { description = "The ecs instance types used to launch worker nodes." type = list(string) - default = [] + default = ["ecs.n1.medium"] } variable "node_cidr_mask" { @@ -177,9 +177,9 @@ variable "k8s_service_cidr" { } variable "k8s_version" { - description = "The version of the kubernetes version. Valid values: '1.16.6-aliyun.1','1.14.8-aliyun.1'. Default to '1.16.6-aliyun.1'." + description = "The version of the kubernetes version. Valid values: 1.20.11-aliyun.1 1.18.8-aliyun.1." type = string - default = "1.16.6-aliyun.1" + default = "1.20.11-aliyun.1" } variable "cluster_addons" { @@ -188,5 +188,15 @@ variable "cluster_addons" { name = string config = string })) - default = [] + default = [{ + "name" = "flannel", + "config" = "", + } + ] +} + +variable "nat_type" { + description = "The type of NAT gateway. Valid values: 'Enhanced'." + type = string + default = "Enhanced" } From 3e7ba0925c491f086888d319475eff20b11a4230 Mon Sep 17 00:00:00 2001 From: "992735020@qq.com" <992735020@qq.com> Date: Tue, 2 Nov 2021 11:43:50 +0800 Subject: [PATCH 2/2] modify format --- variables.tf | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/variables.tf b/variables.tf index 5dc69e1..c2d26b0 100644 --- a/variables.tf +++ b/variables.tf @@ -4,12 +4,12 @@ variable "region" { description = "The region used to launch this module resources." type = string - default = "cn-shanghai" + default = "" } variable "profile" { description = "The profile name as set in the shared credentials file. If not set, it will be sourced from the ALICLOUD_PROFILE environment variable." type = string - default = "default" + default = "" } variable "shared_credentials_file" { description = "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." @@ -112,13 +112,13 @@ variable "new_nat_gateway" { variable "master_instance_types" { description = "The ecs instance types used to launch master nodes." type = list(string) - default = ["ecs.n1.medium", "ecs.c5.large", "ecs.n1.medium"] + default = [] } variable "worker_instance_types" { description = "The ecs instance types used to launch worker nodes." type = list(string) - default = ["ecs.n1.medium"] + default = [] } variable "node_cidr_mask" { @@ -183,14 +183,14 @@ variable "k8s_version" { } variable "cluster_addons" { - description = "Addon components in kubernetes cluster" - type = list(object({ - name = string - config = string + description = "Addon components in kubernetes cluster" + type = list(object({ + name = string + config = string })) - default = [{ - "name" = "flannel", - "config" = "", + default = [{ + "name" = "flannel", + "config" = "", } ] }