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

Creating VPC does not give the correct cidr and name on first apply #7967

Open
walbertus opened this issue Dec 10, 2024 · 2 comments
Open

Creating VPC does not give the correct cidr and name on first apply #7967

walbertus opened this issue Dec 10, 2024 · 2 comments

Comments

@walbertus
Copy link

walbertus commented Dec 10, 2024

Terraform Version

OpenTofu v1.8.7
on darwin_amd64
+ provider registry.opentofu.org/hashicorp/alicloud v1.237.0

Affected Resource(s)

  • alicloud_vpc

Terraform Configuration Files

more details: walbertus/learning@6eef608

resource "alicloud_vpc" "default" {
  is_default  = true
  description = "test"
  cidr_block  = "10.0.0.0/16"
  vpc_name    = "test-vpc"
  enable_ipv6 = false
}

Expected Behavior

VPC should be created with CIDR "10.0.0.0/16" and name "test-vpc" after the first apply.

Actual Behavior

VPC is created with CIDR "127.16.0.0/16" and an empty name.
Second plan result:

  # alicloud_vpc.default will be updated in-place
  ~ resource "alicloud_vpc" "default" {
      ~ cidr_block            = "172.16.0.0/16" -> "10.0.0.0/16"
      + description           = "test"
        id                    = "vpc-bp1wdhr0muswtagst6gly"
        tags                  = {}
      + vpc_name              = "test-vpc"
        # (11 unchanged attributes hidden)
    }

Run apply the second time finally set the correct CIDR and name.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. tofu plan
  2. tofu apply -auto-approve
  3. tofu plan
  4. tofu apply -auto-approve
@walbertus
Copy link
Author

I'm trying to add those parameters when creating the default VPC but still failed. ref: walbertus@7ac5dd2

It turns out it's because the API for creating default VPC does not accept those parameter. https://api.alibabacloud.com/document/Vpc/2016-04-28/CreateDefaultVpc
Why the API does not allow those params? Next apply command able to correctly update the value.

@walbertus
Copy link
Author

Trying to do it in resourceAliCloudVpcVpcUpdate also failed, probably because it's too quick.

There's no solution on this for now unless the API is updated. Workaround is to execute the tofu apply twice.

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