Created
September 25, 2019 06:07
-
-
Save msoe/d904769f330cd14ba0ee1351cdfe7630 to your computer and use it in GitHub Desktop.
My Lab Stack for a Single Web Server Cloudformation Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A web server (ports 80, 22 opened) | |
# on a subnet 10.1.10.0/24 | |
# in a VPC 10.1.0.0/16 | |
# in Region us-east-1a (N Virginia) | |
# Change the source IP in WebSecurityGroup to your testing IP, line 83 and 88 | |
# Change the SSH key to yours on line 98 | |
AWSTemplateFormatVersion: "2010-09-09" | |
Resources: | |
LabVPC: | |
Type: AWS::EC2::VPC | |
Properties: | |
CidrBlock: 10.1.0.0/16 | |
EnableDnsHostnames: true | |
EnableDnsSupport: true | |
Tags: | |
- Key: Name | |
Value: my-lab-vpc | |
PublicSubnet: | |
Type: AWS::EC2::Subnet | |
Properties: | |
VpcId: | |
Ref: LabVPC | |
CidrBlock: 10.1.10.0/24 | |
MapPublicIpOnLaunch: true | |
Tags: | |
- Key: Name | |
Value: my-lab-public-subnet | |
InternetGateway: | |
Type: AWS::EC2::InternetGateway | |
Properties: | |
Tags: | |
- Key: Name | |
Value: my-lab-igw | |
AttachGateway: | |
Type: AWS::EC2::VPCGatewayAttachment | |
Properties: | |
VpcId: | |
Ref: LabVPC | |
InternetGatewayId: | |
Ref: InternetGateway | |
LabPublicRouteTable: | |
Type: AWS::EC2::RouteTable | |
Properties: | |
VpcId: | |
Ref: LabVPC | |
Tags: | |
- Key: Name | |
Value: my-lab-public-rt | |
AttachInternetGatewayToRouteTable: | |
Type: AWS::EC2::Route | |
Properties: | |
RouteTableId: | |
Ref: LabPublicRouteTable | |
DestinationCidrBlock: 0.0.0.0/0 | |
GatewayId: | |
Ref: InternetGateway | |
AssociateSubnet: | |
Type: AWS::EC2::SubnetRouteTableAssociation | |
Properties: | |
RouteTableId: | |
Ref: LabPublicRouteTable | |
SubnetId: | |
Ref: PublicSubnet | |
WebServerSecurityGroup: | |
Type: AWS::EC2::SecurityGroup | |
Properties: | |
GroupDescription: SecurityGroup for Lab Web Server | |
GroupName: Lab Web Servers | |
VpcId: | |
Ref: LabVPC | |
SecurityGroupIngress: | |
- IpProtocol: tcp | |
FromPort: 80 | |
ToPort: 80 | |
CidrIp: 0.0.0.0/0 | |
- IpProtocol: tcp | |
FromPort: 22 | |
ToPort: 22 | |
CidrIp: 0.0.0.0/0 | |
Tags: | |
- Key: Name | |
Value: my-lab-web-sg | |
LaunchWebServerInstance: | |
Type: AWS::EC2::Instance | |
Properties: | |
ImageId: ami-0b69ea66ff7391e80 | |
KeyName: my-keypair-for-lab | |
InstanceType: t2.micro | |
SecurityGroupIds: | |
- !GetAtt "WebServerSecurityGroup.GroupId" | |
SubnetId: | |
Ref: PublicSubnet | |
Tags: | |
- Key: Name | |
Value: my-lab-web-server |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment