Closed tightly-clutched closed 2 years ago
@tightly-clutched the error is due to how the advertised_ip_ranges
is constructed. The module expects this to be a list. However, the example creates this as a single map. You can convert this into a list as follows:
- advertised_ip_ranges = {
+ advertised_ip_ranges = [{
description = "aws subnets"
range = "10.0.0.0/16"
- }
+ }]
description = "aws subnets"
range = "10.0.0.0/16"
This should resolve the error.
@kaariger That worked perfectly! Thanks for your help. I'll be using that construction in future, I'm sure.
TL;DR
When I try to insert advertised_ip_ranges in the module, terraform plan fails with
Error: Unsupported attribute
I need some guidance on using this attribute correctly.
Expected behavior
I expect the advertised_ip_ranges to be added to the cloud_router definition
Observed behavior
Output of
terraform plan
Error: Unsupported attribute
on .terraform/modules/cloud_router-ue4/main.tf line 37, in resource "google_compute_router" "router": 37: range = advertised_ip_ranges.value.range |---------------- | advertised_ip_ranges.value is "aws subnets"
This value does not have any attributes.
Error: Unsupported attribute
on .terraform/modules/cloud_router-ue4/main.tf line 37, in resource "google_compute_router" "router": 37: range = advertised_ip_ranges.value.range |---------------- | advertised_ip_ranges.value is "10.0.0.0/16"
This value does not have any attributes.
Error: Invalid function argument
on .terraform/modules/cloud_router-ue4/main.tf line 38, in resource "google_compute_router" "router": 38: description = lookup(advertised_ip_ranges.value, "description", null) |---------------- | advertised_ip_ranges.value is "aws subnets"
Invalid value for "inputMap" parameter: lookup() requires a map as the first argument.
Error: Invalid function argument
on .terraform/modules/cloud_router-ue4/main.tf line 38, in resource "google_compute_router" "router": 38: description = lookup(advertised_ip_ranges.value, "description", null) |---------------- | advertised_ip_ranges.value is "10.0.0.0/16"
Invalid value for "inputMap" parameter: lookup() requires a map as the first argument.
Terraform Configuration
Terraform Version
Additional information
No response