-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab11.yaml
89 lines (78 loc) · 2.15 KB
/
lab11.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
Description: SPL-200
# Creates "Jingru's VPC" with an EC2 instance in us-west-2
Resources:
JingrusVPC:
Type: AWS::EC2::VPC
Properties:
EnableDnsHostnames: true
EnableDnsSupport: true
CidrBlock: 10.0.0.0/16
Tags:
- Key: Name
Value: Jingru's VPC
InternetGateway:
Type: AWS::EC2::InternetGateway
AttachGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref JingrusVPC
InternetGatewayId: !Ref InternetGateway
JingrusSubnet1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref JingrusVPC
MapPublicIpOnLaunch: true
CidrBlock: 10.0.1.0/24
AvailabilityZone: !Select
- "0"
- !GetAZs "us-west-2"
Tags:
- Key: Name
Value: Public Subnet 1
JingrusRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref JingrusVPC
Tags:
- Key: Name
Value: Route table for subnets
PublicRoute:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref JingrusRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
Subnet1RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref JingrusSubnet1
RouteTableId: !Ref JingrusRouteTable
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Security group for EC2 instance
VpcId: !Ref JingrusVPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
EC2Instance:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-00970f57473724c10
InstanceType: t3.micro
SecurityGroupIds:
- !Ref SecurityGroup
SubnetId: !Ref JingrusSubnet1
UserData:
Fn::Base64: !Sub |
#!/bin/bash
yum -y install httpd
systemctl enable httpd
systemctl start httpd
echo "<html><body><h1>Hello from <b>Jingru's</b> web server</h1></body></html>" > /var/www/html/index.html
# Outputs:
# EC2InstanceId:
# Description: The ID of the EC2 instance
# Value: !Ref EC2Instance