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

[data source] terraform apply outlog error when output nothing #778

Open
xyz5s opened this issue Aug 21, 2019 · 0 comments
Open

[data source] terraform apply outlog error when output nothing #778

xyz5s opened this issue Aug 21, 2019 · 0 comments

Comments

@xyz5s
Copy link

xyz5s commented Aug 21, 2019

Terraform v0.11.14

  • provider.alicloud v1.54.0

1 .t.tf
// no vpc
data "alicloud_vpcs" "vpcs_ds" {
cidr_block = "172.16.0.0/10"
status = "Available"
name_regex = "^TF"
}

output "first_vpc_id" {
value = "${data.alicloud_vpcs.vpcs_ds.vpcs.0.id}"
}

shell>terraform apply
error: Error applying plan:

1 error occurred:
* output.first_vpc_id: Resource 'data.alicloud_vpcs.vpcs_ds' does not have attribute 'vpcs.0.id' for variable 'data.alicloud_vpcs.vpcs_ds.vpcs.0.id'

2.t.tf
// no vpc
data "alicloud_vpcs" "vpcs_ds" {
cidr_block = "172.16.0.0/10"
status = "Available"
name_regex = "^TF"
}

output "first_vpc_id" {
value = "${data.alicloud_vpcs.vpcs_ds.vpcs}"
#value = "${data.alicloud_vpcs.vpcs_ds.vpcs.0.id}"
}

shell>terraform apply
Outputs:
first_vpc_id = []

3.t.tf:
// existing vpc
data "alicloud_vpcs" "vpcs_ds" {
cidr_block = "172.16.0.0/12"
status = "Available"
name_regex = "^TF"
}

output "first_vpc_id" {
#value = "${data.alicloud_vpcs.vpcs_ds.vpcs}"
value = "${data.alicloud_vpcs.vpcs_ds.vpcs.0.id}"
}

shell>terraform apply
Outputs:
first_vpc_id = vpc-2ze2eeyclsybrka16d6jr

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