Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create DynamoDB table in function stack #1381

Closed
thde opened this issue May 2, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@thde
Copy link

commented May 2, 2019

Describe the bug
I'm trying to create a DynamoDB table in a cloudformation stack of a lambda function:

    "AuthTable": {
      "Type": "AWS::DynamoDB::Table",
      "Properties": {
        "BillingMode": "PAY_PER_REQUEST",
        "ProvisionedThroughput": {
          "Ref": "AWS::NoValue"
        },
        "TableName": {
          "Fn::Join": [
            "-",
            [
              {
                "Ref": "AuthTableName"
              },
              {
                "Ref": "env"
              }
            ]
          ]
        },
        "KeySchema": {
          "AttributeName": "Key",
          "KeyType": "HASH"
        }
      }
    },

This will generate the following error:

CREATE_FAILED  AuthTable  AWS::DynamoDB::Table  Tue Apr 30 2019 13:47:29 GMT+0000 (Coordinated Universal Time) Property ProvisionedThroughput cannot be empty.

The documentation says "If you set BillingMode as PAY_PER_REQUEST, you cannot specify this property."
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-provisionedthroughput

Is there a possibility that the CLI will change the stack before submitting it? Is seems unlikely to me, but as I copied the above table definition I'm also quite sure this should work.

@yuth

This comment has been minimized.

Copy link
Contributor

commented May 2, 2019

Is there a possibility that the CLI will change the stack before submitting it? Is seems unlikely to me, but as I copied the above table definition I'm also quite sure this should work.

CLI doesn't change the cloud formation template before submitting it. I think the problem here is you're using AWS: : NoValue without a condtion. If use it with a condition as shown below, it should work without problem

    "AuthTable": {
        "Type": "AWS::DynamoDB::Table",
        "Properties": {
            "BillingMode": "PAY_PER_REQUEST",
            "ProvisionedThroughput": {
                "Fn: : If": [
                    {
                        "Fn::Equals": [
                            {"Ref": "BillingMode" },
                            "PAY_PER_REQUEST"
                        ]
                    },
                    5,
                    {
                        "Ref": "AWS: : NoValue"
                    }
                ]
            },
            "TableName": {
                "Fn: : Join": [
                    "-",
                    [
                        {
                            "Ref": "AuthTableName"
                        },
                        {
                            "Ref": "env"
                        }
                    ]
                ]
            },
            "KeySchema": {
                "AttributeName": "Key",
                "KeyType": "HASH"
            }
        }
    }
@kaustavghosh06

This comment has been minimized.

Copy link
Contributor

commented May 3, 2019

@thde Closing this issue for now. If you're still stuck, please feel free to comment or re-open this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.