Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(aws-ecs): include GPU & ARM based ECS optimized AMI options #2453

Merged
merged 14 commits into from
May 23, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions packages/@aws-cdk/aws-ecs/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,48 @@ export class EcsOptimizedAmi implements ec2.IMachineImageSource {
}
}

/**
* Construct a GPU-based Linux machine image from the latest ECS Optimized AMI published in SSM
*/
export class EcsGpuOptimizedAmi implements ec2.IMachineImageSource {
mattmcclean marked this conversation as resolved.
Show resolved Hide resolved
private readonly amiParameterName: string = '/aws/service/ecs/optimized-ami/amazon-linux-2/gpu/recommended';

/**
* Return the correct image
*/
public getImage(scope: Construct): ec2.MachineImage {
const ssmProvider = new SSMParameterProvider(scope, {
parameterName: this.amiParameterName
});

const json = ssmProvider.parameterValue("{\"image_id\": \"\"}");
const ami = JSON.parse(json).image_id;

return new ec2.MachineImage(ami, new ec2.LinuxOS());
}
}

/**
* Construct a ARM-based Linux machine image from the latest ECS Optimized AMI published in SSM
*/
export class EcsArmOptimizedAmi implements ec2.IMachineImageSource {
private readonly amiParameterName: string = '/aws/service/ecs/optimized-ami/amazon-linux-2/arm64/recommended';

/**
* Return the correct image
*/
public getImage(scope: Construct): ec2.MachineImage {
const ssmProvider = new SSMParameterProvider(scope, {
parameterName: this.amiParameterName
});

const json = ssmProvider.parameterValue("{\"image_id\": \"\"}");
const ami = JSON.parse(json).image_id;

return new ec2.MachineImage(ami, new ec2.LinuxOS());
}
}

/**
* An ECS cluster
*/
Expand Down