diff --git a/packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts b/packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts index 7e84e7620bbe4..79bfabcf5a5c3 100644 --- a/packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts +++ b/packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts @@ -199,6 +199,18 @@ export interface CommonAutoScalingGroupProps { * @default none */ readonly maxInstanceLifetime?: Duration; + + /** + * Controls whether instances in this group are launched with detailed (true) or basic (false) monitoring. + * + * When detailed monitoring is enabled, Amazon CloudWatch generates metrics every minute and your account + * is charged a fee. When you disable detailed monitoring, CloudWatch generates metrics every 5 minutes. + * + * @see https://docs.aws.amazon.com/autoscaling/latest/userguide/as-instance-monitoring.html#enable-as-instance-metrics + * + * @default true + */ + readonly instanceMonitoring?: boolean; } /** @@ -468,6 +480,7 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements imageId: imageConfig.imageId, keyName: props.keyName, instanceType: props.instanceType.toString(), + instanceMonitoring: props.instanceMonitoring, securityGroups: securityGroupsToken, iamInstanceProfile: iamProfile.ref, userData: userDataToken, diff --git a/packages/@aws-cdk/aws-autoscaling/test/test.auto-scaling-group.ts b/packages/@aws-cdk/aws-autoscaling/test/test.auto-scaling-group.ts index 5ee4d7bff64dd..9c7adb74ff36c 100644 --- a/packages/@aws-cdk/aws-autoscaling/test/test.auto-scaling-group.ts +++ b/packages/@aws-cdk/aws-autoscaling/test/test.auto-scaling-group.ts @@ -830,6 +830,26 @@ export = { test.done(); }, + 'can configure instance monitoring'(test: Test) { + // GIVEN + const stack = new cdk.Stack(); + const vpc = mockVpc(stack); + + // WHEN + new autoscaling.AutoScalingGroup(stack, 'MyStack', { + instanceType: ec2.InstanceType.of(ec2.InstanceClass.M4, ec2.InstanceSize.MICRO), + machineImage: new ec2.AmazonLinuxImage(), + vpc, + instanceMonitoring: false, + }); + + // THEN + expect(stack).to(haveResource('AWS::AutoScaling::LaunchConfiguration', { + InstanceMonitoring: false, + })); + test.done(); + }, + 'throws if ephemeral volumeIndex < 0'(test: Test) { // GIVEN const stack = new cdk.Stack();