0
votes

I am working on aws batch to pass user data during the initialization of the container instance. Is there a way to do it in aws batch ?

Followed this link Create AWS Batch Managed Compute Environment passing UserData to Container Instances

but not sure how they ended up solving this problem.

2

2 Answers

1
votes

You can create an EC2 Launch Template and pass the UserData script to it. Then use this launch template while creating your AWS Batch Compute Environment.

Refer to this link to understand Launch Template support while creating AWS Batch Compute Environment.

Cheers,

Kunal

0
votes

Depending on your user data, I see multiple options to expose data to AWS Batch jobs / containers:

  • for key/value pairs, expose the data via environment variables - use the container_overrides parameter for aws batch ( see 1 or use the aws cli :

aws batch submit-job --container-overrides vcpus=integer,memory=integer,command=[string,string],environment=[{name=EnvVariableName,value=EnvVariableValue},{name=string,value=string}]

Or just write your variables to a json file and use --cli-input-json my_file.json

  • If you have large data, store it in S3, hand over the S3 address during startup and then pull the data during startup ; the aws batch job needs to have permission to fetch data from S3

  • for secrets, use the AWS Secret manager to store them, allow your AWS Batch jobs to use secretsmanager:GetSecretValue and pull the secret from AWS