Skip to content

Instantly share code, notes, and snippets.

@overnew
Created March 25, 2024 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save overnew/1e5282dc13c30ce0284d99cacf6841d9 to your computer and use it in GitHub Desktop.
Save overnew/1e5282dc13c30ce0284d99cacf6841d9 to your computer and use it in GitHub Desktop.
CloudFormation.yaml
AWSTemplateFormatVersion: 2010-09-09
Description: Deploy VPC
Resources:
PublicSubnet:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC #VPC의 ID를 참조
CidrBlock: 10.0.0.0/24 #VPC 네트워크 내의 CIDR 주소를 선택
AvailabilityZone: !Select #!Select는 함수로, 리전 내의 가용 영역을 검색
- '0' # 검색된 영역 중에 첫번째를 선택
- !GetAZs '' # 첫번째 AZ를 참조
Tags:
- Key: Name
Value: Public Subnet
#public 서브넷은 IGW로의 경로를 설정해야 하므로 일단 생성
PublicRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: Public Route Table
PublicRoute: # 라우팅 테이블에 경로를 추가
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: 0.0.0.0/0 #모든 IP를
GatewayId: !Ref InternetGateway #IGW로
PublicSubnetRouteTableAssociation: # 라우팅 테이블을 subnet과 연결
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet
RouteTableId: !Ref PublicRouteTable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment