Python 使用boto3更新云形成模板

Python 使用boto3更新云形成模板,python,boto3,amazon-cloudformation,Python,Boto3,Amazon Cloudformation,我试图使用boto3更新现有的CloudFormation模板,但我的代码在“Parameters”属性上失败!以下是我尝试过的: 从配置文件中读取参数 from ConfigParser import SafeConfigParser parser = SafeConfigParser() parser.optionxform=str parser.read( '/parms/SecGrpsParams.cfg') parms = dict(parser.items('para

我试图使用boto3更新现有的CloudFormation模板,但我的代码在“Parameters”属性上失败!以下是我尝试过的:

  • 从配置文件中读取参数

    from ConfigParser import SafeConfigParser  
    parser = SafeConfigParser()  
    parser.optionxform=str  
    parser.read( '/parms/SecGrpsParams.cfg')  
    parms = dict(parser.items('params'))
    
  • “打印帕尔姆”产品

    {'Application':'Click2Buy','AdminCidr':'10.0.0.0/8','AppMoniker':'c2b','vId':'vpc-3bec005f'}

  • 调用更新堆栈

    client = boto3.client('cloudformation')  
    response = client.update_stack(  
        StackName = args.stackname,  
        TemplateURL = template,  
        Parameters = args.params,  
        Capabilities = ['CAPABILITY_IAM']  
     )
    
  • 代码会产生以下错误:
    botocore.exceptions.ParamValidationError:参数验证失败: 参数的类型无效,
    值:{'Application':'Click2Buy','AdminCidr':'10.0.0.0/8','AppMoniker':'c2b','vId':'vpc-3bec005f',
    类型:类型:,有效类型:


  • 我尝试了
    args.params.items()
    [args.params]
    [args.params.items()]
    ,但无法确定需要什么。

    我发现了以前尝试的问题。“update\u stack”调用希望以
    Parameters=[{'ParameterKey':”的形式将列表对象传递到“Parameters”字段parm_name”、“ParameterValue”:'parm_value'}]。
    并且,传递的参数数量必须在数量和语法上与CloudFormation模板中的参数定义完全匹配