[英]cfn-init specify custom json
有没有办法告诉cfn-init使用从磁盘加载的自定义JSON文件? 这样,我可以快速对问题进行故障排除,否则更改AWS::CloudFormation::Init
部分的唯一方法是删除堆栈并重新创建。
我宁愿只是对我的template.json
进行更改,然后告诉类似cfn-init -f C:\\template.json ...
这样的东西cfn-init -f C:\\template.json ...
所以它使用C:\\template.json
而不是从169.254.169.254
或但是它得到了。
原来cfn-init确实接受文件,但是该文件需要具有"Metadata"
键作为根键。
因此,如果我们将其保存到template.json
:
{
"AWS::CloudFormation::Init": {
"config": {
"files": {
"C:\\Users\\Administrator\\Desktop\\test-file": {
"source": "https://s3.us-east-2.amazonaws.com/example-bucket/example-file"
}
}
}
},
"AWS::CloudFormation::Authentication": {
"S3AccessCreds": {
"type": "S3",
"buckets": ["example-bucket"],
"roleName": "s3access"
}
}
}
然后我们可以执行cfn-init -v --region us-east-2 template.json
。
注意:不包括堆栈或资源,如果使用cfn-init -v -s my_stack -r my_instance --region us-east-2 template.json
您将获得:
错误:您不能为元数据指定多个输入源
如果将整个模板文件而不是仅将“ Metadata”作为根目录放置,则会得到:
在template.json中找不到'AWS :: CloudFormation :: Init'键
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.