diff --git a/dotcom-rendering/cdk/bin/cdk.ts b/dotcom-rendering/cdk/bin/cdk.ts index 87be989429a..61cdb4f3959 100644 --- a/dotcom-rendering/cdk/bin/cdk.ts +++ b/dotcom-rendering/cdk/bin/cdk.ts @@ -130,12 +130,6 @@ export const TagPageRenderingPropsCODE: RenderingCDKStackProps = { scaleOutCooldown: Duration.seconds(60), }, }, - - // Route all traffic to ECS. NOTE: EC2 has 0 instances. - targetGroupWeights: { - ec2: 0, - ecs: 1, - }, }, }; @@ -164,12 +158,6 @@ export const TagPageRenderingPropsPROD: RenderingCDKStackProps = { scaleOutCooldown: Duration.seconds(60), }, }, - - // Route 100% traffic to ECS. NOTE: EC2 has 0 instances. - targetGroupWeights: { - ec2: 0, - ecs: 1, - }, }, }; @@ -202,12 +190,11 @@ export const InteractiveRenderingPropsCODE: RenderingCDKStackProps = { scaleOutCooldown: Duration.seconds(60), }, }, - - // Route 100% traffic to EC2. - targetGroupWeights: { - ec2: 1, - ecs: 0, - }, + }, + // Route 100% traffic to EC2. + targetGroupWeights: { + ec2: 1, + ecs: 0, }, }; /** Interactive */ diff --git a/dotcom-rendering/cdk/lib/renderingStack.ts b/dotcom-rendering/cdk/lib/renderingStack.ts index 09c8e175d28..84f55ab4400 100644 --- a/dotcom-rendering/cdk/lib/renderingStack.ts +++ b/dotcom-rendering/cdk/lib/renderingStack.ts @@ -70,11 +70,11 @@ export interface RenderingCDKStackProps extends Omit { scaling: NonNullable< GuLoadBalancedAppExperimentalProps['ecsProps'] >['scaling']; - - targetGroupWeights: NonNullable< - GuLoadBalancedAppExperimentalProps['targetGroupWeights'] - >; }; + + targetGroupWeights?: NonNullable< + GuLoadBalancedAppExperimentalProps['targetGroupWeights'] + >; } const addCPUStepScalingPolicy = ( @@ -211,7 +211,14 @@ const addLatencyStepScalingPolicy = ( /** DCR infrastructure provisioning via CDK */ export class RenderingCDKStack extends CDKStack { constructor(scope: CDKApp, id: string, props: RenderingCDKStackProps) { - const { guApp, stage, domainName, ec2Props, ecsProps } = props; + const { + guApp, + stage, + domainName, + ec2Props, + ecsProps, + targetGroupWeights, + } = props; super(scope, id, { // Any version of this app should run in the eu-west-1 region @@ -294,8 +301,6 @@ export class RenderingCDKStack extends CDKStack { }), }, }), - - // Provision ECS resources only when `ecsProps` has been provided ...(ecsProps == null ? {} : { @@ -308,8 +313,8 @@ export class RenderingCDKStack extends CDKStack { cpu: ecsProps.taskCpu, scaling: ecsProps.scaling, }, - targetGroupWeights: ecsProps.targetGroupWeights, }), + ...(targetGroupWeights == null ? {} : { targetGroupWeights }), }); if (app.ecsService) {