AutoScaling / Client / create_or_update_tags

create_or_update_tags#

AutoScaling.Client.create_or_update_tags(**kwargs)#

Creates or updates tags for the specified Auto Scaling group.

When you specify a tag with a key that already exists, the operation overwrites the previous tag definition, and you do not get an error message.

For more information, see Tag Auto Scaling groups and instances in the Amazon EC2 Auto Scaling User Guide.

See also: AWS API Documentation

Request Syntax

response = client.create_or_update_tags(
    Tags=[
        {
            'ResourceId': 'string',
            'ResourceType': 'string',
            'Key': 'string',
            'Value': 'string',
            'PropagateAtLaunch': True|False
        },
    ]
)
Parameters:

Tags (list) –

[REQUIRED]

One or more tags.

  • (dict) –

    Describes a tag for an Auto Scaling group.

    • ResourceId (string) –

      The name of the Auto Scaling group.

    • ResourceType (string) –

      The type of resource. The only supported value is auto-scaling-group.

    • Key (string) – [REQUIRED]

      The tag key.

    • Value (string) –

      The tag value.

    • PropagateAtLaunch (boolean) –

      Determines whether the tag is added to new instances as they are launched in the group.

Returns:

None

Exceptions

  • AutoScaling.Client.exceptions.LimitExceededFault

  • AutoScaling.Client.exceptions.AlreadyExistsFault

  • AutoScaling.Client.exceptions.ResourceContentionFault

  • AutoScaling.Client.exceptions.ResourceInUseFault

Examples

This example adds two tags to the specified Auto Scaling group.

response = client.create_or_update_tags(
    Tags=[
        {
            'Key': 'Role',
            'PropagateAtLaunch': True,
            'ResourceId': 'my-auto-scaling-group',
            'ResourceType': 'auto-scaling-group',
            'Value': 'WebServer',
        },
        {
            'Key': 'Dept',
            'PropagateAtLaunch': True,
            'ResourceId': 'my-auto-scaling-group',
            'ResourceType': 'auto-scaling-group',
            'Value': 'Research',
        },
    ],
)

print(response)

Expected Output:

{
    'ResponseMetadata': {
        '...': '...',
    },
}