hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.85k stars 9.2k forks source link

[Enhancement]: Need a feature to work with vpc_endpoint_id and destination_prefix_list_id to create AWS routes #39916

Open nick-terra opened 3 weeks ago

nick-terra commented 3 weeks ago

Description

I am trying to create AWS routes using aws_route block. My use-case is to create route(s) for multiple cidr blocks which will serve cross-AZ network establishment. My approach is to create a prefix list. Then pass the prefix list to the routes block under destination_prefix_list_id argument. However, I get stuck due to conflict between destination_prefix_list_id and vpc_endpoint_id arguments. I am aware of the underlying AWS API error for my use-case since my VPCE is of Gateway Load Balancer type. I need to have a work around for my use-case to avoid long list of route blocks in my code and have an iterative approach where I run my loop across a list of route table IDs and attach the prefix list IDs. I am using aws_vpc_endpoint_route_table_association referring to a previous blog (https://github.com/hashicorp/terraform-provider-aws/issues/18607). But the VPCE type is another blocker for me in that case.

AWS Provider: 5.50.0 Terraform Version: 1.8.3

Affected Resource(s) and/or Data Source(s)

aws_route aws_vpc_endpoint_route_table_association aws_ec2_managed_prefix_list

Potential Terraform Configuration

resource "aws_route" "core_routes" {
  for_each = {
    for loop applied with necessary filters
  }
  route_table_id             = aws_route_table.private_route_table[loop keys/values].id
  destination_prefix_list_id = var.prefix_list_id
}

resource "aws_vpc_endpoint_route_table_association" "core_routes_to_vpce" {
  depends_on = [aws_route.core_routes]
  for_each = {
    for loop applied with necessary filters
  }
  route_table_id  = aws_route_table.private_route_table[loop keys/values].id
  vpc_endpoint_id = local.swapped_fw_endpoints[loop keys/values].id
}

References

https://github.com/hashicorp/terraform-provider-aws/issues/18607 https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_endpoint_route_table_association https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route

Would you like to implement a fix?

Yes

github-actions[bot] commented 3 weeks ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

nick-terra commented 3 weeks ago

@justinretzolk Is there any fix or a workaround or an enhancement I can expect to work with for this use-case?