-
Notifications
You must be signed in to change notification settings - Fork 0
/
instance.yaml
78 lines (74 loc) · 1.88 KB
/
instance.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
AWSTemplateFormatVersion: '2010-09-09'
Description: Single instance
Parameters:
AmiId:
Description: AMI for the EC2 Instance
Default: ami-b968bad6
Type: 'AWS::EC2::Image::Id'
Environment:
AllowedValues:
- stage
- prod
Default: stage
Type: String
InstanceType:
AllowedValues:
- t2.small
- t2.medium
Description: Instance Type
Default: "t2.small"
Type: String
KeyName:
Default: sustbmat
Description: Access key name
Type: 'AWS::EC2::KeyPair::KeyName'
SubnetId:
Default: subnet-1148e779
Description: Subnet ID for the Availability Zone
Type: 'AWS::EC2::Subnet::Id'
VpcId:
Default: vpc-0b07ec63
Description: VPC ID for the Security Group
Type: 'AWS::EC2::VPC::Id'
Resources:
Instance:
Type: "AWS::EC2::Instance"
Properties:
ImageId: !Ref AmiId
InstanceType: !Ref InstanceType
KeyName: !Ref KeyName
NetworkInterfaces:
- AssociatePublicIpAddress: true
DeleteOnTermination: true
DeviceIndex: 0
GroupSet: [ !Ref SecurityGroup ]
SubnetId: !Ref SubnetId
Tags:
- Key: Name
Value: !Join [ "-", [ "demo", !Ref Environment ] ]
SecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupDescription: "demo-instance"
Tags:
- Key: Name
Value: !Join [ "-", [ "demo", !Ref Environment ] ]
VpcId: !Ref VpcId
SSHInFromInternet:
Type: "AWS::EC2::SecurityGroupIngress"
Properties:
CidrIp: "0.0.0.0/0"
FromPort: 22
GroupId: !Ref SecurityGroup
IpProtocol: tcp
ToPort: 22
Outputs:
InstanceId:
Description: Id
Value: !Ref Instance
PrivateDnsName:
Description: Internal DNS name in VPC
Value: !GetAtt [Instance, PrivateDnsName]
PrivateIp:
Description: Private IP address in VPC
Value: !GetAtt [Instance, PrivateIp]