diff --git a/environment/huaweicloud/internet/internet_temp.tf b/environment/huaweicloud/internet/internet_temp.tf index 2e3e5e7d51ebcfe73abe1e1817fabc498306422c..32015727fac8dc3511a19b93f2aeb7915f9d8ddb 100644 --- a/environment/huaweicloud/internet/internet_temp.tf +++ b/environment/huaweicloud/internet/internet_temp.tf @@ -4,9 +4,13 @@ resource "huaweicloud_vpc_eip_v1" "this" { type = "5_bgp" } bandwidth { - name = "${lookup(var.eips[count.index], "bandwidth-name", null)}" - size = "${lookup(var.eips[count.index], "size", null)}" - share_type = "PER" - charge_mode = "traffic" + id = "${lookup(var.eips[count.index], "bandwidth_id", null)}" + share_type = "WHOLE" } } + +resource "huaweicloud_vpc_bandwidth_v2" "this" { + count = "${length(var.bandwidths)}" + name = "${lookup(var.bandwidths[count.index], "name", null)}" + size = "${lookup(var.bandwidths[count.index], "size", 5)}" +} diff --git a/environment/huaweicloud/internet/internet_vars.tf b/environment/huaweicloud/internet/internet_vars.tf index 86a9ac9d70b953a86fdb5affecd0c72d05e8eb2c..0664e72c98fe36409ab802c56354c304c68a5997 100644 --- a/environment/huaweicloud/internet/internet_vars.tf +++ b/environment/huaweicloud/internet/internet_vars.tf @@ -3,3 +3,10 @@ variable "eips" { description = "List of eips" default = [] } + + +variable "bandwidths" { + type = list(map(string)) + description = "List of bandwidths" + default = [] +} diff --git a/environment/huaweicloud/internet/out_puts.tf b/environment/huaweicloud/internet/out_puts.tf index 4f55f0b818a5e9befa53f80ef41e036958087fd6..b4fc5f17ca9ea7d84f7b3b34056c0bbfe3f3f042 100644 --- a/environment/huaweicloud/internet/out_puts.tf +++ b/environment/huaweicloud/internet/out_puts.tf @@ -7,3 +7,8 @@ output "this_eip_addresses" { description = "List of address of the eips" value = "${join(",",huaweicloud_vpc_eip_v1.this.*.publicip.0.ip_address)}" } + +output "this_bandwidth_ids" { + description = "List of bandwidth ids" + value = "${join(",",huaweicloud_vpc_bandwidth_v2.this.*.id)}" +} diff --git a/environment/huaweicloud/resources.tf b/environment/huaweicloud/resources.tf index 00d04192708d10dfb50b28a3b84467a8b624a3dd..40a3ddae17e965083ef1e0c7e044e87931762275 100644 --- a/environment/huaweicloud/resources.tf +++ b/environment/huaweicloud/resources.tf @@ -49,23 +49,30 @@ module "cce" { module "internet" { source = "./internet" + + bandwidths = [ + { + name = "bandwidth-mail" + size = "5" + }, + { + name = "bandwidth-website" + size = "30" + } + ] eips = [ { - bandwidth-name = "bandwidth-01", - size = "5" + bandwidth_id = "${split(",", module.internet.this_bandwidth_ids)[0]}" }, { - bandwidth-name = "bandwidth-02", - size = "5" + bandwidth_id = "${split(",", module.internet.this_bandwidth_ids)[0]}" }, { - bandwidth-name = "bandwidth-03", - size = "5" + bandwidth_id = "${split(",", module.internet.this_bandwidth_ids)[0]}" }, { - bandwidth-name = "bandwidth-04", - size = "5" + bandwidth_id = "${split(",", module.internet.this_bandwidth_ids)[1]}" } ] }