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

MissingRequiredParameter: Missing required key params.StreamSpecification #101

Open
jordanmaxfightcamp opened this issue Jul 12, 2021 · 2 comments

Comments

@jordanmaxfightcamp
Copy link

This is kind of annoying but having an issue here that doesnt play well with Serverless. I have a DynamoDB table and using the jest dynamodb package to run a local DDB when running unit tests. I am using version 1.8.1, I have a table that has a StreamSpecification set, which deploys fine using serverless (although I DO see StreamEnabled property on AWS docs). But when I run unit tests, I get this error:

MissingRequiredParameter: Missing required key params.StreamSpecification

so I add it, tests run fine. Then when I try to deploy using serverless I get this error:

serverless Encountered unsupported property StreamEnabled

I assume this is a bug, but any workarounds?

@jordanmaxfightcamp
Copy link
Author

I did find a workaround:

await serverless.init();
  const service = await serverless.variables.populateService();
  const resources = service.resources.Resources;
  let tables = Object.keys(resources)
    .map((name) => resources[name])
    .filter((r) => r.Type === 'AWS::DynamoDB::Table')
    .map((r) => r.Properties);
  
  // This is a workaround, there is some bug that says we need a property called `StreamEnabled` on tables with `StreamSpecification` but that will error out serverless.
  // It's also not in the docs, so I am erroring on the side of Serverless since it seems they are adhering to rules
  // https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-streamspecification.html
  // So the workaround, is for local, we dont need streams anyways, remove this property to not get error.
  tables = tables.map(table => {
    const { StreamSpecification } = table;
    if(StreamSpecification) {
      delete table.StreamSpecification;
    }

    return table;
  })

  return {
    tables,
    port: 8000,
  };

So basically just remove any tables with StreamSpecification in your jest dynamodb config, not the best but works.

@hugoduraes
Copy link

hugoduraes commented Sep 5, 2022

@jordanmaxfightcamp if you need streams, instead of deleting StreamSpecification you'll need to do this instead:

tables = tables.map(table => {
  if (table.StreamSpecification) {
    table.StreamSpecification = {
      ...table.StreamSpecification,
      StreamEnabled: true,
    };
  }

  return table;
})

https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_StreamSpecification.html
According to this, StreamEnabled is a required property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants