Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions data/data/alibabacloud/cluster/vpc/eip.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
resource "alicloud_eip_address" "eip" {
count = length(var.vswitch_ids) == 0 ? 1 : 0

description = local.description
address_name = "${local.prefix}-eip"
payment_type = "PayAsYouGo"
Expand All @@ -13,7 +15,9 @@ resource "alicloud_eip_address" "eip" {
}

resource "alicloud_eip_association" "eip_association" {
allocation_id = alicloud_eip_address.eip.id
instance_id = alicloud_nat_gateway.nat_gateway.id
count = length(var.vswitch_ids) == 0 ? 1 : 0

allocation_id = alicloud_eip_address.eip[0].id
instance_id = alicloud_nat_gateway.nat_gateway[0].id
instance_type = "Nat"
}
10 changes: 6 additions & 4 deletions data/data/alibabacloud/cluster/vpc/nat_gateway.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

resource "alicloud_nat_gateway" "nat_gateway" {
count = length(var.vswitch_ids) == 0 ? 1 : 0

vpc_id = local.vpc_id
nat_gateway_name = "${local.prefix}-ngw"
vswitch_id = alicloud_vswitch.vswitch_nat_gateway.id
vswitch_id = alicloud_vswitch.vswitch_nat_gateway[0].id
internet_charge_type = "PayByLcu"
nat_type = "Enhanced"
description = local.description
Expand All @@ -15,10 +17,10 @@ resource "alicloud_nat_gateway" "nat_gateway" {
}

resource "alicloud_snat_entry" "snat_entrys" {
count = length(local.vswitch_ids)
count = length(var.vswitch_ids) == 0 ? length(local.vswitch_ids) : 0

depends_on = [alicloud_eip_association.eip_association]
snat_table_id = alicloud_nat_gateway.nat_gateway.snat_table_ids
snat_table_id = alicloud_nat_gateway.nat_gateway[0].snat_table_ids
source_vswitch_id = local.vswitch_ids[count.index]
snat_ip = alicloud_eip_address.eip.ip_address
snat_ip = alicloud_eip_address.eip[0].ip_address
}
12 changes: 0 additions & 12 deletions data/data/alibabacloud/cluster/vpc/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,6 @@ output "az_to_vswitch_id" {
value = zipmap(data.alicloud_vswitches.vswitches.vswitches.*.zone_id, data.alicloud_vswitches.vswitches.vswitches.*.id)
}

output "gw_id" {
value = alicloud_nat_gateway.nat_gateway.id
}

output "eip_id" {
value = alicloud_eip_address.eip.id
}

output "eip_ip" {
value = alicloud_eip_address.eip.ip_address
}

output "slb_ids" {
value = [alicloud_slb_load_balancer.slb_external.id, alicloud_slb_load_balancer.slb_internal.id]
}
Expand Down
2 changes: 2 additions & 0 deletions data/data/alibabacloud/cluster/vpc/vpc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ resource "alicloud_vswitch" "vswitches" {
}

resource "alicloud_vswitch" "vswitch_nat_gateway" {
count = length(var.vswitch_ids) == 0 ? 1 : 0

vswitch_name = "${local.prefix}-vswitch-nat-gateway"
description = local.description
vpc_id = local.vpc_id
Expand Down