-
Notifications
You must be signed in to change notification settings - Fork 2
/
security.template2.txt
78 lines (72 loc) · 2.47 KB
/
security.template2.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{
"Parameters" : {
"LatestAmiId" : {
"Type" : "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
"Default" : "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-ebs"
},
"OksoftSubnet":{
"Type": "AWS::EC2::Subnet::Id"
},
"OksoftSG":{
"Type":"AWS::EC2::SecurityGroup::Id"
},
"KeyName": {
"Type": "AWS::EC2::KeyPair::KeyName"
},
"InstanceType": {
"Type": "String",
"Default": "c4.large",
"AllowedValues": ["c4.large", "m5.xlarge", "m5.2xlarge"]
}
},
"Resources":{
"MySpotFleet":{
"Type":"AWS::EC2::SpotFleet",
"Properties":{
"SpotFleetRequestConfigData":{
"IamFleetRole": { "Fn::Sub": "arn:aws:iam::${AWS::AccountId}:role/aws-ec2-spot-fleet-tagging-role" },
"AllocationStrategy": "lowestPrice",
"TargetCapacity": 1,
"SpotPrice": "2.105",
"Type":"maintain",
"LaunchSpecifications": [
{
"ImageId": {"Ref": "LatestAmiId"},
"InstanceType": {"Ref": "InstanceType"},
"SpotPrice": "2.105",
"NetworkInterfaces": [
{
"DeviceIndex": 0,
"SubnetId": { "Ref" : "OksoftSubnet" } ,
"Groups": [ { "Ref" : "OksoftSG" } ],
"AssociatePublicIpAddress": true
}
],
"KeyName" : { "Ref" : "KeyName" },
"BlockDeviceMappings": [
{
"DeviceName": "/dev/xvda",
"Ebs": {
"DeleteOnTermination": true,
"VolumeType": "standard",
"VolumeSize": 400
}
}
],
"UserData":{
"Fn::Base64":{
"Fn::Sub":"#!/bin/bash -xe\n
yum install -y docker mysql git python-pip > /tmp/line1_succ.txt 2> /tmp/line1_err.txt\n
service docker start > /tmp/line2_succ.txt 2> /tmp/line2_err.txt \n
docker run -d -p 8887:8888 -v /tmp:/tmp shantanuo/notebook > /tmp/line3_succ.txt 2> /tmp/line3_err.txt \n
pip install aws-ec2-assign-elastic-ip > /tmp/line4_succ.txt 2> /tmp/line4_err.txt \n
/usr/local/bin/aws-ec2-assign-elastic-ip --access-key !Ref Oksoftaccess --secret-key !Ref Oksoftsecret --valid-ips 35.174.198.170 > /tmp/line5_succ.txt 2> /tmp/line5_err.txt \n "
}
}
}
]
}
}
}
}
}