diff --git a/src/experimental/patterns/__snapshots__/ec2-app.test.ts.snap b/src/experimental/patterns/__snapshots__/ec2-app.test.ts.snap index 6409e3b98..8346b5169 100644 --- a/src/experimental/patterns/__snapshots__/ec2-app.test.ts.snap +++ b/src/experimental/patterns/__snapshots__/ec2-app.test.ts.snap @@ -110,6 +110,7 @@ exports[`The GuEc2AppExperimental pattern matches the snapshot 1`] = ` }, }, "Properties": { + "DesiredCapacity": "1", "HealthCheckGracePeriod": 120, "HealthCheckType": "ELB", "LaunchTemplate": { diff --git a/src/experimental/patterns/ec2-app.test.ts b/src/experimental/patterns/ec2-app.test.ts index 9194979e2..9d51a5808 100644 --- a/src/experimental/patterns/ec2-app.test.ts +++ b/src/experimental/patterns/ec2-app.test.ts @@ -44,6 +44,20 @@ describe("The GuEc2AppExperimental pattern", () => { expect(Template.fromStack(stack).toJSON()).toMatchSnapshot(); }); + it("should create an ASG with min, max, and desired capacity set", () => { + const stack = simpleGuStackForTesting(); + + new GuEc2AppExperimental(stack, { ...initialProps(stack), scaling: { minimumInstances: 5 } }); + + Template.fromStack(stack).hasResource("AWS::AutoScaling::AutoScalingGroup", { + Properties: { + MinSize: "5", + MaxSize: "10", + DesiredCapacity: "5", + }, + }); + }); + it("should create an ASG with a resource signal count that matches the min instances", () => { const stack = simpleGuStackForTesting(); diff --git a/src/experimental/patterns/ec2-app.ts b/src/experimental/patterns/ec2-app.ts index e776abd9e..f2a40c200 100644 --- a/src/experimental/patterns/ec2-app.ts +++ b/src/experimental/patterns/ec2-app.ts @@ -58,6 +58,8 @@ export class GuEc2AppExperimental extends GuEc2App { const { userData, role } = autoScalingGroup; const cfnAutoScalingGroup = autoScalingGroup.node.defaultChild as CfnAutoScalingGroup; + cfnAutoScalingGroup.desiredCapacity = minimumInstances.toString(); + /* Enable all ASG metrics for improved observability. Specifying `granularity` without specifying `metrics` results in all metrics being enabled.