Managing the Tags of an Object

Tags are labels used to categorize and identify resources.

You can add tags to an object contained in a bucket, get information about the tags of an object and remove the tags of an object.

You can add up to 50 tags to an object.

These features are not available from Cockpit. This documentation only describes the procedures using AWS CLI.

Managing the Tags of an Object Using AWS CLI

Tagging an Object

Before you begin: Install and configure AWS CLI. For more information, see Installing and Configuring AWS CLI.

When using this command, the specified list of tags fully replaces all existing tags of the object.

To add one or more tags to an object, use the put-object-tagging command following this syntax:

Request sample
$ aws s3api put-object-tagging \
    --profile YOUR_PROFILE \
    --bucket BUCKET \
    --key OBJECT \
    --version-id qAfAAsAAuA00kclkg0A0AAuAAjaAtA. \
    --tagging '{"TagSet": [{"Key": "string", "Value": "string"}, {"Key": "string", "Value": "string"}]}' \
    --endpoint https://oos.eu-west-2.outscale.com

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • bucket: The name of the bucket in which the object is stored.

  • key: The name of the object in the bucket.

  • (optional) version-id: The ID of a previous or of the current version of the object.

  • tagging: The tags you want to add to the specified object.

    • TagSet: The list of tags. This element contains the following elements that you need to specify for each tag:

      • Key: The key of the tag.

      • (optional) Value: The value of the tag.

        • Keys must be unique and contain between 1 and 128 characters.

        • Values must contain between 0 and 256 characters.

        • Allowed characters are a-z, A-Z, 0-9, and +=,.@-_.

  • endpoint: The endpoint corresponding to the Region you want to send the request to. For more information, see Installing and Configuring AWS CLI.

If you have never enabled versioning in this bucket, this action does not return any element.

If you have ever enabled versioning in this bucket, even if you disabled it later, the put-object-tagging command returns the following element:

  • VersionId: The version ID of the object.

Result Sample
{
    "VersionId": "39383336323431353039353434383939393939395247303031202031382e32353637333831302e35"
}

The specified tags are added to the specified object.

Getting Information About the Tags of an Object

To get information about the tags of an object, use the get-object-tagging command following this syntax:

Request sample
$ aws s3api get-object-tagging \
    --profile YOUR_PROFILE \
    --bucket BUCKET \
    --key OBJECT \
    --version-id qAfAAsAAuA00kclkg0A0AAuAAjaAtA. \
    --endpoint https://oos.eu-west-2.outscale.com

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • bucket: The name of the bucket in which the object is stored.

  • key: The name of the object in the bucket.

  • (optional) version-id: The ID of a previous or of the current version of the object.

  • endpoint: The endpoint corresponding to the Region you want to send the request to. For more information, see Installing and Configuring AWS CLI.

The get-object-tagging command returns the following elements:

  • VersionId: The version ID of the object, if you have ever enabled versioning in this bucket, even if you disabled it later.

  • TagSet: The tags associated to the object.

    • Value: The value of the tag.

    • Key: The key of the tag.

Result sample
{
    "VersionId": "39383336323431353039353434383939393939395247303031202031382e32353637333831302e35",
    "TagSet": [
        {
            "Value": "VALUE",
            "Key": "KEY"
        }
    ]
}

Removing All Tags From an Object

To delete all the tags of an object, use the delete-object-tagging command following this syntax:

Request sample
$ aws s3api delete-object-tagging \
    --profile YOUR_PROFILE \
    --bucket BUCKET \
    --key OBJECT \
    --version-id qAfAAsAAuA00kclkg0A0AAuAAjaAtA. \
    --endpoint https://oos.eu-west-2.outscale.com

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • bucket: The name of the bucket in which the object is stored.

  • key: The name of the object in the bucket.

  • (optional) version-id: The ID of a previous or of the current version of the object.

  • endpoint: The endpoint corresponding to the Region you want to send the request to. For more information, see Installing and Configuring AWS CLI.

If you have never enabled versioning in this bucket, this action does not return any element.

If you have ever enabled versioning in this bucket, even if you disabled it later, the delete-object-tagging command returns the following element:

  • VersionId: The version ID of the object.

Result Sample
{
    "VersionId": "39383336323431353039353434383939393939395247303031202031382e32353637333831302e35"
}

The tags of the specified object are deleted.

Related Pages

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.