Skip to content

Commit

Permalink
chore(ecs): add test and docs for using ARM instances
Browse files Browse the repository at this point in the history
Closes aws#14433
  • Loading branch information
SoManyHs committed May 5, 2021
1 parent acc7bdd commit 611cf2e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
15 changes: 15 additions & 0 deletions packages/@aws-cdk/aws-ecs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,21 @@ cluster.addCapacity('bottlerocket-asg', {
});
```

### ARM64 (Graviton) Instances

To launch instances with ARM64 hardware, you can use the Amazon ECS-optimized
Amazon Linux 2 (arm64) AMI. Based on Amazon Linux 2, this AMI is recommended
for use when launching your EC2 instances that are powered by Arm-based AWS
Graviton Processors.

```ts
cluster.addCapacity('graviton-cluster', {
minCapacity: 2,
instanceType: new ec2.InstanceType('c6g.large'),
machineImage: ecs.EcsOptimizedImage.amazonLinux2(ecs.AmiHardwareType.ARM),
});

```
### Spot Instances

To add spot instances into the cluster, you must specify the `spotPrice` in the `ecs.AddCapacityOptions` and optionally enable the `spotInstanceDraining` property.
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ecs/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ export enum WindowsOptimizedVersion {
/*
* TODO:v2.0.0
* * remove `export` keyword
* * remove @depracted
* * remove @deprecated
*/
/**
* The properties that define which ECS-optimized AMI is used.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,17 @@ nodeunitShim({
test.done();
},

'allows returning the correct image for linux 2 for EcsOptimizedImage with ARM hardware'(test: Test) {
// GIVEN
const stack = new cdk.Stack();

test.equal(ecs.EcsOptimizedImage.amazonLinux2(ecs.AmiHardwareType.ARM).getImage(stack).osType,
ec2.OperatingSystemType.LINUX);

test.done();
},


'allows returning the correct image for windows for EcsOptimizedImage'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
Expand Down
16 changes: 16 additions & 0 deletions packages/@aws-cdk/aws-ecs/test/integ.cluster.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as ec2 from '@aws-cdk/aws-ec2';
import * as cdk from '@aws-cdk/core';
import * as ecs from '../lib';

const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-ecs-integ');

const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2 });
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });

cluster.addCapacity('graviton-cluster', {
minCapacity: 2,
instanceType: new ec2.InstanceType('c6g.large'),
machineImage: ecs.EcsOptimizedImage.amazonLinux2(ecs.AmiHardwareType.ARM),
});
app.synth();

0 comments on commit 611cf2e

Please sign in to comment.