0
votes

I'm trying to create a Cloud Formation stack that makes a DynamoDB table. I'm just using a sample template provided by 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
)

It's returning this error:

An error occurred (ValidationError) when calling the CreateStack operation: Parameters: [HashKeyElementName] must have values

I have tried providing a value for this parameter in the parameters section but this won't work.

2
Can you show the example where you included the required parameter and it didn't work? did you get a different error?jordanm

2 Answers

0
votes

I was being silly and doing this

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

instead of this

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

Seems like you have not provided the value for HashKeyElementName parameters.

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

In the template, all the params have defaulted except HashKeyElementName excerpt from the template


 
  "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"
    }
  },