-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathinstance-and-security-group.yml
78 lines (63 loc) · 1.76 KB
/
instance-and-security-group.yml
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
Description: >
Template for creating a single ec2 instance and an attached security group. Also allows you to specify existing security groups to attach.
Parameters:
InstanceName:
Description: The name tag for the instance
Type: String
VPC:
Type: AWS::EC2::VPC::Id
Description: Choose which VPC the security group should be deployed to
Subnet:
Description: The subnet in which to deploy the instance
Type: AWS::EC2::Subnet::Id
Contact:
Description: Contact email
Default: [email protected]
Type: String
Keyname:
Description: Key to provision for SSHing into the ec2 instance
Type: AWS::EC2::KeyPair::KeyName
InstanceAMI:
Description: AMI for the instance
Type: String
InstanceType:
Description: what instance type the ec2 instance should use
Default: t2.nano
AllowedValues:
- t2.nano
- t2.micro
- t2.small
Type: String
Resources:
MySecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow world SSH access to this instance.
VpcId: !Ref VPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '443'
ToPort: '443'
CidrIp: 0.0.0.0/0
MyInstance:
Type: AWS::EC2::Instance
Properties:
ImageId:
Ref: InstanceAMI
InstanceType:
Ref: InstanceType
SecurityGroupIds:
- Ref: MySecurityGroup
KeyName:
Ref: Keyname
SubnetId:
Ref: Subnet
Tags:
- Key: Contact
Value: !Ref Contact
- Key: Name
Value: !Ref InstanceName
Outputs:
InstanceID:
Description: The Instance ID
Value: !Ref MyInstance