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

(aws-ecs): Use the proper AMI when using a Graviton2 instance #14433

Closed
2 tasks
darko-mesaros opened this issue Apr 28, 2021 · 3 comments · Fixed by #14536
Closed
2 tasks

(aws-ecs): Use the proper AMI when using a Graviton2 instance #14433

darko-mesaros opened this issue Apr 28, 2021 · 3 comments · Fixed by #14536
Assignees
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container effort/small Small work item – less than a day of effort guidance Question that needs advice or information.

Comments

@darko-mesaros
Copy link

Okay, so, I wish to launch a Gravion2 ECS Cluster, and I wish to use CDK for that. I am using .addCapacity to create the AutoScaling Group for my cluster, and I am only specifying the instance type.

Unless I define a machineImage property and use the ECS optimized AMI (for aarch64), it will attempt to launch it with the regular x86 ECS optimized AMI. And the launch of EC2 Instances fail:

import * as cdk from '@aws-cdk/core';
import * as ec2 from '@aws-cdk/aws-ec2';
import * as ecs from '@aws-cdk/aws-ecs';

export class ClusterStack extends cdk.Stack {
  public readonly vpc: ec2.Vpc;
  public readonly cluster: ecs.Cluster;

  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    this.vpc = new ec2.Vpc(this, 'VPC', { maxAzs: 2});
    this.cluster = new ecs.Cluster(this, 'Cluster', {vpc: this.vpc});
    this.cluster.addCapacity('DefaultCapacity', {
      instanceType: new ec2.InstanceType('c6g.large'),
    });
  }
}

Use Case

We can keep using the dynamic nature of AMI IDs and not have to hardcode the AMI id for the ECS optimized image for Graviton2.

Proposed Solution

Ideally if CDK could verify if the instance type is an ARM based instance, it would use the appropriate AMI.

Other

CDK Version: 1.100.0 (build d996c6d)
OS: Mac Os Big Sur
Kernel: Darwin m1-air.lan 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 arm64

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@darko-mesaros darko-mesaros added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Apr 28, 2021
@peterwoodworth peterwoodworth added the @aws-cdk/aws-ecs Related to Amazon Elastic Container label Apr 28, 2021
@SoManyHs SoManyHs added effort/small Small work item – less than a day of effort p1 and removed needs-triage This issue or PR still needs to be triaged. labels Apr 29, 2021
@SoManyHs SoManyHs changed the title (ecs.cluster.addCapacity): Use the proper AMI when using a Gravion2 instance (aws-ecs): Use the proper AMI when using a Graviton2 instance Apr 29, 2021
@SoManyHs SoManyHs self-assigned this May 4, 2021
@SoManyHs SoManyHs added guidance Question that needs advice or information. and removed feature-request A feature should be added or improved. p1 labels May 4, 2021
SoManyHs added a commit to SoManyHs/aws-cdk that referenced this issue May 4, 2021
SoManyHs added a commit to SoManyHs/aws-cdk that referenced this issue May 4, 2021
SoManyHs added a commit to SoManyHs/aws-cdk that referenced this issue May 5, 2021
SoManyHs added a commit to SoManyHs/aws-cdk that referenced this issue May 5, 2021
@SoManyHs
Copy link
Contributor

SoManyHs commented May 5, 2021

Hi @darko-mesaros!

The missing piece here is you also need to specify machineImage as a property when you call addCapacity. I've updated the README with a working example in #14536 -- hope that helps!

SoManyHs added a commit to SoManyHs/aws-cdk that referenced this issue May 5, 2021
@darko-mesaros
Copy link
Author

Ah good! I was under the impression that I would need to know the AMI ID to be used at all times. This is a much better option! Thanks! 👏

@mergify mergify bot closed this as completed in #14536 May 5, 2021
mergify bot pushed a commit that referenced this issue May 5, 2021
Closes #14433


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented May 5, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

john-tipper pushed a commit to john-tipper/aws-cdk that referenced this issue May 10, 2021
Closes aws#14433


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this issue Aug 26, 2021
Closes aws#14433


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container effort/small Small work item – less than a day of effort guidance Question that needs advice or information.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants