Add a tag to a repository - AWS CodeCommit

Add a tag to a repository

Adding tags to a repository can help you identify and organize your AWS resources and manage access to them. First, you add one or more tags (key-value pairs) to a repository. Keep in mind that there are limits on the number of tags you can have on a repository. There are restrictions on the characters you can use in the key and value fields. For more information, see Limits. After you have tags, you can create IAM policies to manage access to the repository based on these tags. You can use the the CodeCommit console or the AWS CLI to add tags to a repository.

Important

Adding tags to a repository can impact access to that repository. Before you add a tag to a repository, make sure to review any IAM policies that might use tags to control access to resources such as repositories. For examples of tag-based access policies, see Example 5: Deny or allow actions on repositories with tags.

For more information about adding tags to a repository when you create it, see Create a repository (console).

Add a tag to a repository (console)

You can use the CodeCommit console to add one or more tags to a CodeCommit repository.

  1. Open the CodeCommit console at https://console.aws.amazon.com/codesuite/codecommit/home.

  2. In Repositories, choose the name of the repository where you want to add tags.

  3. In the navigation pane, choose Settings. Choose Repository tags.

  4. If no tags have been added to the repository, choose Add tag. Otherwise, choose Edit, and then choose Add tag.

  5. In Key, enter a name for the tag. You can add an optional value for the tag in Value.

    
                        Adding a tag to a repository
  6. (Optional) To add another tag, choose Add tag again.

  7. When you have finished adding tags, choose Submit.

Add a tag to a repository (AWS CLI)

Follow these steps to use the AWS CLI to add a tag to a CodeCommit repository. To add a tag to a repository when you create it, see Create a repository (AWS CLI).

In these steps, we assume that you have already installed a recent version of the AWS CLI or updated to the current version. For more information, see Installing the AWS Command Line Interface.

At the terminal or command line, run the tag-resource command, specifying the Amazon Resource Name (ARN) of the repository where you want to add tags and the key and value of the tag you want to add. You can add more than one tag to a repository. For example, to tag a repository named MyDemoRepo with two tags, a tag key named Status with the tag value of Secret, and a tag key named Team with the tag value of Saanvi:

aws codecommit tag-resource --resource-arn arn:aws:codecommit:us-west-2:111111111111:MyDemoRepo --tags Status=Secret,Team=Saanvi

If successful, this command returns nothing.