LoginSignup
1
0

More than 5 years have passed since last update.

メモ:【AWS】CloudFormationでVPCをつくる

Posted at

AWS CloudFormation テンプレートの構造とセクション

前提知識

以下にテンプレートの例を示す。

JSON

{
  "AWSTemplateFormatVersion" : "version date",

  "Description" : "JSON string",

  "Metadata" : {
    template metadata
  },

  "Parameters" : {
    set of parameters
  },

  "Mappings" : {
    set of mappings
  },

  "Conditions" : {
    set of conditions
  },

  "Transform" : {
    set of transforms
  },

  "Resources" : {
    set of resources
  },

  "Outputs" : {
    set of outputs
  }
}

YAML

AWSTemplateFormatVersion: "version date"

Description:
  String

Metadata:
  template metadata

Parameters:
  set of parameters

Mappings:
  set of mappings

Conditions:
  set of conditions

Transform:
  set of transforms

Resources:
  set of resources

Outputs:
  set of outputs

テンプレートセクション

Format Version (任意)
 現時点で最新は 2010-09-09
Description (任意)
 このセクションは、必ずテンプレートの Format Version セクションの後に記述する必要がある。
Metadata (任意)
 追加情報
Parameters (任意)
 テンプレートに渡すことができる値
Mappings (任意)
 条件パラメーター値の指定に使用できる、キーと関連する値のマッピング
Conditions (任意)
 条件付きのリソースを作成できる
Transform (任意)
 使用できる構文と、その処理方法を定義する
Resources (必須)
 スタックリソースとそのプロパティを指定する
Outputs (任意)
 スタックのプロパティを確認すると返される値

VPCをつくる

以下にテストしたコードを示す。

JSON

{
  "AWSTemplateFormatVersion" : "2010-09-09",

  "Description" : "JSON sample VPC",

  "Resources" : {
    "sampleVPC" : {
      "Type" : "AWS::EC2::VPC",
      "Properties" : {
        "CidrBlock" : "10.0.0.0/16",
        "Tags" : [
          { "Key" : "Name", "Value" : "sampleName" }
        ]
      }
    }
  }
}

YAML

AWSTemplateFormatVersion: 2010-09-09
Description: YAML sample VPC
Resources:
  sampleVPC:
    Type: 'AWS::EC2::VPC'
    Properties:
      CidrBlock: 10.0.0.0/16
      Tags:
        - Key: Name
          Value: sampleVPC

疑問・課題・メモ

・「"」or「'」の使い方の違い。
・細かいオプション指定

参考・引用


AWS ドキュメント » AWS CloudFormation » ユーザーガイド » AWS CloudFormation テンプレートの使用 » テンプレートの分析

1
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
1
0