Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to close the ipv6 function of VPC and vSwitch successfully in terraform #7526

Open
songhd opened this issue Aug 2, 2024 · 0 comments
Open

Comments

@songhd
Copy link

songhd commented Aug 2, 2024

Description

When using the Alicloud Terraform provider to close ipv6 function on the AliCloud VPC and vSwitch, I noticed that the close order of terraform has a conflict with AliCloud design.

Terraform will try to close ipv6 function on VPC first since the vSwitch resource depends on VPC resource, while AliCloud requires the ipv6 function of the switch be disabled earlier.

Therefore, I have raised this issue to apply for a solution in this scenario.

Category

AliCloud

Aspect

VPC(ipv6)

Details

An error will be raised when you try to close the ipv6 function by change the enable_ipv6 value from true to false.
image

Terraform Version

1.5.7

Affected Resource(s)

VPC

Terraform Configuration Files

resource "alicloud_vpc" "this" {
  count = local.create_vpc ? 1 : 0

  vpc_name                = var.name
  resource_group_id       = local.resource_group_id
  ipv4_ipam_pool_id       = var.ipv4_ipam_pool_id
  system_route_table_name = "${var.name}-default"
  cidr_block              = var.use_ipam_pool ? null : var.cidr
  ipv6_cidr_block         = var.ipv6_cidr
  enable_ipv6             = var.enable_ipv6 ? true : false
  ipv6_isp                = var.ipv6_isp
}

resource "alicloud_vswitch" "public" {
  count = local.create_public_subnets ? local.len_public_subnets : 0

  vpc_id               = local.vpc_id
  vswitch_name         = var.vswitch_name
  enable_ipv6          = var.enable_ipv6 && length(var.public_subnet_ipv6_prefixes) > 0
  ipv6_cidr_block_mask = element(concat(var.public_subnet_ipv6_prefixes, [""]), count.index)
  zone_id              =  element(var.azs, count.index) 
  cidr_block           = element(concat(var.public_subnets, [""]), count.index)
}

Debug Output

N/A

Panic Output

N/A

Expected Behavior

The ipv6 function can be disabled successfully by change the value of enable_ipv6 argument from true to false.

Actual Behavior

Error raised

Steps to Reproduce

N/A

References

[alicloud_vpc_document]
[(https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/vpc)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant