Skip to content
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

[Enhancement]: Allow ARN as identifier for aws_ec2_tag resource #39445

Open
C-Duv opened this issue Sep 23, 2024 · 1 comment
Open

[Enhancement]: Allow ARN as identifier for aws_ec2_tag resource #39445

C-Duv opened this issue Sep 23, 2024 · 1 comment
Labels
enhancement Requests to existing resources that expand the functionality or scope. needs-triage Waiting for first response or review from a maintainer. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@C-Duv
Copy link

C-Duv commented Sep 23, 2024

Description

TL;DR: I have 2 AWS accounts, one creating resources and tagging them then sharing them to the other account using AWS RAM and generating a file containing maps of tags per resource's ARN. But aws_ec2_tag do not accept resource ARN (it needs resource ID). Please add support for ARN.

I would like to suggest improvement on how aws_ec2_tag is given instruction on which resource to tag. I think it should accept ARN identifiers.

My use-case is:

Network team in charge of the AWS infrastructure creates some resources in their "network" AWS account. They also and tag and share them with a second "application" account (for the Application team) using AWS RAM/Resource Access Manager.

Because tags are not shared from one account to another, Application team need to (re-)tag those same resources.

So network team also generates a (YAML) file using the aws_resourcegroupstaggingapi_resources data source where each key is the ARN of a resource and the value is a map of the tags applied to said resource:

Example of file:

"arn:aws:ec2:eu-west-1:690910532991:subnet/subnet-000d48157436895af":
  "Acme:Creator:Tool": "Terraform"
  "Acme:For:Client": "Acme"
  "Acme:For:Environment": "Production"
  "Acme:For:Module": "Infrastructure"
  "Acme:For:Project": "Website"
  "Name": "sn-web-zone-a-website_prod"
"arn:aws:ec2:eu-west-3:690910532991:vpc-peering-connection/pcx-63976331eac92878c":
  "Acme:Creator:Tool": "Terraform"
  "Acme:For:Client": "Acme"
  "Acme:For:Environment": "Production"
  "Acme:For:Module": "Infrastructure"
  "Acme:For:Project": "Website"
  "Name": "vpc_peering-website_x_monitoring"

The best (only) way to re-tag thoses ram-obtained resources is the aws_ec2_tag, but it only accepts IDs, not ARN.

On the other side, the aws_resourcegroupstaggingapi data source only exports ARNs, not IDs.

If I try to pass an ARN to aws_ec2_tag as resource_id argument, it fails with:

aws_ec2_tag.test_tag: Creating...
╷
│ Error: creating ec2 resource (arn:aws:ec2:eu-west-3:690910532991:vpc-peering-connection/pcx-63976331eac92878c) tag (Acme:Creator:Tool): tagging resource (arn:aws:ec2:eu-west-3:690910532991:vpc-peering-connection/pcx-63976331eac92878c): tagging resource (arn:aws:ec2:eu-west-3:690910532991:vpc-peering-connection/pcx-63976331eac92878c): operation error EC2: CreateTags, https response error StatusCode: 400, RequestID: 0532c625-9f36-535d-929f-26cb2feb797f, api error InvalidID: The ID 'arn:aws:ec2:eu-west-3:690910532991:vpc-peering-connection/pcx-63976331eac92878c' is not valid
│ 
│   with aws_ec2_tag.test_tag,
│   on resource-tagger.tf line 24, in resource "aws_ec2_tag" "test_tag":
│   24: resource "aws_ec2_tag" "test_tag" {

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

  • aws_ec2_tag

Potential Terraform Configuration

resource "aws_ec2_tag" "test_tag" {
  resource_arn = "arn:aws:ec2:eu-west-3:690910532991:vpc-peering-connection/pcx-63976331eac92878c"
  key = "Acme:Creator:Tool"
  value = "Terraform"
}

References

No response

Would you like to implement a fix?

None

@C-Duv C-Duv added the enhancement Requests to existing resources that expand the functionality or scope. label Sep 23, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added service/ec2 Issues and PRs that pertain to the ec2 service. needs-triage Waiting for first response or review from a maintainer. labels Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Requests to existing resources that expand the functionality or scope. needs-triage Waiting for first response or review from a maintainer. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

1 participant