0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

aws CloudFomationで簡単なネットワークを作成してみた

Posted at

概要

下記の図の基本的なネットワーク構成をCloudfFomationで作成してみました。

スクリーンショット 2025-10-12 211221.png

流れ

  • テンプレート作成
  • スタック構築
  • 更新
  • 削除

テンプレート内容

  • 値を替えて使ってみて下さい。
AWSTemplateFormatVersion: '2010-09-09'
Description: test-vpc構成テンプレート

Resources:
  TestVPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: 10.0.0.0/21
      EnableDnsSupport: true
      EnableDnsHostnames: true
      InstanceTenancy: default
      Tags:
        - Key: Name
          Value: test-vpc

  TestInternetGateway:
    Type: AWS::EC2::InternetGateway
    Properties:
      Tags:
        - Key: Name
          Value: test-internetgatway

  AttachInternetGateway:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId: !Ref TestVPC
      InternetGatewayId: !Ref TestInternetGateway

  TestSubnet0:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId: !Ref TestVPC
      CidrBlock: 10.0.0.0/24
      AvailabilityZone: ap-northeast-1a
      Tags:
        - Key: Name
          Value: test-subnet-0

  TestSubnet2:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId: !Ref TestVPC
      CidrBlock: 10.0.2.0/24
      AvailabilityZone: ap-northeast-1a
      Tags:
        - Key: Name
          Value: test-subnet-2

  RouteTableSubnet0:
    Type: AWS::EC2::RouteTable
    Properties:
      VpcId: !Ref TestVPC
      Tags:
        - Key: Name
          Value: rtb-subnet-0

  RouteToInternetSubnet0:
    Type: AWS::EC2::Route
    Properties:
      RouteTableId: !Ref RouteTableSubnet0
      DestinationCidrBlock: 0.0.0.0/0
      GatewayId: !Ref TestInternetGateway

  Subnet0RouteTableAssociation:
    Type: AWS::EC2::SubnetRouteTableAssociation
    Properties:
      SubnetId: !Ref TestSubnet0
      RouteTableId: !Ref RouteTableSubnet0

  RouteTableSubnet2:
    Type: AWS::EC2::RouteTable
    Properties:
      VpcId: !Ref TestVPC
      Tags:
        - Key: Name
          Value: rtb-subnet-2

  Subnet2RouteTableAssociation:
    Type: AWS::EC2::SubnetRouteTableAssociation
    Properties:
      SubnetId: !Ref TestSubnet2
      RouteTableId: !Ref RouteTableSubnet2

スタック構築

  • 検索欄からCloudFomationを検索し、選択。
    スタックの作成を押下する。

作成したテンプレートのymlをアップロードし、スタック名を入力し、「送信」を押下する。

スクリーンショット 2025-10-12 214739.png
スクリーンショット 2025-10-12 214805.png
image.png

  • あっという間に作成完了です。
    image.png
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?