From 1105831bca3c0391df93ba84b0fd2e26296cc1c7 Mon Sep 17 00:00:00 2001 From: philmcmahon Date: Thu, 10 Oct 2024 11:28:46 +0100 Subject: [PATCH] Parameterise cpuArchitecture for GuEcsTask --- .changeset/brave-pots-act.md | 5 +++++ package.json | 2 +- .../ecs/__snapshots__/ecs-task.test.ts.snap | 4 ++++ src/constructs/ecs/ecs-task.ts | 12 ++++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 .changeset/brave-pots-act.md diff --git a/.changeset/brave-pots-act.md b/.changeset/brave-pots-act.md new file mode 100644 index 000000000..e98d72cad --- /dev/null +++ b/.changeset/brave-pots-act.md @@ -0,0 +1,5 @@ +--- +"@guardian/cdk": major +--- + +Add cpuArchitecture property to guecstask, default it to ARM64 diff --git a/package.json b/package.json index de394e4b8..68a9b9250 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/constructs/ecs/__snapshots__/ecs-task.test.ts.snap b/src/constructs/ecs/__snapshots__/ecs-task.test.ts.snap index 8577dce89..244b0ddbc 100644 --- a/src/constructs/ecs/__snapshots__/ecs-task.test.ts.snap +++ b/src/constructs/ecs/__snapshots__/ecs-task.test.ts.snap @@ -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", diff --git a/src/constructs/ecs/ecs-task.ts b/src/constructs/ecs/ecs-task.ts index 773f2621b..ba44d2d4a 100644 --- a/src/constructs/ecs/ecs-task.ts +++ b/src/constructs/ecs/ecs-task.ts @@ -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"; @@ -131,6 +133,11 @@ export interface GuEcsTaskProps extends AppIdentity { * @default false */ containerInsights?: boolean; + /** + * Set architecture + * @default ARM64 + */ + cpuArchitecture?: CpuArchitecture; } /** @@ -180,6 +187,7 @@ export class GuEcsTask extends Construct { enableDistributablePolicy = true, readonlyRootFilesystem = false, containerInsights = false, + cpuArchitecture = CpuArchitecture.ARM64, } = props; if (storage && storage < 21) { @@ -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`, {