I have an AWS Batch compute environment with a Job Definition.
I created all this using Cloud Formation.
Now I want to add an EFS Volume (Name: EFS-000, File system ID: fs-9999999) and a MountPoint to this Job Definition.
I read
- https://docs.aws.amazon.com/AmazonECS/latest/developerguide/tutorial-efs-volumes.html
- https://aws.amazon.com/es/premiumsupport/knowledge-center/batch-mount-efs
In the first link we have an example of a Task Definition ( AWS ECS instead AWS Batch concept)
{
"containerDefinitions": [
{
"memory": 128,
"portMappings": [
{
"hostPort": 80,
"containerPort": 80,
"protocol": "tcp"
}
],
"essential": true,
"mountPoints": [
{
"containerPath": "/usr/share/nginx/html",
"sourceVolume": "efs-html"
}
],
"name": "nginx",
"image": "nginx"
}
],
"volumes": [
{
"name": "efs-html",
"efsVolumeConfiguration": {
"fileSystemId": "fs-1324abcd",
"transitEncryption": "ENABLED"
}
}
],
"family": "efs-tutorial"
}
Seems easy add the right code to my Cloud Formation recipe (I choosed yaml syntax). Into my ContainerDefinition I added…
Volumes:
- Name: SRV
EfsVolumeConfiguration:
FileSystemId: fs-9999999
TransitEncryption: ENABLED
But when I run the Cloud Formation recipe I get….
The following resource(s) failed to update: [ContentJob1].
Property validation failure: [Encountered unsupported properties in {/ContainerProperties/Volumes/0}: [EfsVolumeConfiguration]]
If EfsVolumeConfiguration is not a valid property…
how I have to do to add an EFS volume to a AWS Batch Job Definition using Cloud Formation?
2
Answers
Until CloudFormation supported EFS, I used this solution. But its still usefull.
I create a Launch Template
Then I created a Compute Environment which use this template.
Finaly, I used ContainerProperties/[Volumes|MountPoints] of AWS::Batch::JobDefinition to add my EFS volumes.
Since I need to set the price of SPOT instances and other thigs into the LaunchTemplate, it had been a good solution to me.
AWS Batch added EFS Volume support on April 1, 2021.
The user documentation is available at https://docs.aws.amazon.com/batch/latest/userguide/efs-volumes.html
A blog post is available at https://aws.amazon.com/blogs/hpc/introducing-support-for-per-job-amazon-efs-volumes-in-aws-batch/