[CloudFormation] 閉域の1VPC・1サブネット構成


1つのVPCを作成し、1つのサブネットを入れた構成です。
インターネットからアクセスしない最低限の環境になっています。

AWSTemplateFormatVersion: '2010-09-09'
Description: Create a VPC with Subnet and related networking components

Resources:
  MyVPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: '10.0.0.0/16'
      EnableDnsSupport: 'true'
      EnableDnsHostnames: 'true'
      Tags:
        - Key: Name
          Value: MyVPC

  MySubnet:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId: !Ref MyVPC
      CidrBlock: '10.0.1.0/24'
      Tags:
        - Key: Name
          Value: MySubnet

  MyRouteTable:
    Type: AWS::EC2::RouteTable
    Properties:
      VpcId: !Ref MyVPC
      Tags:
        - Key: Name
          Value: MyRouteTable

  SubnetRouteTableAssociation:
    Type: AWS::EC2::SubnetRouteTableAssociation
    Properties:
      SubnetId: !Ref MySubnet
      RouteTableId: !Ref MyRouteTable

Outputs:
  VpcId:
    Description: VPC ID
    Value: !Ref MyVPC
    Export:
      Name: VpcId

  VpcCIDR:
    Description: VPC CIDR Block
    Value: !GetAtt MyVPC.CidrBlock
    Export:
      Name: VpcCIDR

  RouteTableId:
    Description: Route Table ID
    Value: !Ref MyRouteTable
    Export:
      Name: RouteTableId

  SubnetId:
    Description: Subnet ID
    Value: !Ref MySubnet
    Export:
      Name: SubnetId

AWSCloudFormation

Posted by kidatti