amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

Tag Support

Open officeguy opened this issue 8 years ago • 18 comments

please add tag support to AWS Amplify cli, so that all resources can be tagged automatically at creation time with the tags you specify via a --tags argument

officeguy avatar Oct 28 '18 01:10 officeguy

If anyone has insight into how one would approach raising a PR against this, perhaps it would help drive development? For context, my company allows us devs to have a sandbox AWS account so long as the resources are tagged, thus having to figure out what resources were made or update a cloudformation file after the fact isn't the best DX.

mtliendo avatar Mar 19 '19 20:03 mtliendo

@mtliendo We ran into the same issues. We use aws-nuke to keep the costs low on testing.

Please make this possible!

tzdesign avatar Apr 23 '19 09:04 tzdesign

@tzdesign Oh, I've never used that package before. It's like rimraf for aws hehe. My solution has been to keep a notepad of the repos I create that use amplify and when I feel they go idle run amplify delete.

In practice are there advantages that aws-nuke provides over that command?

mtliendo avatar Apr 23 '19 14:04 mtliendo

@mtliendo We are using a lot of Cloudformation and serveral team members are deploying with amplify, serverless, etc. It's impossible to keep track on each one of these things without tags.

It has no advantages except that it implements a workflow for testing and destruct stuff which is not in production.

At the moment it's okay to nuke all inside the sandbox sub account, but in the end when it comes to cost consumption you will struggle without tags as well.

It's a feature of aws cloud formation, why not supporting it here.

tzdesign avatar Apr 23 '19 15:04 tzdesign

Please, I do need this.

BeneyKim avatar Apr 26 '19 01:04 BeneyKim

@kaustavghosh06 it would be awesome if this was added, right now we have environments that haven't been committed to amplify/team-provider.json (e.g. abandoned in a branch) that we'd like to periodically clean up.

jbabe avatar Apr 26 '19 16:04 jbabe

We also could use this. Currently we have to go to the resources after they are created and manually add them or we add the tags to the cloudformation. It is a bit of an annoyance :)

johnkoehn avatar May 07 '19 15:05 johnkoehn

I can work on drafting an RFC. From what I can tell from our use cases, the process would be the following:

  1. When running amplify init prompt the user to enter their set of tags that would be used to all(?) created resources.

  2. If the resource allows tagging (not all resources do), then update the necessary cloudformation templates to include the desired tags. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html

Possibly 3: Allow the user to edit/add tags when running amplify configure.

It's been a while since this issue was first opened and the fact that it hasn't gone stale means there is continued interest. Looking forward to all of your feedback to make sure we can get a more directed PR up soon.

mtliendo avatar May 08 '19 08:05 mtliendo

It would be great if we could apply tags to the root stack, and have them propagated to the nested stacks as well. That would allow CloudFormation to do it's thing and handle tagging all taggable resources automatically.

hotgazpacho avatar Sep 20 '19 23:09 hotgazpacho

Any update on when this might be possible? I am just starting to use Amplify and my boss asked that all resources created by Amplify be tagged so he can manage the cost better.

Is there a workaround until Amplify does support this directly? Is there a way to sift through the files in the amplify folder of a project to collect all of the ARNs for the resources created? Could the aws cli be used to assign tags then?

BennettSmith avatar Mar 27 '20 04:03 BennettSmith

Need this support in our org as well

bakersemail avatar Mar 30 '20 01:03 bakersemail

@mtliendo is there enough detail on this now that we could start working on the PR?

codercatdev avatar Apr 14 '20 22:04 codercatdev

@hotgazpacho im not sure I understand. the docs say that tagging at the root level will automatically propagate.

All stack-level tags, including automatically created tags, are propagated to resources that AWS CloudFormation supports. Currently, tags are not propagated to Amazon EBS volumes that are created from block device mappings

Are you saying that wouldn’t include nested stacks?

mtliendo avatar Apr 26 '20 09:04 mtliendo

Hi everyone! We've put this into an RFC! I'd love to hear all of your feedback on this. https://github.com/aws-amplify/amplify-cli/issues/4607

renebrandel avatar Jun 18 '20 21:06 renebrandel

Hi all - Tag support is now available! https://docs.amplify.aws/cli/usage/tags

renebrandel avatar Aug 31 '20 23:08 renebrandel

Awesome work! So glad to have this and it's been already used in some of our greenfield projects!

mtliendo avatar Sep 01 '20 03:09 mtliendo

Tags with amplify init command

Please note that amplify init does not take the contents in amplify/backend/tags.json file if you do not have amplify/.config/project-config.json inplaced.

In other words, you have to create at least three files in the following structure (the template can be found in https://github.com/aws-amplify/amplify-cli/tree/master/packages/amplify-cli/templates/amplify-skeleton.) if you would like have all the required tags attached to resources created when running amplify init for a whole new project: -- Project root ---- amplify ------ .config -------- project-config.json ------ backend -------- backend-config.json -------- tags.json

  • If project does not have file project-config.json, amplify-cli will create a new empty 'amplify' folder and move the current folder whose name is 'amplify' to 'amplify-backup'. In this case, all the tags you put into tags.json will be ignored as it is put into amplify-backup folder
  • If project does not have backend-config.json, the init process will be complete but pops up with an error saying backend-config.json cannot be found.
  • If tags.json is not present, then no tags will be added to any resource created by amplify with cloudformation.

I spent quite a time to figure out this. My company has strict a rule that all the AWS resources must be created with required tags. However, amplify init creates authrole and unauthrole with the default tags 'user:stack' and 'user:application' which is forbidden by the rule. I am new to amplify so it takes me ages to find above solution.

May this help with anyone had similar situations.

M-Arthur avatar Apr 30 '21 04:04 M-Arthur

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

github-actions[bot] avatar May 30 '21 05:05 github-actions[bot]