Skip to content

fix: use toset(keys(...)) in vpc-endpoints for_each to avoid deprecated .region schema walk - #170

Open
Arnoldas Brazys (arnoldasbrazys) wants to merge 1 commit into
cloudposse:mainfrom
arnoldasbrazys:fix/vpc-endpoints-deprecated-region-attribute
Open

fix: use toset(keys(...)) in vpc-endpoints for_each to avoid deprecated .region schema walk#170
Arnoldas Brazys (arnoldasbrazys) wants to merge 1 commit into
cloudposse:mainfrom
arnoldasbrazys:fix/vpc-endpoints-deprecated-region-attribute

Conversation

@arnoldasbrazys

Copy link
Copy Markdown

what

  • Replace for_each = ... ? data.aws_vpc_endpoint_service.X : {} with for_each = ... ? toset(keys(data.aws_vpc_endpoint_service.X)) : toset([]) in all four for_each expressions in modules/vpc-endpoints/main.tf

why

  • Passing the full data source map to for_each causes Terraform/OpenTofu to walk the entire aws_vpc_endpoint_service schema, which surfaces a deprecation warning for the region attribute (replaced by service_region in AWS provider v6.x):
    Warning: Value derived from a deprecated source
      on modules/vpc-endpoints/main.tf line 62, in module "gateway_endpoint_label":
      62:   for_each = local.enabled ? data.aws_vpc_endpoint_service.gateway_endpoint_service : {}
    This value's attribute ["dynamodb"].region is derived from
    data.aws_vpc_endpoint_service.gateway_endpoint_service.region, which is deprecated.
    
  • None of the four affected blocks use each.value — label modules only reference each.key, and endpoint resources access data source attributes directly via data.aws_vpc_endpoint_service.X[each.key].attr. Using toset(keys(...)) keeps the same string keys, so state is unaffected and no migration is needed

references

@gberenice

Copy link
Copy Markdown
Contributor

/terratest

@gberenice

Copy link
Copy Markdown
Contributor

Arnoldas Brazys (@arnoldasbrazys) can I ask you to remove the deprecated example code? It's failing and blocking the release:

│ Error: Unsupported argument

│ on main.tf line 7, in module "vpc":
│ 7: cidr_block = "172.16.0.0/16"

│ An argument named "cidr_block" is not expected here.


│ Error: Unsupported argument

│ on main.tf line 31, in module "vpc_disabled":
│ 31: cidr_block = "172.16.0.0/16"

│ An argument named "cidr_block" is not expected here.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage Needs triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warning: Value derived from deprecated aws_vpc_endpoint_service .region attribute in vpc-endpoints submodule

2 participants