Skip to content

Commit b32066e

Browse files
Merge branch 'main' into bump-tracker-js
2 parents 2751026 + 9123798 commit b32066e

3 files changed

Lines changed: 40 additions & 25 deletions

File tree

dotcom-rendering/cdk/bin/cdk.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ export const TagPageRenderingPropsCODE: RenderingCDKStackProps = {
111111
domainName: 'tag-page-rendering.code.dev-guardianapis.com',
112112
scaling: { minimumInstances: 1, maximumInstances: 3 },
113113
instanceType: InstanceType.of(InstanceClass.T4G, InstanceSize.SMALL),
114-
imageIdentifier: getImageIdentifier(),
114+
ecsProps: {
115+
imageIdentifier: getImageIdentifier(),
116+
taskCpu: 1024,
117+
taskMemoryLimitMiB: 2048,
118+
},
115119
};
116120

117121
new RenderingCDKStack(
@@ -150,7 +154,11 @@ export const TagPageRenderingPropsPROD: RenderingCDKStackProps = {
150154
},
151155
},
152156
instanceType: InstanceType.of(InstanceClass.C8G, InstanceSize.MEDIUM),
153-
imageIdentifier: getImageIdentifier(),
157+
ecsProps: {
158+
imageIdentifier: getImageIdentifier(),
159+
taskCpu: 2048,
160+
taskMemoryLimitMiB: 4096,
161+
},
154162
};
155163

156164
new RenderingCDKStack(

dotcom-rendering/cdk/lib/__snapshots__/renderingStack.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4442,15 +4442,15 @@ exports[`The RenderingCDKStack matches the snapshot for Tag Page Rendering PROD
44424442
"ReadonlyRootFilesystem": true,
44434443
},
44444444
],
4445-
"Cpu": "1024",
4445+
"Cpu": "2048",
44464446
"ExecutionRoleArn": {
44474447
"Fn::GetAtt": [
44484448
"EcsTaskDefinitionExecutionRoleBE450C73",
44494449
"Arn",
44504450
],
44514451
},
44524452
"Family": "TagPageRenderingPRODEcsTaskDefinition12224835",
4453-
"Memory": "2048",
4453+
"Memory": "4096",
44544454
"NetworkMode": "awsvpc",
44554455
"RequiresCompatibilities": [
44564456
"FARGATE",

dotcom-rendering/cdk/lib/renderingStack.ts

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,28 @@ export interface RenderingCDKStackProps extends Omit<GuStackProps, 'stack'> {
4646
};
4747

4848
/**
49-
* Which image to run.
50-
* This should be the image digest (e.g. 'sha256:abc123') to ensure immutable deployments.
51-
*
52-
* @note Currently optional to control which services run in an EC2-ECS hybrid mode, or EC2-only.
53-
*
54-
* @see https://docs.docker.com/dhi/core-concepts/digests
49+
* ECS configuration including image identifier and instance sizing.
50+
* Optional to control which services run in an EC2-ECS hybrid mode, or EC2-only.
5551
*/
56-
imageIdentifier?: string;
52+
ecsProps?: {
53+
/**
54+
* Which image to run.
55+
* This should be the image digest (e.g. 'sha256:abc123') to ensure immutable deployments.
56+
*
57+
* @see https://docs.docker.com/dhi/core-concepts/digests
58+
*/
59+
imageIdentifier: string;
60+
61+
/**
62+
* vCPU units for the ECS task
63+
*/
64+
taskCpu: number;
65+
66+
/**
67+
* Memory in MB for ECS task
68+
*/
69+
taskMemoryLimitMiB: number;
70+
};
5771
}
5872

5973
const addCPUStepScalingPolicy = (
@@ -200,14 +214,8 @@ export class RenderingCDKStack extends CDKStack {
200214
});
201215

202216
const { stack: guStack, region, account } = this;
203-
const {
204-
guApp,
205-
stage,
206-
instanceType,
207-
scaling,
208-
domainName,
209-
imageIdentifier,
210-
} = props;
217+
const { guApp, stage, instanceType, scaling, domainName, ecsProps } =
218+
props;
211219

212220
const artifactsBucket =
213221
GuDistributionBucketParameter.getInstance(this).valueAsString;
@@ -276,17 +284,16 @@ export class RenderingCDKStack extends CDKStack {
276284
}),
277285
},
278286

279-
// Provision ECS resources only when `imageIdentifier` has been provided
280-
...(imageIdentifier == null
287+
// Provision ECS resources only when `ecsProps` has been provided
288+
...(ecsProps == null
281289
? {}
282290
: {
283291
ecsProps: {
284292
repositoryName: 'guardian/dotcom-rendering',
285-
imageIdentifier,
293+
imageIdentifier: ecsProps.imageIdentifier,
286294

287-
// TODO tune these values
288-
memoryLimitMiB: 2048,
289-
cpu: 1024,
295+
memoryLimitMiB: ecsProps.taskMemoryLimitMiB,
296+
cpu: ecsProps.taskCpu,
290297
scaling: {
291298
minimumTasks: 1,
292299
maximumTasks: 2,

0 commit comments

Comments
 (0)