[英]cfn-init specify custom json
Is there a way to tell cfn-init to use a custom JSON file loaded from disk? 有没有办法告诉cfn-init使用从磁盘加载的自定义JSON文件? That way I can quickly troubleshoot problems, otherwise the only way to change the
AWS::CloudFormation::Init
section is to delete the stack and create it anew. 这样,我可以快速对问题进行故障排除,否则更改
AWS::CloudFormation::Init
部分的唯一方法是删除堆栈并重新创建。
I'd rather just make changes to my template.json
, then tell something like cfn-init -f C:\\template.json ...
so it uses C:\\template.json
instead of getting the template from 169.254.169.254
or however it gets it. 我宁愿只是对我的
template.json
进行更改,然后告诉类似cfn-init -f C:\\template.json ...
这样的东西cfn-init -f C:\\template.json ...
所以它使用C:\\template.json
而不是从169.254.169.254
或但是它得到了。
Turns out cfn-init does accept a file, but the file needs to have the "Metadata"
key as the root key. 原来cfn-init确实接受文件,但是该文件需要具有
"Metadata"
键作为根键。
So if we save this to template.json
: 因此,如果我们将其保存到
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"
}
}
}
Then we can execute cfn-init -v --region us-east-2 template.json
. 然后我们可以执行
cfn-init -v --region us-east-2 template.json
。
Note: Do not include the stack or resource, if you use cfn-init -v -s my_stack -r my_instance --region us-east-2 template.json
you will get: 注意:不包括堆栈或资源,如果使用
cfn-init -v -s my_stack -r my_instance --region us-east-2 template.json
您将获得:
Error: You cannot specify more than one input source for metadata
错误:您不能为元数据指定多个输入源
If you put the entire template file instead of just "Metadata" as root, you will get: 如果将整个模板文件而不是仅将“ Metadata”作为根目录放置,则会得到:
Could not find 'AWS::CloudFormation::Init' key in template.json
在template.json中找不到'AWS :: CloudFormation :: Init'键
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.