简体   繁体   中英

How to add tags to all ECS task definition in one go

I would like to tag all 9000+ task definition in one go, please help me with best way to do. i tried with cmd aws ecs tag-resource --resource-arn but it is allowing to take one arn at a time.

You can only do this using a program. Use the AWS SDK, list all ARNs, loop through them all and call the tag resource api on each of them. This is how you tag a bunch of tables in Python:

    session = boto3.Session(profile_name="my-region")
    client = session.client('dynamodb')

    # Get all DDB tables
    tables = client.list_tables()
    
    # Loop through tables
    for table in tables['TableNames']:
        print(f'Tagging table: {table}')
        client.tag_resource(ResourceArn=f'arn:aws:dynamodb:us-east-1:xxx:table/{table}',Tags=[{'Key':'my_tag','Value':'my_tag_value'}])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM