Skip to content

Instantly share code, notes, and snippets.

@msato0731
Last active July 6, 2018 23:28
Show Gist options
  • Save msato0731/2df080b84a6bf91fea7cab5fe1810a17 to your computer and use it in GitHub Desktop.
Save msato0731/2df080b84a6bf91fea7cab5fe1810a17 to your computer and use it in GitHub Desktop.
# VPC
AWSTemplateFormatVersion: 2010-09-09
Resources:
VPC:
Type: "AWS::EC2::VPC"
Properties:
CidrBlock: 10.0.0.0/16
EnableDnsSupport: true
EnableDnsHostnames: true
InstanceTenancy: "default"
Tags:
- Key: Name
Value: cfn-test-VPC
PublicSubnet1:
Type: 'AWS::EC2::Subnet'
Properties:
CidrBlock: 10.0.1.0/24
MapPublicIpOnLaunch: false
AvailabilityZone: ap-northeast-1a
Tags:
- Key: Name
Value: cfn-test-PublicSubnet1
VpcId: !Ref VPC
Outputs:
MyVPC:
Value: !Ref VPC
Export:
Name: cfn-test-VPC
PublicSubnet1:
Value: !Ref PublicSubnet1
Export:
Name: cfn-test-PublicSubnet1
# SecurityGroup
AWSTemplateFormatVersion: 2010-09-09
Resources:
# WEBServer SecurityGroup
SecurityGroupForWeb:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupName: cfn-test-Web-SG
GroupDescription: >-
SG for Web Server
# Inbound SecurityGroup
SecurityGroupIngress:
- CidrIp: 0.0.0.0/0
Description: SSH
FromPort: 22
IpProtocol: tcp
ToPort: 22
- CidrIp: 0.0.0.0/0
Description: HTTP
FromPort: 80
IpProtocol: tcp
ToPort: 80
- CidrIp: 0.0.0.0/0
Description: HTTPS
FromPort: 443
IpProtocol: tcp
ToPort: 443
VpcId: !ImportValue 'cfn-test-VPC'
Tags:
- Key: Name
Value: cfn-test-Web-SG
Outputs:
SecurityGroupForWeb:
Value: !Ref SecurityGroupForWeb
Export:
Name: cfn-test-Web-SG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment