🔥

AWS CloudFormationテンプレートによるインフラ構築(VPC,サブネット)

2024/05/08に公開

以前書いた"AWS Hands-on for Beginners - Network編#1"をAWS CLIで構築する1をAWS CloudFormationテンプレートによるインフラ構築。

参考


https://zenn.dev/soshimiyamoto/articles/3c624728438902
https://dev.classmethod.jp/articles/re-introducation-2022-aws-cloudformation/
https://dev.classmethod.jp/articles/cloudformation-beginner01/


AWSTemplateFormatVersion: '2010-09-09'
Resources:
  Handson:
    Type: 'AWS::EC2::VPC'
    Properties:
      CidrBlock: 10.0.0.0/16
      EnableDnsSupport: true
      EnableDnsHostnames: true
      InstanceTenancy: default
      Tags:
        - Key: Name
          Value: handson
  PublicSubnet1a:
    Type: 'AWS::EC2::Subnet'
    Properties:
      VpcId: !Ref Handson
      CidrBlock: 10.0.1.0/24
      AvailabilityZone: ap-northeast-1a
      MapPublicIpOnLaunch: true
      Tags:
        - Key: Name
          Value: Public-subnet-a
  PublicSubnet1c:
    Type: 'AWS::EC2::Subnet'
    Properties:
      VpcId: !Ref Handson
      CidrBlock: 10.0.2.0/24
      AvailabilityZone: ap-northeast-1c
      MapPublicIpOnLaunch: true
      Tags:
        - Key: Name
          Value: Public-subnet-c
  PrivateSubnet1a:
    Type: 'AWS::EC2::Subnet'
    Properties:
      VpcId: !Ref Handson
      CidrBlock: 10.0.11.0/24
      AvailabilityZone: ap-northeast-1a
      Tags:
        - Key: Name
          Value: Private-subnet-a
  PrivateSubnet1c:
    Type: 'AWS::EC2::Subnet'
    Properties:
      VpcId: !Ref Handson
      CidrBlock: 10.0.12.0/24
      AvailabilityZone: ap-northeast-1c
      Tags:
        - Key: Name
          Value: Private-subnet-c

Discussion