Reputation: 1097
I'm trying to tag an existing autoscaling group, using Python and Boto3.
I can definitely describe the ASGs by name:
import boto3
asg_client = boto3.client("autoscaling")
asg_name = "foo-bar20220502044025104700000001"
response = asg_client.describe_auto_scaling_groups(AutoScalingGroupNames=[asg_name])
The problem I have with the create_or_update_tags()
and delete_tags()
methods is that they don't seem to accept a list of ASG names. E.g. this doesn't work:
asg_client.create_or_update_tags(
AutoScalingGroupNames=[asg_name],
Tags=[my_tag]
)
To make it clear:
The tag-related methods appear to be different from all the other ASG client methods in that they do not accept an ASG name, or list of names, as a parameter.
Upvotes: 0
Views: 189
Reputation: 8087
You can do this, you just need provide a different input. The ResourceId
of these client methods can be supplied with an ASG name.
Here is the boto3 docs for the create_or_update_tags
call.
Here's an example:
asg_client.create_or_update_tags(
Tags=[
{
'ResourceId': asg_name,
'ResourceType': 'auto-scaling-group',
'Key': 'myTagKey',
'Value': 'myTagValue',
'PropagateAtLaunch': True
},
]
)
Upvotes: 1