LoginSignup
0
0

More than 3 years have passed since last update.

CloudFormationでVPCを作成する

Last updated at Posted at 2021-05-04

概要

CloudFormationを使ってみたかったので、試しにVPCを作成してみます。

作成するもの

  • VPC
  • サブネット

テンプレート

AWSTemplateFormatVersion: 2010-09-09
Description: >-
  CloudFormationでVPC, subnetを作成します
Resources:
  VPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: 172.16.1.0/24
      EnableDnsSupport: true
      Tags:
        - Key: Name
          Value: VPC-name
  subnet1a:
    Type: AWS::EC2::Subnet
    Properties:
      AvailabilityZone: "ap-northeast-1a"
      VpcId: 
        Ref: VPC
      CidrBlock: 172.16.1.0/26
      Tags:
        - Key: Name
          Value: subnet-1a
  subnet1c:
    Type: AWS::EC2::Subnet
    Properties:
      AvailabilityZone: "ap-northeast-1c"
      VpcId: 
        Ref: VPC
      CidrBlock: 172.16.1.64/26
      Tags:
        - Key: Name
          Value: subnet-1c

雑感

NATゲートウェイやルートテーブルも設定したいですね。
セキュリティグループは用途次第なので、作るリソースに合わせて作成ですかね。
たとえば、RDSならDBのポートを開けるとか。

資料

テンプレートを作る際のリファレンスはこちらです。
日本語だと情報がうまく出ないので英語を指定します。
https://docs.aws.amazon.com/en_us/AWSCloudFormation/latest/UserGuide/template-reference.html

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0