Created
June 4, 2020 08:09
-
-
Save nirsky/610e3888a72927afbcd61d7126635b04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Ec2TaskDefinition, Scope, ContainerDefinition } from '@aws-cdk/aws-ecs'; | |
// Create TaskDefinition | |
const taskDefinition = new Ec2TaskDefinition(...); | |
// Add EBS volume, this will also create the volume | |
// Look here to understand all the options: | |
// https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-volumes.html | |
const VOLUME_NAME = 'my-ebs-volume'; | |
taskDefinition.addVolume({ | |
name: VOLUME_NAME, | |
dockerVolumeConfiguration: { | |
autoprovision: true, | |
scope: Scope.SHARED, | |
driver: 'rexray/ebs', | |
driverOpts: { | |
volumetype: 'gp2', | |
size: '10', | |
}, | |
}, | |
}); | |
// Add your docker container | |
const myContainer: ContainerDefinition = taskDefinition.addContainer(...); | |
// Mount the volume to your container | |
myContainer.addMountPoints({ | |
sourceVolume: VOLUME_NAME, | |
containerPath: '/path/to/mount', | |
readOnly: false, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment