我正在尝试将
aws cloudformation update-stack
与 --cli-input-json
一起使用,但我也希望 "TemplateBody":"[...]"
值指向一个文件,就像我可以使用 --template-body file://template.yml
那样。
这可能吗?
谢谢!
不,不支持。
您将收到此错误消息:
调用UpdateStack操作时发生错误(ValidationError):模板格式错误:不支持的结构。
首先,您的模板主体必须是
cli-input-json
中的 JSON,所以假设您有 template.json
。
当您通过命令行提供
--template-body
时,CLI 会意识到您正在提供要读取的文件,读取该文件,然后将 JSON 内容提供给 API。
cli-input-json
时,CLI 会按字面意思解析它1 并将 file://template.json
识别为不属于 CloudFormation 模板格式的无效 JSON。
1 如果使用
--debug
运行命令,您可以看到这一点(这是 CreateStack
,但适用相同的概念):
2023-09-30 11:29:17,259 - MainThread - botocore.endpoint - DEBUG - 使用参数 {'url_path': '/', 'query_string': '', 'method 向 OperationModel(name=CreateStack) 发出请求': 'POST', 'headers': {'Content-Type': 'xxx', 'User-Agent': 'xxx'}, 'body': {'Action': 'CreateStack', 'Version': ' 2010-05-15', 'StackName': 'xxx', 'TemplateBody': 'file://template.json'}, 'url': 'xxx', 'context': {'client_region': ' xxx','client_config':
,'has_streaming_input':False,'auth_type':无}}