aliyun / terraform-provider-alicloud

Terraform AliCloud provider
https://www.terraform.io/docs/providers/alicloud/
Mozilla Public License 2.0
589 stars 553 forks source link

data resource alicloud_vpcs cannot fetch any data but the vpc is existing and terraform show 'Read complete' #5852

Open DavidJohn197749 opened 1 year ago

DavidJohn197749 commented 1 year ago

Terraform Version

Terraform v1.3.6
on linux_amd64
+ provider registry.terraform.io/aliyun/alicloud v1.196.0

Your version of Terraform is out of date! The latest version
is 1.3.7. You can update by downloading from https://www.terraform.io/downloads.html

Affected Resource(s)

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

terraform {
}
provider "alicloud" {}
data "alicloud_vpcs" "main" {

    name_regex = "Testing-vpcs"

}
output "vpc" {

  value = data.alicloud_vpcs.main

}

Expected Behavior

the output should not be null, and the output data should same with using aliyun.

Actual Behavior

data.alicloud_vpcs.main: Reading...
data.alicloud_vpcs.main: Read complete after 1s [id=0]

Changes to Outputs:
  + vpc = {
      + cidr_block          = null
      + dhcp_options_set_id = null
      + dry_run             = null
      + enable_details      = true
      + id                  = "0"
      + ids                 = []
      + is_default          = null
      + name_regex          = null
      + names               = []
      + output_file         = null
      + page_number         = null
      + page_size           = 50
      + resource_group_id   = null
      + status              = null
      + tags                = null
      + total_count         = 0
      + vpc_name            = null
      + vpc_owner_id        = null
      + vpcs                = []
      + vswitch_id          = null
    }

You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.

Steps to Reproduce

  1. create a alicloud vpc
  2. terraform init
  3. terraform plan
tamaskiraly commented 6 months ago

@DavidJohn197749 have you figured out a workaround? I am facing the same issue. In my case if I run terraform plan form local with my admin user credentials I get the expected output and all vpcs are listed. But when the GHA pipeline runs with the assumed role that has full VPC permissions the output is empty.

xiaozhu36 commented 6 months ago

Hi @DavidJohn197749 @tamaskiraly What is the region of your vpc belongs? The provider default region is cn-beijing, and it will return empty data if your resources are not in cn-beijing. Maybe you can check it, set a right region and have a try.

tamaskiraly commented 6 months ago

@DavidJohn197749 that was the exact problem, my resources are created in cn-shanghai region and have not specified the region when tried to list the vpcs. Thanks for your help