[ aws . secretsmanager ]
Attaches tags to a secret. Tags consist of a key name and a value. Tags are part of the secret’s metadata. They are not associated with specific versions of the secret. This operation appends tags to the existing list of tags.
The following restrictions apply to tags:
Maximum number of tags per secret: 50
Maximum key length: 127 Unicode characters in UTF-8
Maximum value length: 255 Unicode characters in UTF-8
Tag keys and values are case sensitive.
Do not use the aws:
prefix in your tag names or values because Amazon Web Services reserves it for Amazon Web Services use. You can’t edit or delete tag names or values with this prefix. Tags with this prefix do not count against your tags per secret limit.
If you use your tagging schema across multiple services and resources, other services might have restrictions on allowed characters. Generally allowed characters: letters, spaces, and numbers representable in UTF-8, plus the following special characters: + - = . _ : / @.
Warning
If you use tags as part of your security strategy, then adding or removing a tag can change permissions. If successfully completing this operation would result in you losing your permissions for this secret, then the operation is blocked and returns an Access Denied error.
Required permissions: secretsmanager:TagResource
. For more information, see IAM policy actions for Secrets Manager and Authentication and access control in Secrets Manager .
See also: AWS API Documentation
See ‘aws help’ for descriptions of global parameters.
tag-resource
--secret-id <value>
--tags <value>
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
--secret-id
(string)
The identifier for the secret to attach tags to. You can specify either the Amazon Resource Name (ARN) or the friendly name of the secret.
For an ARN, we recommend that you specify a complete ARN rather than a partial ARN. See Finding a secret from a partial ARN .
--tags
(list)
The tags to attach to the secret as a JSON text string argument. Each element in the list consists of a
Key
and aValue
.For storing multiple values, we recommend that you use a JSON text string argument and specify key/value pairs. For more information, see Specifying parameter values for the Amazon Web Services CLI in the Amazon Web Services CLI User Guide.
(structure)
A structure that contains information about a tag.
Key -> (string)
The key identifier, or name, of the tag.
Value -> (string)
The string value associated with the key of the tag.
Shorthand Syntax:
Key=string,Value=string ...
JSON Syntax:
[
{
"Key": "string",
"Value": "string"
}
...
]
--cli-input-json
| --cli-input-yaml
(string)
Reads arguments from the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton
. If other arguments are provided on the command line, those values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally. This may not be specified along with --cli-input-yaml
.
--generate-cli-skeleton
(string)
Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input
, prints a sample input JSON that can be used as an argument for --cli-input-json
. Similarly, if provided yaml-input
it will print a sample input YAML that can be used with --cli-input-yaml
. If provided with the value output
, it validates the command inputs and returns a sample output JSON for that command.
See ‘aws help’ for descriptions of global parameters.
Example 1: To add a tag to a secret
The following example shows how to attach a tag with shorthand syntax.
aws secretsmanager tag-resource \
--secret-id MyTestSecret \
--tags Key=FirstTag,Value=FirstValue
This command produces no output.
For more information, see Tag your secrets in the Secrets Manager User Guide.
Example 2: To add multiple tags to a secret
The following tag-resource
example attaches two key-value tags to a secret.
aws secretsmanager tag-resource \
--secret-id MyTestSecret \
--tags '[{"Key": "FirstTag", "Value": "FirstValue"}, {"Key": "SecondTag", "Value": "SecondValue"}]'
This command produces no output.
For more information, see Tag secrets in the Secrets Manager User Guide.
None