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

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

merged 14 commits into from
May 23, 2019

Conversation

mattmcclean
Copy link
Contributor

@mattmcclean mattmcclean commented May 1, 2019


Pull Request Checklist

  • Testing
    • Unit test added (prefer not to modify an existing test, otherwise, it's probably a breaking change)
    • CLI change?: coordinate update of integration tests with team
    • cdk-init template change?: coordinated update of integration tests with team
  • Docs
    • jsdocs: All public APIs documented
    • README: README and/or documentation topic updated
    • Design: For significant features, design document added to design folder
  • Title and Description
    • Change type: title prefixed with fix, feat and module name in parens, which will appear in changelog
    • Title: use lower-case and doesn't end with a period
    • Breaking?: last paragraph: "BREAKING CHANGE: <describe what changed + link for details>"
    • Issues: Indicate issues fixed via: "Fixes #xxx" or "Closes #xxx"
  • Sensitive Modules (requires 2 PR approvers)
    • IAM Policy Document (in @aws-cdk/aws-iam)
    • EC2 Security Groups and ACLs (in @aws-cdk/aws-ec2)
    • Grant APIs (only if not based on official documentation with a reference)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.

@mattmcclean mattmcclean requested review from SoManyHs and a team as code owners May 1, 2019 20:04
Copy link
Contributor

@SoManyHs SoManyHs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks @mattmcclean! Should we also think about modifying AddCapacityOptions to include machineImage so that these AMI constructs can be used there?

@mattmcclean
Copy link
Contributor Author

Yes, would be good to add machineImage option to AddCapacityOptions as I see it is hard coded to be the default EcsOptimizedAmi. Would we need a base class that the others implement?

@SoManyHs
Copy link
Contributor

SoManyHs commented May 1, 2019

A base class for which? The Ami classes all implement IMachineImageSource, and AddCapacityOptions extends AddAutoScalingGroupCapacityOptions. The latter inherits from autoscaling.CommonAutoScalingGroupProps which does not appear to have machineImage, though the autoscaling.AutoScalingGroupProps does. So I'm thinking we would add machineImage to AddAutoScalingGroupCapacityOptions, since that would expose the property for both the default addCapacity as well as the custom one.

Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Any chance you can also add a small unit test?

@mattmcclean
Copy link
Contributor Author

@SoManyHs cool, have added the machine image parameter to AddAutoScalingGroupCapacityOptions. Not sure how to do a test as the ami id will change frequently

packages/@aws-cdk/aws-ecs/lib/cluster.ts Outdated Show resolved Hide resolved
@SoManyHs
Copy link
Contributor

Verified that running a synth on a stack with:

cluster.addCapacity('GpuAutoScalingGroup', {
      instanceType: new ec2.InstanceType('t2.micro'),
      machineImage: new ecs.EcsOptimizedAmi({
      amiType: ecs.EcsOptimizedAmiType.Gpu
      }),

resulted in this bit of CFN:

  EcsClusterDefaultAutoScalingGroupLaunchConfigB7E376C1:
    Type: AWS::AutoScaling::LaunchConfiguration
    Properties:
      ImageId: ami-043c4e6bff652b99e
      InstanceType: t2.micro
      IamInstanceProfile:
        Ref: EcsClusterDefaultAutoScalingGroupInstanceProfile2CE606B3
      SecurityGroups:
        - Fn::GetAtt:
            - EcsClusterDefaultAutoScalingGroupInstanceSecurityGroup912E1231
            - GroupId

The ImageId: ami-043c4e6bff652b99e indeed correponds to the GPU AMI for this region (us-west-2) currently published: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-optimized_AMI.html

Copy link
Contributor

@SoManyHs SoManyHs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending addition of the unit test suggested!

packages/@aws-cdk/aws-ecs/lib/cluster.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-ecs/lib/cluster.ts Outdated Show resolved Hide resolved
@mattmcclean
Copy link
Contributor Author

Changes have been committed including unit tests. The CodeBuild seems to be breaking but cannot see the details. Travis CI is working fine

@rix0rrr
Copy link
Contributor

rix0rrr commented May 23, 2019

Can be merged as soon as the build passes.

@RomainMuller RomainMuller merged commit 45abfcd into aws:master May 23, 2019
This was referenced Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants