-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Tags for AWS resources created implicitly by other resources #9061
Comments
Look also at shared Route 53 Resolver Forwarding Rules which can have tags. |
Another use case is for tagging EC2 resources implicitly created by other resources such as the transit gateway attachment created by associating a Direct Connect gateway. |
Another similar thing for Route 53 Hosted Zones created via Servicediscovery: #7840 |
This feature is very much appreciated! Looks like it is not supported by AWS yet though, so we should probably wait for them. Really annoying that the tags that you set on an object - for example the TGW - are not automatically shared; this prevents you pretty much from doing more robust setups. |
Another use case is for the EC2 resources created as part of an EKS Managed Node Group - #10915. |
Another one - tagging DynamoDB resources: #6859. |
Another one - tagging ECS cluster created for Batch: #11951. |
Another one - Tagging EC2 Transit Gateway Route Tables created in cross account. They will be unnamed in the account holding the Transit Gateway itself.. |
Another use case - when resource aws_vpn_connection creates connection - the attachment on the transit gateway is not/cannot be tagged. Details here: #12535 |
And another bunch, the COIP and Local Gateway resources created when setting up an AWS Outpost - #12302. |
Another use case: |
Would be lovely to have a generic |
Another use case: |
A new # Example configuration in Terraform 0.12 and later syntax
resource "aws_ec2_transit_gateway" "example" {}
resource "aws_customer_gateway" "example" {
bgp_asn = 65000
ip_address = "172.0.0.1"
type = "ipsec.1"
}
resource "aws_vpn_connection" "example" {
customer_gateway_id = aws_customer_gateway.example.id
transit_gateway_id = aws_ec2_transit_gateway.example.id
type = aws_customer_gateway.example.type
}
resource "aws_ec2_tag" "example" {
resource_id = aws_vpn_connection.example.transit_gateway_attachment_id
key = "Name"
value = "Hello World"
} As with any Terraform 0.12.6 or later configuration, this resource can be combined with Thanks to @joestump and others who made the implementation possible. 👍 While the above covers EC2 resources, we would highly suggest creating individual GitHub feature requests for other AWS services since these types of general issues lack a definition of done. Here's what I see above so far:
I will however keep this open for a short while longer since we will likely want to implement a few general enhancements to make creating these service tag resources easier, which will be the definition of done for this particular issue:
|
…list/get, use in aws_ec2_tag implementation Reference: #9061 The GetTag generator simplifies the creation of the new individual service tag resources into a consistent implementation. This consistent implementation can be used to automatically generate the service tag resources themselves in the future. Output from acceptance testing: ``` --- PASS: TestAccAWSEc2Tag_basic (485.52s) --- PASS: TestAccAWSEc2Tag_disappears (529.67s) --- PASS: TestAccAWSEc2Tag_Value (588.49s) ```
…list/get, use in aws_ec2_tag implementation (#13745) * internal/keyvaluetags: Create {SERVICE}GetTag generator, support EC2 list/get, use in aws_ec2_tag implementation Reference: #9061 The GetTag generator simplifies the creation of the new individual service tag resources into a consistent implementation. This consistent implementation can be used to automatically generate the service tag resources themselves in the future. Output from acceptance testing: ``` --- PASS: TestAccAWSEc2Tag_basic (485.52s) --- PASS: TestAccAWSEc2Tag_disappears (529.67s) --- PASS: TestAccAWSEc2Tag_Value (588.49s) ``` * tests/resource/aws_ec2_tag: Add missing error check
… switch aws_ec2_tag implementation Reference: #9061 Output from acceptance testing: ``` --- PASS: TestAccAWSEc2Tag_disappears (429.66s) --- PASS: TestAccAWSEc2Tag_Value (530.85s) --- PASS: TestAccAWSEc2Tag_basic (537.38s) ```
… switch aws_ec2_tag implementation Reference: #9061 Output from acceptance testing: ``` --- PASS: TestAccAWSEc2Tag_disappears (429.66s) --- PASS: TestAccAWSEc2Tag_Value (530.85s) --- PASS: TestAccAWSEc2Tag_basic (537.38s) ```
… switch aws_ec2_tag implementation Reference: #9061 Output from acceptance testing: ``` --- PASS: TestAccAWSEc2Tag_disappears (429.66s) --- PASS: TestAccAWSEc2Tag_Value (530.85s) --- PASS: TestAccAWSEc2Tag_basic (537.38s) ```
This functionality has been released in v3.56.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
Same for |
Tested version was |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Community Note
Description
When AWS EC2/VPC (and maybe other service) resources are shared with another account via RAM the tags from the creating account are not copied to the accepting account and so for example a shared subnet has no Name in the accepting account's AWS Console.
We decouple much of our Terraform code by creating for example all subnet resources in one module (with a predefined set of tags) and then using a data source in another module (specifying those predefined tags) to find a specific subnet ID (for an ASG or whatever).
This won't work when a subnet is shared into an account as those predefined tags are missing.
Doing a
terraform import
for those shared resources won't really work as the accepting account doesn't own the resource's lifecycle and can only change tags on the resource.My thinking is to have a Terraform resource in the accepting account that can manage just the tags on these shared VPC resources.
New or Affected Resource(s)
References
#8457 seems to be a solution to a similar problem.
Related:
The text was updated successfully, but these errors were encountered: