Skip to content

Commit

Permalink
Parameterise cpuArchitecture for GuEcsTask
Browse files Browse the repository at this point in the history
  • Loading branch information
philmcmahon committed Oct 31, 2024
1 parent 4eaedc2 commit 1105831
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/brave-pots-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@guardian/cdk": major
---

Add cpuArchitecture property to guecstask, default it to ARM64
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"prettier:check": "prettier --check \"src/**/*.ts\"",
"format": "prettier --write \"src/**/*.ts\"",
"watch": "tsc -w",
"test": "jest --detectOpenHandles --runInBand",
"test": "jest --detectOpenHandles --runInBand -u",
"test:custom-lint-rule": "eslint tools/eslint/rules/*.test.ts",
"test:dev": "jest --detectOpenHandles --runInBand --watch",
"prepare": "tsc",
Expand Down
4 changes: 4 additions & 0 deletions src/constructs/ecs/__snapshots__/ecs-task.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,10 @@ exports[`The GuEcsTask pattern should create the correct resources with lots of
"RequiresCompatibilities": [
"FARGATE",
],
"RuntimePlatform": {
"CpuArchitecture": "ARM64",
"OperatingSystemFamily": "LINUX",
},
"Tags": [
{
"Key": "App",
Expand Down
12 changes: 12 additions & 0 deletions src/constructs/ecs/ecs-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import {
Cluster,
Compatibility,
ContainerImage,
CpuArchitecture,
FargatePlatformVersion,
LogDrivers,
OperatingSystemFamily,
TaskDefinition,
} from "aws-cdk-lib/aws-ecs";
import type { PolicyStatement } from "aws-cdk-lib/aws-iam";
Expand Down Expand Up @@ -131,6 +133,11 @@ export interface GuEcsTaskProps extends AppIdentity {
* @default false
*/
containerInsights?: boolean;
/**
* Set architecture
* @default ARM64
*/
cpuArchitecture?: CpuArchitecture;
}

/**
Expand Down Expand Up @@ -180,6 +187,7 @@ export class GuEcsTask extends Construct {
enableDistributablePolicy = true,
readonlyRootFilesystem = false,
containerInsights = false,
cpuArchitecture = CpuArchitecture.ARM64,
} = props;

if (storage && storage < 21) {
Expand All @@ -203,6 +211,10 @@ export class GuEcsTask extends Construct {
memoryMiB: memory.toString(),
family: `${stack}-${stage}-${app}`,
ephemeralStorageGiB: storage,
runtimePlatform: {
cpuArchitecture: cpuArchitecture,
operatingSystemFamily: OperatingSystemFamily.of("LINUX"),
},
});

const containerDefinition = taskDefinition.addContainer(`${id}-TaskContainer`, {
Expand Down

0 comments on commit 1105831

Please sign in to comment.