From 00634fdc8b6b0c4696e8a2a0382ab0070659a118 Mon Sep 17 00:00:00 2001 From: akash1810 Date: Mon, 15 Jul 2024 15:49:18 +0100 Subject: [PATCH] Set ASG creation policy --- cdk/lib/__snapshots__/cdk-playground.test.ts.snap | 8 ++++++++ cdk/lib/cdk-playground.ts | 13 +++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cdk/lib/__snapshots__/cdk-playground.test.ts.snap b/cdk/lib/__snapshots__/cdk-playground.test.ts.snap index 628f4d66..afd7fc31 100644 --- a/cdk/lib/__snapshots__/cdk-playground.test.ts.snap +++ b/cdk/lib/__snapshots__/cdk-playground.test.ts.snap @@ -114,6 +114,11 @@ Object { }, "Resources": Object { "AutoScalingGroupCdkplaygroundASGD6E49F0F": Object { + "CreationPolicy": Object { + "AutoScalingCreationPolicy": Object { + "MinSuccessfulInstancesPercent": 100, + }, + }, "Properties": Object { "HealthCheckGracePeriod": 120, "HealthCheckType": "ELB", @@ -192,6 +197,9 @@ Object { "AutoScalingReplacingUpdate": Object { "WillReplace": true, }, + "AutoScalingScheduledAction": Object { + "IgnoreUnmodifiedGroupSizeProperties": true, + }, }, }, "CertificateCdkplayground47FCF7D9": Object { diff --git a/cdk/lib/cdk-playground.ts b/cdk/lib/cdk-playground.ts index 817b6bd9..72ff7727 100644 --- a/cdk/lib/cdk-playground.ts +++ b/cdk/lib/cdk-playground.ts @@ -8,6 +8,7 @@ import { GuFastlyLogsIamRole } from '@guardian/cdk/lib/constructs/iam'; import type { App, CfnAutoScalingReplacingUpdate, + CfnCreationPolicy, CfnStack, CfnUpdatePolicy, } from 'aws-cdk-lib'; @@ -64,14 +65,14 @@ export class CdkPlayground extends GuStack { updatePolicy: UpdatePolicy.replacingUpdate(), }); - const updatePolicy: CfnUpdatePolicy = { - autoScalingReplacingUpdate: { - willReplace: true, - } as CfnAutoScalingReplacingUpdate, + const createPolicy: CfnCreationPolicy = { + autoScalingCreationPolicy: { + minSuccessfulInstancesPercent: 100, + }, }; + const asg = autoScalingGroup.node.defaultChild as CfnAutoScalingGroup; - // asg.desiredCapacity = '3'; - asg.cfnOptions.updatePolicy = updatePolicy; + asg.cfnOptions.creationPolicy = createPolicy; new GuCname(this, 'EC2AppDNS', { app: ec2App,