Reputation: 183
Hello,
I'm creating a lambda function on AWS to automatically create tags on EC2 resources. The solution works fine:
ec2.create_tags(Resources=instance_ids,Tags=[{'Key':'environnement','Value':'dev'}])
My question:
Can i create a tag with limited values? like a drop down list ?
So users can only choose from this list ?
ec2.create_tags(Resources=instance_ids,Tags=[{'Key':'environnement','Value':['dev','prod','test']}])
Thanks in advance !
Upvotes: 0
Views: 3012
Reputation: 2113
You can attach an IAM policy to the cloudwatch service to create tags only if the expected key/value pair matches. Sample IAM policy.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"ec2:DeleteTags",
"ec2:DescribeTags",
"ec2:CreateTags"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:RequestTag/Env": [
"Prod",
"Stage",
"Dev"
]
}
}
}
]
}
This will only allow if Env tag is being created with values Prod/Stage/Dev. You can add any number of key/value pair to the policy based on your need.
Upvotes: 1
Reputation: 2365
Upvotes: 0