-
Notifications
You must be signed in to change notification settings - Fork 121
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
Feature Request: AWS tag resources on creation #488
Comments
Hi @dlouzan, Since this is an AWS request, it's better served by the That being said, Packer supports tagging created AMIs, both through the Thanks |
The referenced issue hashicorp/packer#4746 was actually implemented, not just closed. See PR hashicorp/packer#5196. |
@lorengordon Thanks for the confirmation, using the latest plugin version I was indeed able to reconfigure our IAM user setup so that tags are only allowed on creation operations, now our packer IAM user cannot touch any other resources in the account/vpc 🎉 Simplified setup idea: {
Sid = "AllowCreateTagsOnlyOnNewEC2Resources"
Effect = "Allow"
Action = [
"ec2:CreateTags"
]
Resource = "*"
Condition = {
StringEquals = {
"ec2:CreateAction" = [
"CreateImage",
"CreateKeyPair",
"CreateSecurityGroup",
"CreateSnapshot",
"CreateVolume",
"RunInstances",
]
}
}
},
{
Sid = "AllowEC2CreateActionsWhenTaggingOwner"
Effect = "Allow"
Action = [
"ec2:CreateImage",
"ec2:CreateKeyPair",
"ec2:CreateSecurityGroup",
"ec2:CreateSnapshot",
"ec2:CreateVolume",
"ec2:RunInstances",
]
Resource = "*"
Condition = {
StringEquals = {
"aws:RequestTag/Owner" = var.ec2-resource-tag-owner # RequestTag: tag must be provided as parameter
}
"ForAnyValue:StringEquals" = { # ForAnyValue: allow any other potential tags
"aws:TagKeys" : [ # TagKeys: ensure case-sensitivity of request tag
"Owner"
]
}
}
},
{
Sid = "AllowEC2UntaggedActions"
Effect = "Allow"
Action = [
"ec2:CopyImage",
"ec2:DescribeImageAttribute",
...
]
Resource = "*"
},
{
Sid = "AllowEC2AllOtherActionsOnlyWhenOwnerTag"
Effect = "Allow"
Action = [
"ec2:AttachVolume",
"ec2:AuthorizeSecurityGroupEgress",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:DeleteKeyPair",
...
]
Resource = "*"
Condition = {
StringEquals = {
"aws:ResourceTag/Owner" = var.ec2-resource-tag-owner # ResourceTag: tag must be already attached to the resources
}
}
} Just some hints for future readers:
Thanks again for the project. Happy coding! |
Community Note
Please search the existing issues for relevant feature requests, and use the
reaction feature
(https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/)
to add upvotes to pre-existing requests.
Description
This is a general re-request of feature hashicorp/packer#4746. Basically support being able to provide tags to AWS resources on creation. Since the previous issue is blocked, it can't be commented on, nor upvoted.
This functionality would allow a much tighter set of IAM permissions.
Ansible 10 just recently added this capability: https://github.com/ansible-community/ansible-build-data/blob/main/10/CHANGELOG-v10.md#amazonaws. Having it on packer too would be really helpful.
Thanks!
The text was updated successfully, but these errors were encountered: