Created
September 21, 2016 21:15
-
-
Save yhahn/f905b903ca962c1b3c3133dfcf17fec1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AWSTemplateFormatVersion": "2010-09-09", | |
"Description": "Builds an ECS Cluster", | |
"Parameters": {}, | |
"Resources": { | |
"SpotFleet": { | |
"Type": "AWS::EC2::SpotFleet", | |
"Properties": { | |
"SpotFleetRequestConfigData": { | |
"AllocationStrategy": "diversified", | |
"ExcessCapacityTerminationPolicy": "default", | |
"IamFleetRole": { | |
"Fn::GetAtt": [ | |
"IAMFleetRole", | |
"Arn" | |
] | |
}, | |
"SpotPrice": "2", | |
"TargetCapacity": "5", | |
"LaunchSpecifications": [ | |
{ | |
"InstanceType": "m3.xlarge", | |
"SecurityGroups": [], | |
"Monitoring": { | |
"Enabled": "true" | |
}, | |
"ImageId": "ami-6bb2d67c", | |
"BlockDeviceMappings": [ | |
{ | |
"VirtualName": "ephemeral0", | |
"DeviceName": "/dev/xvdb" | |
}, | |
{ | |
"VirtualName": "ephemeral1", | |
"DeviceName": "/dev/xvdc" | |
} | |
], | |
"UserData": { | |
"Fn::Base64": { | |
"Fn::Join": [ | |
"\n", | |
[ | |
"#!/bin/bash", | |
"set -ex", | |
"exec > >(tee /var/log/user-data.log | logger -t user-data -s 2> /dev/console) 2>&1" | |
] | |
] | |
} | |
} | |
} | |
] | |
} | |
} | |
}, | |
"IAMFleetRole": { | |
"Type": "AWS::IAM::Role", | |
"Properties": { | |
"AssumeRolePolicyDocument": { | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": { | |
"Service": [ | |
"spotfleet.amazonaws.com" | |
] | |
}, | |
"Action": [ | |
"sts:AssumeRole" | |
] | |
} | |
] | |
}, | |
"Policies": [ | |
{ | |
"PolicyName": "fleet", | |
"PolicyDocument": { | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"ec2:TerminateInstances", | |
"ec2:RequestSpotInstances", | |
"ec2:DescribeImages", | |
"ec2:DescribeSubnets" | |
], | |
"Resource": "*" | |
}, | |
{ | |
"Effect": "Allow", | |
"Action": "iam:PassRole", | |
"Resource": "*" | |
} | |
] | |
} | |
} | |
] | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment