This repository has been archived by the owner on Apr 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
automation_host_cft-w-existing-vpc.json
165 lines (162 loc) · 6.7 KB
/
automation_host_cft-w-existing-vpc.json
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Creates an Amazon EC2 instance running the F5 AWS Deployments AMI. The AMI is chosen based on the region in which the stack is run. This example creates an EC2 security group for the instance to give you SSH access. **WARNING** This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters" : {
"KeyName": {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance",
"Type": "AWS::EC2::KeyPair::KeyName",
"ConstraintDescription" : "must be the name of an existing EC2 KeyPair."
},
"VPC": {
"Type": "AWS::EC2::VPC::Id",
"Default" : "vpc-56f85232",
"ConstraintDescription": "Must be an existing VPC within working region."
},
"Subnet": {
"Description": "SubnetID of existing subnet for Automation Host",
"Type": "AWS::EC2::Subnet::Id",
"Default" : "subnet-fd0ee18b",
"ConstraintDescription": "Must be an existing subnet"
},
"InstanceType" : {
"Description" : "Automation Host EC2 instance type",
"Type" : "String",
"Default" : "m3.large",
"AllowedValues" : [ "t1.micro", "t2.micro", "t2.small", "t2.medium", "m1.small", "m1.medium", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "m3.medium", "m3.large", "m3.xlarge", "m3.2xlarge", "c1.medium", "c1.xlarge", "c3.large", "c3.xlarge", "c3.2xlarge", "c3.4xlarge", "c3.8xlarge", "c4.large", "c4.xlarge", "c4.2xlarge", "c4.4xlarge", "c4.8xlarge", "g2.2xlarge", "r3.large", "r3.xlarge", "r3.2xlarge", "r3.4xlarge", "r3.8xlarge", "i2.xlarge", "i2.2xlarge", "i2.4xlarge", "i2.8xlarge", "d2.xlarge", "d2.2xlarge", "d2.4xlarge", "d2.8xlarge", "hi1.4xlarge", "hs1.8xlarge", "cr1.8xlarge", "cc2.8xlarge", "cg1.4xlarge"]
,
"ConstraintDescription" : "must be a valid EC2 instance type."
},
"SSHLocation" : {
"Description" : "The IP address range that can be used to SSH to the EC2 instances",
"Type": "String",
"MinLength": "9",
"MaxLength": "18",
"Default": "0.0.0.0/0",
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
}
},
"Mappings" : {
"AWSRegionArch2AMI": {
"us-east-1": {
"AMI": "ami-63efbd06"
},
"us-west-1": {
"AMI": "ami-eba86baf"
},
"us-west-2": {
"AMI": "ami-f638dbc5"
},
"eu-west-1": {
"AMI": "ami-f3b98584"
},
"ap-southeast-2": {
"AMI": "ami-098dc733"
},
"ap-northeast-1": {
"AMI": "ami-28bbd928"
}
}
},
"Resources" : {
"EC2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"InstanceType" : { "Ref" : "InstanceType" },
"KeyName" : { "Ref" : "KeyName" },
"ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" }, "AMI" ] },
"NetworkInterfaces" : [{
"GroupSet" : [{ "Ref" : "InstanceSecurityGroup" }],
"AssociatePublicIpAddress" : "true",
"DeviceIndex" : "0",
"DeleteOnTermination" : "true",
"SubnetId" : { "Ref" : "Subnet" }
}],
"UserData": {
"Fn::Base64": {
"Fn::Join": [ "\n",
[
"#!/bin/bash",
"#cloud-init is run as run as root so need to change dirs/permissions/etc",
"cd /home/ubuntu",
"#setup the bash file for first login",
"if ! egrep activate /home/ubuntu/.bash_profile ; then echo 'source venv/bin/activate' >> /home/ubuntu/.bash_profile; fi",
"if ! egrep aws-deployments /home/ubuntu/.bash_profile ; then echo 'cd aws-deployments' >> /home/ubuntu/.bash_profile; fi",
"# make sure the virtual environment is active",
"source /home/ubuntu/venv/bin/activate",
"# clone the latest code",
"git clone https://github.com/F5Networks/aws-deployments.git",
"# change into the directory",
"cd aws-deployments",
"# check out the sales_demo branch",
"git fetch",
"git checkout sales_demo",
"# install the latest python module requirements",
"pip install -r requirements.txt",
"# copy over the basic setup files",
"cp ./build/files/.f5aws /home/ubuntu/",
"cp -r ./build/files/.aws /home/ubuntu/",
"cp -r ./lab /home/ubuntu/",
"cd ./src",
"python setup.py install",
"cd ../",
"chown -R ubuntu.ubuntu /home/ubuntu/*",
"chown -R ubuntu.ubuntu /home/ubuntu/.*"
]]
}
},
"Tags": [
{
"Key": "Name",
"Value": {
"Ref": "AWS::StackName"
}
}
]
}
},
"InstanceSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable SSH access via port 22",
"VpcId": { "Ref": "VPC" },
"SecurityGroupIngress" : [ {
"IpProtocol" : "tcp",
"FromPort" : "22",
"ToPort" : "22",
"CidrIp" : { "Ref" : "SSHLocation"}
} ],
"Tags": [
{
"Key": "Application",
"Value": {
"Ref": "AWS::StackName"
}
}
]
}
}
},
"Outputs" : {
"InstanceId" : {
"Description" : "InstanceId of the newly created EC2 instance",
"Value" : { "Ref" : "EC2Instance" }
},
"AZ" : {
"Description" : "Availability Zone of the newly created EC2 instance",
"Value" : { "Fn::GetAtt" : [ "EC2Instance", "AvailabilityZone" ] }
},
"PrivateIP" : {
"Description" : "Private IP address of the newly created EC2 instance",
"Value" : { "Fn::GetAtt" : [ "EC2Instance", "PrivateIp" ] }
},
"PublicDNS" : {
"Description" : "Public DNSName of the newly created EC2 instance",
"Value" : { "Fn::GetAtt" : [ "EC2Instance", "PublicDnsName" ] }
},
"PublicIP" : {
"Description" : "Public IP address of the newly created EC2 instance",
"Value" : { "Fn::GetAtt" : [ "EC2Instance", "PublicIp" ] }
}
}
}