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 9f82bae8f8098..584240c470701 100644 --- a/packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts +++ b/packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts @@ -212,9 +212,9 @@ export class AutoScalingGroup extends cdk.Construct implements cdk.ITaggable, el launchConfig.addDependency(this.role); - const minSize = props.minSize || 1; - const maxSize = props.maxSize || 1; - const desiredCapacity = props.desiredCapacity || 1; + const minSize = props.minSize !== undefined ? props.minSize : 1; + const maxSize = props.maxSize !== undefined ? props.maxSize : 1; + const desiredCapacity = props.desiredCapacity !== undefined ? props.desiredCapacity : 1; if (desiredCapacity < minSize || desiredCapacity > maxSize) { throw new Error(`Should have minSize (${minSize}) <= desiredCapacity (${desiredCapacity}) <= maxSize (${maxSize})`); 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 a2a63050b9658..587ef5f91b22b 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 @@ -126,6 +126,29 @@ export = { test.done(); }, + 'can set minSize, maxSize, desiredCapacity to 0'(test: Test) { + const stack = new cdk.Stack(undefined, 'MyStack', { env: { region: 'us-east-1', account: '1234' }}); + const vpc = mockVpc(stack); + + new autoscaling.AutoScalingGroup(stack, 'MyFleet', { + instanceType: new ec2.InstanceTypePair(ec2.InstanceClass.M4, ec2.InstanceSize.Micro), + machineImage: new ec2.AmazonLinuxImage(), + vpc, + minSize: 0, + maxSize: 0, + desiredCapacity: 0 + }); + + expect(stack).to(haveResource("AWS::AutoScaling::AutoScalingGroup", { + MinSize: "0", + MaxSize: "0", + DesiredCapacity: "0", + } + )); + + test.done(); + }, + 'addToRolePolicy can be used to add statements to the role policy'(test: Test) { const stack = new cdk.Stack(undefined, 'MyStack', { env: { region: 'us-east-1', account: '1234' }}); const vpc = mockVpc(stack);