なにかお手伝いできることがあればご連絡ください。
お問い合わせはこちらから
※Googleフォームが表示されます
Visual Studio Codeのプラグインが便利。
https://marketplace.visualstudio.com/items?itemName=aws-scripting-guy.cform
.yml
ファイルを作成して、ファイル上でstart
+ tabでテンプレートの骨格が作成される。
AWSTemplateFormatVersion: 2010-09-09
Description: ---
Metadata:
Parameters:
Mappings:
Conditions:
Resources:
Outputs:
Visual Studio CodeにCloudFormation用の設定を追加します。
◎ ~/Library/Application Support/Code/User/settings.json
{"yaml.schemas": {
"https://d33vqc0rt9ld30.cloudfront.net/latest/gzip/CloudFormationResourceSpecification.json": [
"*.cf.yaml",
"*.cf.yml",
"*.cfn/*.yaml",
"*.cfn/*.yml",
"cloud*formation/*.yaml",
"cloud*formation/*.yml"
]
},
"yaml.customTags": [
"!Ref",
"!Sub scalar",
"!Sub sequence",
"!Join sequence",
"!FindInMap sequence",
"!GetAtt scalar",
"!GetAtt sequence",
"!Base64 mapping",
"!GetAZs",
"!Select scalar",
"!Select sequence",
"!Split sequence",
"!ImportValue",
"!Condition",
"!Equals sequence",
"!And",
"!If",
"!Not",
"!Or"
]
}
以下VPCを作成する、CloudFormationテンプレートファイルを作成します。
AWSTemplateFormatVersion: 2010-09-09
Resources:
MyVpc:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.8.0/21
EnableDnsSupport: true
Tags:
- Key: Name
Value: MyVPCfromCF
CloudFormationのスタックの作成から「新しいリソースを使用」を選択します。
テンプレートファイルをアップロードします。
スタック名を設定します。
その他はそのままの設定で、スタックを作成します。
しばらく待つとVPCが作成されます。
作成したスタックを更新します。
VPCにサブネットを追加します。
AWSTemplateFormatVersion: 2010-09-09
Resources:
MyVpc:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.8.0/21
EnableDnsSupport: true
Tags:
- Key: Name
Value: MyVPCfromCF
subnetName:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: "ap-northeast-1a"
VpcId: !Ref MyVpc
CidrBlock: 10.0.8.0/24
Tags:
- Key: Name
Value: subnet1fromCF
先程作成したスタックを選択して、「更新」ボタンを押します。
「既存のテンプレートを置き換え」を選択して、変更したテンプレートファイルをアップロードします。
その他は特にへんこうせず、更新を行うとサブネットが追加されます。
スタックのテンプレートは規模が大きくなるとテンプレートファイルが大きくなってしまうので、複数のファイルに分けて、リソースを参照するようにします。
なにかお手伝いできることがあればご連絡ください。
※Googleフォームが表示されます