Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CloudFormationを用いた簡単なAWSネットワーク構築.pdf

 CloudFormationを用いた簡単なAWSネットワーク構築.pdf

AWS CloudFormationを用いた簡単なAWSネットワーク構築方法及び、プロビジョニング時の躓きを共有する資料です。

Avatar for Shun Kawamoto

Shun Kawamoto

February 25, 2025
Tweet

More Decks by Shun Kawamoto

Other Decks in Technology

Transcript

  1. © JSOL CORPORATION 2 自己紹介 河本 瞬(かわもと しゅん) プラットフォーム事業本部 プラットフォームビジネス部

    SAP basis・インフラ領域を担当 社会人歴:1年目(現場配属3か月) 好きなAWSのサービス:Amazon Route 53 趣味:筋トレ、カメラ
  2. © JSOL CORPORATION 10 現場配属後の業務 2か月目 できました! ありがとうございます! 次はCloudFormationで これをプロビジョニング

    してください。 承知しました! CloudFormationを用いたリソースの作成 (いきなりCloudFormationか...。難しそうやな...。)
  3. © JSOL CORPORATION 12 CloudFormationとは • 設定ファイル(テンプレート)を元にAWSの構築を自動化できるサービス • テンプレートにはJSONやYAML形式でリソースの情報を記述する •

    作成したリソースの集合体をスタックという単位で管理できる Templateに作成する リソースを定義 ClourdFormation Templateの解釈 AWSリソースを操作 (作成/変更/削除) Stack リソースを集合体と してまとめて管理
  4. © JSOL CORPORATION 13 CloudFormationでAWSネットワークを作成 Virtual private cloud (VPC) AZ:ap-northeast-1a

    Public subnet RouteTable 構成図 • Virturl private cloud (VPC) • Public subnet • Route table • Internet gateway Internet gateway
  5. © JSOL CORPORATION 14 CloudFormationでAWSネットワークを作成 テンプレート AWSTemplateFormatVersion: "2010-09-09" Description: "CloudFormation

    template for a VPC with Multi-AZ subnets and VPC Endpoint." #VPC作成 Resources: VPC: Type: "AWS::EC2::VPC" Properties: CidrBlock: "10.0.0.0/16" #サブネット作成 Subnet: Type: "AWS::EC2::Subnet" Properties: VpcId: !Ref VPC CidrBlock: "10.0.1.0/24" AvailabilityZone: "ap-northeast-1a" #インターネットゲートウェイ作成 InternetGateway: Type: AWS::EC2::InternetGateway Properties: Tags: - Key: Name Value: MyInternetGateway VPCGatewayAttachment: Type: AWS::EC2::VPCGatewayAttachment Properties: VpcId: !Ref VPC InternetGatewayId: !Ref InternetGateway #ルートテーブル作成 RouteTable: Type: "AWS::EC2::RouteTable" Properties: VpcId: !Ref VPC #ルート追加 #インターネットへのルートを追加 RouteAZ1Internet: Type: "AWS::EC2::Route" Properties: RouteTableId: !Ref RouteTable DestinationCidrBlock: "0.0.0.0/0" GatewayId: !Ref InternetGateway VPCGatewayEndpoint: Type: "AWS::EC2::VPCEndpoint" Properties: VpcId: !Ref VPC ServiceName: "com.amazonaws.ap-northeast-1.s3" RouteTableIds: - !Ref RouteTable #ルートテーブルをサブネットに紐づける SubnetRouteTableAssociationAZ1: Type: "AWS::EC2::SubnetRouteTableAssociation" Properties: SubnetId: !Ref Subnet RouteTableId: !Ref RouteTable
  6. © JSOL CORPORATION 15 CloudFormationでAWSネットワークを作成 テンプレート AWSTemplateFormatVersion: "2010-09-09" Description: "CloudFormation

    template for a VPC with Multi-AZ subnets and VPC Endpoint." #VPC作成 Resources: VPC: Type: "AWS::EC2::VPC" Properties: CidrBlock: "10.0.0.0/16" #サブネット作成 Subnet: Type: "AWS::EC2::Subnet" Properties: VpcId: !Ref VPC CidrBlock: "10.0.1.0/24" AvailabilityZone: "ap-northeast-1a" #インターネットゲートウェイ作成 InternetGateway: Type: AWS::EC2::InternetGateway Properties: Tags: - Key: Name Value: MyInternetGateway VPCGatewayAttachment: Type: AWS::EC2::VPCGatewayAttachment Properties: VpcId: !Ref VPC InternetGatewayId: !Ref InternetGateway #ルートテーブル作成 RouteTable: Type: "AWS::EC2::RouteTable" Properties: VpcId: !Ref VPC #ルート追加 #インターネットへのルートを追加 RouteAZ1Internet: Type: "AWS::EC2::Route" Properties: RouteTableId: !Ref RouteTable DestinationCidrBlock: "0.0.0.0/0" GatewayId: !Ref InternetGateway VPCGatewayEndpoint: Type: "AWS::EC2::VPCEndpoint" Properties: VpcId: !Ref VPC ServiceName: "com.amazonaws.ap-northeast-1.s3" RouteTableIds: - !Ref RouteTable #ルートテーブルをサブネットに紐づける SubnetRouteTableAssociationAZ1: Type: "AWS::EC2::SubnetRouteTableAssociation" Properties: SubnetId: !Ref Subnet RouteTableId: !Ref RouteTable ちょっと難易度が高いのでは
  7. © JSOL CORPORATION 24 スタック作成時のエラー どうやらルートテーブル関連でリソースに重複があるとのこと (Resource handler returned message

    :”Already Exsists”) 実業務での最初のスタック作成ではエラーが発生... 解決に約1時間を要してしまった。