我无法将参数加载到Python boto3 Cloudformation客户端中。
以下是我的参数文件:
[
{"ParameterKey": "pVpcId", "ParameterValue": "vpc-XXXXXX"},
{"ParameterKey": "pContact", "ParameterValue": "XDXDXX"},
{"ParameterKey": "pCC", "ParameterValue": "XXXXX" },
{"ParameterKey": "pFormat", "ParameterValue": "True"}
]
我将它以以下方式加载到程序中:
with open(parameter_file, 'r') as infile:
parameters=ast.literal_eval(infile.read())
client = boto3.client('cloudformation',aws_access_key_id=access_key,aws_secret_access_key=secret_key,aws_session_token=session_token,region_name=region)
response = client.create_stack(
StackName=stack_name,
TemplateURL=stack_url,
Parameters=parameters
)
当我使用Cloudformation建立一个boto3客户端并调用它时,出现了以下描述的错误。如果不带参数调用,则可以正常工作,因此问题肯定与参数文件有关。
Traceback (most recent call last):
File "cf_create_stack", line 85, in <module>
Parameters=parameters
File "/usr/lib/python2.7/site-packages/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/lib/python2.7/site-packages/botocore/client.py", line 661, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (ValidationError) when calling the CreateStack operation: Template format error: unsupported structure.