thoreinstein / serverless-offline-ssm

Read SSM parameters from a .env file instead of AWS
MIT License
94 stars 24 forks source link

Cannot make it work with serverless 1.72.0 #33

Open alxch- opened 4 years ago

alxch- commented 4 years ago

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.

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.

thoreinstein commented 4 years ago

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

alxch- commented 4 years ago

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.

thoreinstein commented 4 years ago

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.

pascencio commented 3 years ago

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!