aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.36k stars 3.77k forks source link

ec2: Need G6 EC2 Instance support #30683

Open CambioML opened 1 week ago

CambioML commented 1 week ago

Describe the feature

Need G6 EC2 Instance support

Use Case

Need to provision ECS EC2 while using G6 instance

Proposed Solution

No response

Other Information

No response

Acknowledgements

CDK version used

^2.1.0

Environment details (OS name and version, etc.)

mac 14.5

ashishdhingra commented 1 week ago

Per Amazon EC2 instance types, G6 is one of the supported instance types. However, it not an option in InstanceClass. The probable workaround is to use L1 construct.

@CambioML Thanks for bringing this issue into our attention. Feel free to contribute PR to add G6 EC2 instance type.

pahud commented 1 week ago

@CambioML

Before we have a PR to natively support that, you can override the InstanceType like this:

// create a dummy ec2 instance
    const instance = new ec2.Instance(this, 'Instance', {
      machineImage: ec2.MachineImage.latestAmazonLinux2023(),
      instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.SMALL),
      vpc: ec2.Vpc.fromLookup(this, 'Vpc', { isDefault: true }),
    });

   (instance.node.defaultChild as ec2.CfnInstance).addPropertyOverride('InstanceType', 'g6.xlarge');

verify:

% npx cdk synth dummy-stack1 | grep InstanceType
      InstanceType: g6.xlarge

And you will need to specify appropriate AMI as well.

Let me know if it works for you and we welcome any pull requests for this.