learner00
learner00

Reputation: 68

CloudFormation LaunchTemplate AutoScaling group with Spot instances

I'm creating a CloudFormation template to deploy an autoscaling group that should only use spot instances. The Cloudformation throws an error with this template. What's wrong here?

Error: CREATE_FAILED Encountered unsupported property InstancesDistribution

{
    "Resources": {
        "testasg": {
            "Type": "AWS::AutoScaling::AutoScalingGroup",
            "Properties": {
                "LaunchTemplate": {
                    "LaunchTemplateId": "lt-0c8090cd4510eb25e",
                    "Version": "1"
                },
                "MaxSize": "10",
                "MinSize": "2",
                "DesiredCapacity": "2",
                "VPCZoneIdentifier": [
                    "subnet1",
                    "subnet2"
                ],
                "MaxInstanceLifetime": 86400,
                "InstancesDistribution": {
                    "OnDemandAllocationStrategy": "lowest-price",
                    "OnDemandBaseCapacity": 0,
                    "OnDemandPercentageAboveBaseCapacity": 0,
                    "SpotAllocationStrategy": "lowest-price",
                    "SpotInstancePools": 2
                },
                "NewInstancesProtectedFromScaleIn": false,
                "TerminationPolicies": [
                    "OldestInstance"
                ],
                "Tags": [
                    {
                        "Key": "Cluster",
                        "Value": "Production",
                        "PropagateAtLaunch": "true"
                    },
                ]
            }
        }
    }
}

Upvotes: 0

Views: 285

Answers (1)

Marcin
Marcin

Reputation: 238209

InstancesDistribution should be inside MixedInstancesPolicy block, which you do not have.

Upvotes: 1

Related Questions