たとえば、これらのパラメータを要求するこのCFテンプレートがあります
----- cftemplate.yaml -----
...
Parameters:
**Subnet:
Description: Subnet for the Instance
Type: 'AWS::EC2::Subnet::Id'
SecurityGroups:
Description: Security Group for Instance
Type: 'List<AWS::EC2::SecurityGroup::Id>'**
...
Resources:
EC2Instance:
Type: AWS::EC2::Instance
Properties:
...
**SubnetId: !Ref Subnet
SecurityGroupIds: !Ref SecurityGroups**
...
----- cftemplate.yaml -----
スタックをデプロイするには、次のコマンドを使用します。
aws cloudformation create-stack --stack-name StackName --template-body file://cftemplate.yaml --parameters file://params.json
params.jsonに含まれる場所:
----- params.json -----
[
{
"ParameterKey":"Subnet",
"ParameterValue":"subnet-11111111"
},
{
"ParameterKey":"SecurityGroups",
"ParameterValue":"sg-111111111",
"ParameterValue":"sg-222222222"
}
]
----- params.json -----
今、私の目標は.jsonファイルの使用を排除することです。上記のコマンドと同じ効果を達成する必要があるコマンドの簡略構文を知っている人はいますか?オンラインのドキュメントでこれを見つけることができないようです。前もって感謝します!
同等のコマンドラインは次のようになります(明確にするために少し再フォーマットされています)。
aws cloudformation create-stack \
--stack-name StackName \
--template-body file://cftemplate.yaml \
--parameters ParameterKey=Subnet,ParameterValue=subnet-11111111 ParameterKey=SecurityGroups,ParameterValue=sg-111111111\\,sg-222222222
上記では、スペースとコンマに注意することが重要です。
私は検証私自身のパラメータと自分のサンドボックスのアカウントを使用してコマンドを:
aws cloudformation create-stack --stack-name StackName --template-body file://instance.yaml --parameters ParameterKey=Subnet,ParameterValue=subnet-0ae6ce0f9bbf52251 ParameterKey=SecurityGroups,ParameterValue=sg-06d2a3e9c8aa99620\\,sg-004d23d188ec1146f
これは正しく、スタックをデプロイするプロセスを開始することになります。
{
"StackId": "arn:aws:cloudformation:us-east-1:xxxxxx:stack/StackName/61fbacd0-d3b0-11ea-970a-0ad23187ddb2"
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加