serverless-offline-ssm icon indicating copy to clipboard operation
serverless-offline-ssm copied to clipboard

Cannot make it work with serverless 1.72.0

Open alxch- opened this issue 4 years ago • 4 comments

Hi,

I have an issue making the plugin work with serverless 1.72.0. I just installed so I cannot confirm if it was working with a previous version, but I tested serverless 1.69.0 with no success. I've tried setting my parameter both in the serverless-offline-ssm section and in .env file.

When running sls offline start --stage dev, I get:

Serverless: serverless-offline-ssm checking serverless version 1.72.0.
 Serverless Warning --------------------------------------
  A valid SSM parameter to satisfy the declaration 'ssm:/test_param~true' could not be found.
  • package.json:
    "serverless": "^1.72.0",
    "serverless-domain-manager": "^3.2.2",
    "serverless-dynamodb-local": "^0.2.35",
    "serverless-offline": "^6.3.1",
    "serverless-offline-sqs": "^2.0.2",
    "serverless-offline-ssm": "^5.0.1",
    "serverless-plugin-git-variables": "^3.3.1",
    "serverless-python-requirements": "^4.3.0"
  • plugins section of serverless.yml:
  - serverless-python-requirements
  - serverless-domain-manager
  - serverless-dynamodb-local
  - serverless-offline-sqs
  - serverless-offline-ssm
  - serverless-offline
  - serverless-plugin-git-variables
  • custom section of serverless.yml:
custom:
  serverless-offline-ssm:
    stages:
      - dev
    ssm:
      'test_param': 'placeholder'
  • I also have at the root of my package a .env file:
test_param=placeholder

Could it be a conflicting plugin? I've tried disabling them one by one but it did not solve the issue. Would you have any idea about why it does not work?

Thank you very much.

alxch- avatar Jun 03 '20 23:06 alxch-

@alxch- Can you please provide a sample project or repository in which this happens, I am unable to reproduce it currently.

thoreinstein avatar Jun 04 '20 00:06 thoreinstein

Thank you for trying to reproduce.

I finally found where my issue was coming from. When referring to my SSM params, I was using ${ssm:/test_param~true} (see the / as a prefix). This is actually equivalent to ${ssm:test_param~true} when querying the parameters from AWS. See this doc:

The systems treats both of the following parameters as root parameters. /parameter-name parameter-name

However, it seems that the plugin does not have the same behavior. It will try to find the exact parameter (with the / prefix) from .env, and complain because it cannot find it.

alxch- avatar Jun 04 '20 19:06 alxch-

Ah, ok, I see that now. It's likely to do with the regex that reads the ssm name from the yaml file. I feel like the leading / was something I wasn't using or wasn't supported when I first wrote this. I'll see if I can add that support and get a fix released.

thoreinstein avatar Jun 04 '20 21:06 thoreinstein

Thank you for trying to reproduce.

I finally found where my issue was coming from. When referring to my SSM params, I was using ${ssm:/test_param~true} (see the / as a prefix). This is actually equivalent to ${ssm:test_param~true} when querying the parameters from AWS. See this doc:

The systems treats both of the following parameters as root parameters. /parameter-name parameter-name

However, it seems that the plugin does not have the same behavior. It will try to find the exact parameter (with the / prefix) from .env, and complain because it cannot find it.

Hi @alxch- can you give me an example please?. I have the same problem here.

This is my configuration:

Offline SSM:

serverless-offline-ssm:
    stages:
      - local
    ssm:
      'greeting': 'Hi local'

Plugins:

plugins:
  - serverless-stage-manager
  - serverless-webpack
  - serverless-dynamodb-local
  - serverless-offline-ssm
  - serverless-offline

Environment variables:

  environment:
    AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
    GREETING: ${ssm:greeting~true}

I have the same issue using .env file.

Thanks in the advance!

pascencio avatar Feb 11 '21 05:02 pascencio