【问题标题】:CloudFormation create_stack requiring parametersCloudFormation create_stack 需要参数
【发布时间】:2021-06-10 18:05:57
【问题描述】:

我正在尝试创建一个创建 DynamoDB 表的 Cloud Formation 堆栈。我只是使用 AWS 提供的示例模板。

response = cf.create_stack(
    StackName = stack_name,
    TemplateURL = 'https://s3.us-west-2.amazonaws.com/cloudformation-templates-us-west-2/DynamoDB_Table.template',
    Parameters=[
        {
            'ParameterKey': 'AudioFiles',
            'ParameterValue': 'string',
        },
    ],
    TimeoutInMinutes=123,
    ResourceTypes=[
        'AWS::DynamoDB::Table',
    ],
    OnFailure='DO_NOTHING',
    EnableTerminationProtection=True
)

返回此错误:

调用CreateStack操作时发生错误(ValidationError):参数:[HashKeyElementName]必须有值

我已尝试在参数部分为此参数提供一个值,但这不起作用。

【问题讨论】:

  • 您能否展示包含所需参数但它不起作用的示例?你得到不同的错误了吗?

标签: amazon-web-services amazon-cloudformation


【解决方案1】:

我做这件事很傻

Parameters=[
    {
        'HashKeyElementName': 'AudioFiles',
        'ParameterValue': String',
    },
],

而不是这个

Parameters=[
    {
        'ParameterKey': 'HashKeyElementName',
        'ParameterValue': 'AudioFiles',
    },
],

【讨论】:

    【解决方案2】:

    您似乎没有提供HashKeyElementName 参数的值。

    response = cf.create_stack(
        StackName = stack_name,
        TemplateURL = 'https://s3.us-west-2.amazonaws.com/cloudformation-templates-us-west-2/DynamoDB_Table.template',
        Parameters=[
            {
                'ParameterKey': 'AudioFiles',
                'ParameterValue': 'string',
                'ParameterKey': 'HashKeyElementName',
                'ParameterValue' : 'value'
            },
        ],
        TimeoutInMinutes=123,
        ResourceTypes=[
            'AWS::DynamoDB::Table',
        ],
        OnFailure='DO_NOTHING',
        EnableTerminationProtection=True
    )
    

    boto3 create_stack

    在模板中,除了HashKeyElementName之外的所有参数都默认了 模板摘录

    
     
      "Parameters" : {
        "HashKeyElementName" : {
          "Description" : "HashType PrimaryKey Name",
          "Type" : "String",
          "AllowedPattern" : "[a-zA-Z0-9]*",
          "MinLength": "1",
          "MaxLength": "2048",
          "ConstraintDescription" : "must contain only alphanumberic characters"
        },
    
        "HashKeyElementType" : {
          "Description" : "HashType PrimaryKey Type",
          "Type" : "String",
          "Default" : "S",
          "AllowedPattern" : "[S|N]",
          "MinLength": "1",
          "MaxLength": "1",
          "ConstraintDescription" : "must be either S or N"
        },
    
        "ReadCapacityUnits" : {
          "Description" : "Provisioned read throughput",
          "Type" : "Number",
          "Default" : "5",
          "MinValue": "5",
          "MaxValue": "10000",
          "ConstraintDescription" : "must be between 5 and 10000"
        },
    
        "WriteCapacityUnits" : {
          "Description" : "Provisioned write throughput",
          "Type" : "Number",
          "Default" : "10",
          "MinValue": "5",
          "MaxValue": "10000",
          "ConstraintDescription" : "must be between 5 and 10000"
        }
      },
    

    【讨论】:

      猜你喜欢
      • 2018-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-06
      • 2019-07-02
      • 1970-01-01
      • 2015-05-05
      • 2020-03-09
      相关资源
      最近更新 更多