Scott Thompson
Scott Thompson

Reputation: 198

Set EC2 Instance Tag Name for Compute Environment

I have a batch job which is trigged with boto3, I run about 10 workers on an ec2 compute enviroment and they used to inherit the jobname from batch but now all my instances have no name tag so it's difficult to figure out which is which.

How can I pass on a name tag to the ec2 instances for my batch job via boto3?

    batch = boto3.client('batch', my_arguments)
    batch_detils = batch.submit_job(
        jobName = 'worker_{}'.format(i),
        jobQueue = 'my_queue',
        jobDefinition = 'my_job_definition',
        containerOverrides = {'command': ['sleep 100']},
    )

I should specify the ultimate goal is to get each worker with a unique name, not to get the all the same name as the compute environment.

Upvotes: 3

Views: 1274

Answers (2)

John Rotenstein
John Rotenstein

Reputation: 269236

The Compute Environment Parameters - AWS Batch documentation page talks of a tags parameter:

Key-value pair tags to be applied to instances that are launched in the compute environment. For example, you can specify "Name": "AWS Batch Instance - C4OnDemand" as a tag so that each instance in your compute environment has that name. This is helpful for recognizing your AWS Batch instances in the Amazon EC2 console.

Upvotes: 1

Narain
Narain

Reputation: 922

Have you tried this

Boto3 create_tags

Upvotes: 0

Related Questions