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.86k stars 9.21k forks source link

[New Data Source]: Port mappings for custom routing Global Accelerator #39399

Open bogatuadrian opened 2 months ago

bogatuadrian commented 2 months ago

Description

After you create a custom routing Global Accelerator, it is a common practice to use the port mappings generated by the GA, for example as seen in this AWS blog post.

Right now, through Terraform, you can create a custom routing Global Accelerator, but there seems to be no way to get the port mappings information, leaving you with the alternative to run the following command with AWS CLI from Terraform (with something like terraform_data + local-exec; edit: or rather the external module) which is not ideal:

aws globalaccelerator list-custom-routing-port-mappings ...

It would be great to have access to this port mapping through a Terraform data source.

NOTE 1: The required API seems to be available in AWS Go SDK v2: globalaccelerator#Client.ListCustomRoutingPortMappings

NOTE 2: The best practice is to list the port mappings after the Global Accelerator is in a "Deployed" state, in case this poses problems to any potential code that waits for a specific GA state to be ready during an apply.

NOTE 3: There is also another potential data source similar to this one that is more specific: ListCustomRoutingPortMappingsByDestination; you could consider including this one as well.

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

Potential Terraform Configuration

data "aws_globalaccelerator_custom_routing_port_mappings" "this" {
  accelerator_arn = aws_globalaccelerator_custom_routing_accelerator.this.id
}

References

Would you like to implement a fix?

Yes

github-actions[bot] commented 2 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue