-
Notifications
You must be signed in to change notification settings - Fork 0
/
singleinstance.yaml
141 lines (138 loc) · 4.02 KB
/
singleinstance.yaml
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
AWSTemplateFormatVersion: 2010-09-09
Description: >-
Single EC2 CloudFormation Templates.
Parameters:
VpcId:
Type: 'AWS::EC2::VPC::Id'
Description: VpcId of your existing Virtual Private Cloud (VPC)
ConstraintDescription: must be the VPC Id of an existing Virtual Private Cloud.
Subnets:
Type: 'AWS::EC2::Subnet::Id'
Description: The list of SubnetIds in your Virtual Private Cloud (VPC)
ConstraintDescription: >-
must be a list of at least two existing subnets associated with at least
two different availability zones. They should be residing in the selected
Virtual Private Cloud.
InstanceType:
Description: Ant Media Server EC2 instance type
Type: String
Default: t2.large
AllowedValues:
- t2.large
- t2.xlarge
- t2.2xlarge
- m5.large
- m5.xlarge
- m5.2xlarge
- m5.4xlarge
- m5.12xlarge
- m5.24xlarge
- m4.large
- m4.xlarge
- m4.2xlarge
- m4.4xlarge
- m4.10xlarge
- m4.16xlarge
- c5d.large
- c5d.xlarge
- c5d.2xlarge
- c5d.4xlarge
- c5d.9xlarge
- c5d.18xlarge
- c5.large
- c5.xlarge
- c5.2xlarge
- c5.4xlarge
- c5.9xlarge
- c5.12xlarge
- c5.18xlarge
- c5.24xlarge
- c4.large
- c4.xlarge
- c4.2xlarge
- c4.4xlarge
- c4.8xlarge
ConstraintDescription: must be a valid EC2 instance type.
KeyName:
Description: Name of an existing EC2 KeyPair to enable SSH access to the instances
Type: 'AWS::EC2::KeyPair::KeyName'
MinLength: '1'
MaxLength: '255'
AllowedPattern: '[\x20-\x7E]*'
ConstraintDescription: can contain only ASCII characters.
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.
ElasticIPAddress:
Description: If you want to assign an Elastic IP Address, please select True
Default: false
Type: String
AllowedValues:
- true
- false
ImageID:
Description: ImageID
Type: String
ConstraintDescription: must be a valid Image Id
Conditions:
CreateIP: !Equals
- !Ref ElasticIPAddress
- true
Resources:
TestSecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
VpcId: !Ref VpcId
GroupDescription: Test SecurityGroup
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
CidrIp: 0.0.0.0/0
TestInstance:
Type: 'AWS::EC2::Instance'
Properties:
KeyName: !Ref KeyName
ImageId: !Ref ImageID
InstanceType: !Ref InstanceType
SubnetId: !Ref Subnets
SecurityGroupIds:
- !GetAtt TestSecurityGroup.GroupId
Tags:
- Key: Name
Value: ${AWS::StackName}
UserData:
Fn::Base64: !Sub |
#!/bin/bash
apt-get update
apt-get install -y python-pip
apt-get install -y python-setuptools
mkdir -p /opt/aws/bin
python /usr/lib/python2.7/dist-packages/easy_install.py --script-dir /opt/aws/bin https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource TestInstance --region ${AWS::Region}
ElasticIP:
Type: AWS::EC2::EIP
Condition: CreateIP
Properties:
Domain: "vpc"
ElasticIPAssignment:
Type: AWS::EC2::EIPAssociation
Condition: CreateIP
Properties:
EIP: !Ref ElasticIP
InstanceId: !Ref TestInstance
Outputs:
InstanceElasticIP:
Description: Elastic IP Address
Condition: CreateIP
Value: !Ref ElasticIP
PublicIPV4:
Description: Public IP Address
Value: !GetAtt TestInstance.PublicIp
Export:
Name: !Sub "${AWS::StackName}-PublicIp"