Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 46 additions & 13 deletions dotcom-rendering/cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ import { InstanceClass, InstanceSize, InstanceType } from 'aws-cdk-lib/aws-ec2';
import type { RenderingCDKStackProps } from '../lib/renderingStack';
import { RenderingCDKStack } from '../lib/renderingStack';

function getImageIdentifier(): string {

@aug24 aug24 Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to top as it will eventually be used by everything.

We could eventually make this just a top level variable?

const imageIdentifier: string | undefined = process.env.IMAGE_DIGEST;
if (!imageIdentifier) {
throw new Error('Image identifier must be provided');
}
return imageIdentifier;
}

const cdkApp = new App();

const cpuScalingSteps = {
Expand Down Expand Up @@ -97,14 +105,6 @@ new RenderingCDKStack(cdkApp, 'FaciaRendering-PROD', {
});

/** Tag pages */
function getImageIdentifier(): string {
const imageIdentifier: string | undefined = process.env.IMAGE_DIGEST;
if (!imageIdentifier) {
throw new Error('Image identifier must be provided');
}
return imageIdentifier;
}

export const TagPageRenderingPropsCODE: RenderingCDKStackProps = {
guApp: 'tag-page-rendering',
stage: 'CODE',
Expand Down Expand Up @@ -199,15 +199,43 @@ new RenderingCDKStack(
TagPageRenderingPropsPROD,
);

/** Interactive */
new RenderingCDKStack(cdkApp, 'InteractiveRendering-CODE', {
export const InteractiveRenderingPropsCODE: RenderingCDKStackProps = {
guApp: 'interactive-rendering',
stage: 'CODE',
domainName: 'interactive-rendering.code.dev-guardianapis.com',
scaling: { minimumInstances: 1, maximumInstances: 3 },
instanceType: InstanceType.of(InstanceClass.T4G, InstanceSize.MICRO),
});
new RenderingCDKStack(cdkApp, 'InteractiveRendering-PROD', {
ecsProps: {
imageIdentifier: getImageIdentifier(),
taskCpu: 1024,
taskMemoryLimitMiB: 2048,
scaling: {
minimumTasks: 1,
maximumTasks: 3,
cpuScaling: {
targetValue: 20,
// TODO: Tune cooldown values.
// https://docs.aws.amazon.com/autoscaling/application/userguide/target-tracking-scaling-policy-overview.html#target-tracking-cooldown
scaleInCooldown: Duration.seconds(60),
scaleOutCooldown: Duration.seconds(60),
},
},

// Route 100% traffic to EC2.
targetGroupWeights: {
ec2: 1,
ecs: 0,
},
},
};
/** Interactive */
new RenderingCDKStack(
cdkApp,
'InteractiveRendering-CODE',
InteractiveRenderingPropsCODE,
);

export const InteractiveRenderingPropsPROD: RenderingCDKStackProps = {
guApp: 'interactive-rendering',
stage: 'PROD',
domainName: 'interactive-rendering.guardianapis.com',
Expand Down Expand Up @@ -237,4 +265,9 @@ new RenderingCDKStack(cdkApp, 'InteractiveRendering-PROD', {
},
},
instanceType: InstanceType.of(InstanceClass.C8G, InstanceSize.MEDIUM),
});
};
new RenderingCDKStack(
cdkApp,
'InteractiveRendering-PROD',
InteractiveRenderingPropsPROD,
);
Loading
Loading