Many organizationâs workflows requires services to be tagged. Either itâs a requirement for the development or it is to identify all non-essential services and batch remove them.
amplify delete canât address this easily because it requires a developer instead of an âadminâ to manually navigate to every environment and run amplify delete. Sometimes the amplify project is in an abandoned branch thatâs difficult to locate.
By introducing AWS tags to services, we can easily allow backend administrators to locate amplify-generated services and their projects.
amplify init
By default, Amplify CLI places the following tags in a global amplify/tags.json file.
|Key |Value |
|--- |--- |
|user:Stack |{project-env} |
|user:Application |{project-name} |
|user:AmplifyCLIVersion |{cli-version} |
Customers can override the tags in tags.json file in the amplify/ folder by editing the file itself. The file itself must be in the JSON format with the following contents:
[{
Key: âMY_TAG_KEYâ,
Value: âMY_TAG_VALUE"
}]
When amplify push runs, itâll take the configuration from tags.json and attach it to every service in the CFN.
Customers can use specific variables within their tag values to let Amplify CLI know if some information should be auto-filled.
Amplify CLI will provide 3 default variables:
Example: If the customer's project name is myamplifyproject, environment is dev and their tags.json is the following:
[{
"Key": "myawesomekey",
"Value": "myvalue-{project-name}-{project-env}"
}]
then the tags get transformed into
[{
"Key": "myawesomekey",
"Value": "myvalue-myamplifyproject-dev"
}]
âĄď¸ Which tags do you think should be there by default?
âĄď¸ What do you think about this workflow using a "amplify/tags.json" file?
Issue: #365
Thanks for putting together this RFC @ammarkarachi!
I think the 3 defaults are fine and cover the basics of what users would expect.
I agree that this flow is easier than the CLI approached discussed in #365, where something like amplify add tags would be more cumbersome than just editing a tags file.
Regarding the json file itself, I just wanted to bring up some discussion points:
key and value should be casing insensitivepush?Overall this is a solid proposal and I'm super happy it's getting some more momentum behind it!
the key and value should be casing insensitive
I am not entirely sure if this makes sense AWS tags are case sensitive by default
it should guard against duplicate tags
Good point! I agree
I'm assuming this is ok to keep in version control by default?
@mtliendo Can you elaborate?
When does tag validation take place; on every resource push?
Yes, tag validation does take place on Amplify push.
I don't have much experience in this area, but is there a built-in way to scaffold tags when in headless mode?
This is something we are looking into right now.
Oh nice, I guess I never realized that they were case sensitive by default đ
Regarding version control, I was just specifically wondering if the tags.json file would not be added to the .gitignore file by default.
I would like keep the tags.json in version control. This way the tags would remain be uniform across all local repositories and subsequent pushes
Sounds good. I appreciate your thoughts on all of this and your time on these questions. Looking forward to seeing this move along!
[{ key: âMY_TAG_KEYâ, value: âMY_TAG_VALUE" }]Edited to
[{ Key: âMY_TAG_KEYâ, Value: âMY_TAG_VALUE" }]
Another thing to consider:
amplify env add
Then the current environment's tags.json file gets duplicated into the new environment. Just like with all other resources. No different behavior here.
Will updating the tags file with like a current date or something cause it to re-push all items? Just curious if there is a quick way to do tags that doesn't require a full push?
Will updating the tags file with like a current date or something cause it to re-push all items? Just curious if there is a quick way to do tags that doesn't require a full push?
If the tags is the only thing that has changed then yes it would not push all your resources but update the tags in this case
+1
Hi all - "Tag support" is now available! https://docs.amplify.aws/cli/usage/tags
Most helpful comment
Sounds good. I appreciate your thoughts on all of this and your time on these questions. Looking forward to seeing this move along!