How to use ssm in production but a string in development?

Hi everyone,
I’m trying to create different environments for development versus production where the development doesn’t need access to any AWS key. I have this keyless requirement because I want to run automated tests on a server without an AWS key. Here are the two pieces of my serverless.yml:

  stage: ${env:STAGE}
        CONTENT_TABLE: ${self:custom.CONTENT_TABLE.${self:provider.stage}}

then down in custom

    dev: ps-dev-content
    staging: ${ssm:/ps/${self:provider.stage}/CONTENT_TABLE}

This works great locally if I comment out the staging line, but if I uncomment it, I get this error. It’s so strange because it uses the dev line when I comment out the staging line and provide a process.env.stage = ‘dev’.

1 unsettled promises
ssm:/ps/dev/CONTENT_TABLE waited on by: ${ssm:/ps/dev/CONTENT_TABLE}

It sounds like the Serverless Framework is attempting to resolve all variables up front which is what I would expect. You might be able to solve this by using a separate file for each stage.

Your serverless.yml would look like:

  CONTENT_TABLE: ${file(env-${self:custom.stage}.yml):CONTENT_TABLE}

Your env-dev.yml would look like

CONTENT_TABLE: ps-dev-content

Your env-staging.yml would look like

CONTENT_TABLE: ${ssm:/ps/${self:provider.stage}/CONTENT_TABLE}
1 Like

This worked beautifully, thanks so much for the reply!