Skip to content

Commit

Permalink
test(asg): Verify that UpdatePolicies are correctly cloudformed when …
Browse files Browse the repository at this point in the history
…specified in a pattern
  • Loading branch information
AshCorr committed Jul 11, 2024
1 parent d49c690 commit 3e8dbb5
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/patterns/ec2-app/base.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Match, Template } from "aws-cdk-lib/assertions";
import { BlockDeviceVolume, EbsDeviceVolumeType } from "aws-cdk-lib/aws-autoscaling";
import { BlockDeviceVolume, EbsDeviceVolumeType, UpdatePolicy } from "aws-cdk-lib/aws-autoscaling";
import { InstanceClass, InstanceSize, InstanceType, Peer, Port, Vpc } from "aws-cdk-lib/aws-ec2";
import { type CfnLoadBalancer } from "aws-cdk-lib/aws-elasticloadbalancingv2";
import { AccessScope, MetadataKeys } from "../../constants";
Expand Down Expand Up @@ -1095,4 +1095,32 @@ describe("the GuEC2App pattern", function () {
SslPolicy: "ELBSecurityPolicy-TLS13-1-2-2021-06",
});
});

it("has a defined UpdatePolicy when provided with one", function () {
const stack = simpleGuStackForTesting();
new GuEc2App(stack, {
applicationPort: 3000,
app: "test-gu-ec2-app",
access: { scope: AccessScope.PUBLIC },
instanceType: InstanceType.of(InstanceClass.T4G, InstanceSize.MEDIUM),
monitoringConfiguration: { noMonitoring: true },
userData: "#!/bin/dev foobarbaz",
certificateProps: {
domainName: "domain-name-for-your-application.example",
},
scaling: {
minimumInstances: 1,
},
instanceMetadataHopLimit: 2,
updatePolicy: UpdatePolicy.replacingUpdate(),
});

Template.fromStack(stack).hasResource("AWS::AutoScaling::AutoScalingGroup", {
UpdatePolicy: {
AutoScalingReplacingUpdate: {
WillReplace: true,
},
},
});
});
});

0 comments on commit 3e8dbb5

Please sign in to comment.