Skip to content
Open
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
23 changes: 5 additions & 18 deletions dotcom-rendering/cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
};

Expand Down Expand Up @@ -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,
},
},
};

Expand Down Expand Up @@ -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 */
Expand Down
21 changes: 13 additions & 8 deletions dotcom-rendering/cdk/lib/renderingStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ export interface RenderingCDKStackProps extends Omit<GuStackProps, 'stack'> {
scaling: NonNullable<
GuLoadBalancedAppExperimentalProps['ecsProps']
>['scaling'];

targetGroupWeights: NonNullable<
GuLoadBalancedAppExperimentalProps['targetGroupWeights']
>;
};

targetGroupWeights?: NonNullable<
GuLoadBalancedAppExperimentalProps['targetGroupWeights']
>;
}

const addCPUStepScalingPolicy = (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -294,8 +301,6 @@ export class RenderingCDKStack extends CDKStack {
}),
},
}),

// Provision ECS resources only when `ecsProps` has been provided
...(ecsProps == null
? {}
: {
Expand All @@ -308,8 +313,8 @@ export class RenderingCDKStack extends CDKStack {
cpu: ecsProps.taskCpu,
scaling: ecsProps.scaling,
},
targetGroupWeights: ecsProps.targetGroupWeights,
}),
...(targetGroupWeights == null ? {} : { targetGroupWeights }),
});

if (app.ecsService) {
Expand Down
Loading