Skip to content

Instantly share code, notes, and snippets.

@pahud
Created November 16, 2018 03:49
Show Gist options
  • Save pahud/535998b275f28ab5d6b915ae51eee015 to your computer and use it in GitHub Desktop.
Save pahud/535998b275f28ab5d6b915ae51eee015 to your computer and use it in GitHub Desktop.
Create Autoscaling Group with more instance types and purchase options
#!/bin/bash
# make sure your awscli version is >= 1.16.56
#
# 1. create a launch template and copy the LaunchTemplateId
# 2. create mix-policy.json
# 3. run create-asg.sh
#
# by pahudnet@gmail.com
asgname=demo
aws autoscaling create-auto-scaling-group \
--auto-scaling-group-name=$asgname \
--min-size=2 \
--desired-capacity=8 \
--max-size=10 \
--vpc-zone-identifier=subnet-01afddf2fa02affaf,subnet-052e393860f11bde9,subnet-0be531a55836fef9c \
--mixed-instances-policy=file://mix-policy.json
{
"LaunchTemplate": {
"LaunchTemplateSpecification": {
"LaunchTemplateId": "lt-0bc5d3f873b573e3c"
},
"Overrides": [
{
"InstanceType": "t3.small"
},
{
"InstanceType": "t3.medium"
},
{
"InstanceType": "t3.large"
},
{
"InstanceType": "t3.xlarge"
}
]
},
"InstancesDistribution": {
"OnDemandAllocationStrategy": "prioritized",
"OnDemandBaseCapacity": 2,
"OnDemandPercentageAboveBaseCapacity": 0,
"SpotAllocationStrategy": "lowest-price",
"SpotInstancePools": 10
}
}
@pahud
Copy link
Author

pahud commented Nov 16, 2018

image

@GoodMirek
Copy link

Thanks! You have saved me from figuring that out myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment