Skip to content

Allow SSM parameters to be referenced with profile and stage coming from cli-options (#4311) - #4725

Closed
jbreckel wants to merge 1 commit into
serverless:masterfrom
jbreckel:master
Closed

jbreckel wants to merge 1 commit into
serverless:masterfrom
jbreckel:master

Conversation

@jbreckel

@jbreckel jbreckel commented Feb 6, 2018

Copy link
Copy Markdown

What did you implement:

Closes #4311

serverless.yml:

service: serverless-ssm-test
frameworkVersion: "=1.26.0"
provider:
  name: aws
  runtime: nodejs6.10
  stage: ${opt:stage, 'dev'}
  profile: ${opt:profile}
  region: 'eu-central-1'
  environment:
    DB_USER: ${ssm:/some-path/to-a/db-username}

When there are options used for provider.stage or provider.profile with or without a default value, serverless can not resolve the ssm parameter and fails with Profile ${opt:profile} does not exist.

How did you implement it:

Before sending the request to aws to get the ssm parameter a short wait of 10 ms is introduced to wait for cli options to be resolved.

How can we verify it:

  1. Add the ssm parameter mentioned in the config above to a aws profile
  2. Run sls print --stage stage --profile <profile-with-ssm-parameter>
    The above serverless.yml should throw an error when run with the current release (=1.26.0).

Todos:

  • Write tests
  • Write documentation
  • Fix linting errors
  • Make sure code coverage hasn't dropped
  • Provide verification config / commands / resources
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: NO
Is it a breaking change?: NO

The issue described in serverless#4311 comes from the fact, that aws needs `provider.profile` and `provider.stage` to be resolved before attempting to resolve the ssm references.
As there is no way to separate ssm variables from others, a short wait (10 ms) was added, before attempting to fetch the parameters from aws.
@HyperBrain

Copy link
Copy Markdown
Contributor

@jbreckel Appreciate your thoughts and work on this 👍 , but I don't think this is a proper and deterministic solution for the problem.

The bug itself is strongly related to #4702 - all AWS API calls during the variable resolution have to await the proper variable resolutions (and that not by just waiting) that are currently queued. Only after they have been resolved, the calls can be made safely.

@erikerikson Is probably already working on a solution for this, together with the cleanup of the resolution of variable dependencies. If not done together in his PR, we should at least wait with these API call fixes in the variable resolution, until the dependent variable resolution has been fixed.
Erik, can you please comment here, so that we can schedule or track this a bit?

@erikerikson

Copy link
Copy Markdown
Contributor

Thanks for calling my attention here @HyperBrain.

This particular matter isn't directly addressed by my current work (#4713) but it definitely fits in. The current work to avoid deadlocks is very much about sorting dependency problems and this is that in another form.

A similar concern came up in the recent serverless.js discussions from a different perspective.

I would say that my current code cannot be called correct without fixing this but it may have consequences. I'll tackle it today.

@erikerikson

erikerikson commented Feb 7, 2018 •

Copy link
Copy Markdown
Contributor

Very quick update. I've got the rough out of the code mostly done. should be complete today, will submit the work under #4713 after augmenting with the appropriate tests. All further updates under that PR.

edit: oops #4713, not #4687

@erikerikson

Copy link
Copy Markdown
Contributor

This issue should be resolved via:
#4754
Could you give it a try and report back?

@albertnavas

Copy link
Copy Markdown

I have the same issue with ssm and profiles in the latest version 1.27.3. Is it planned to be solved? Thanks!

@erikerikson

Copy link
Copy Markdown
Contributor

It appears that this PR can be closed. Any reason to keep it open?

@dschep

dschep commented Jan 23, 2019

Copy link
Copy Markdown
Contributor

hey @jbreckel, i've implemented this in a different (imo better) way in #5744. I applies the same early "resolve-to-constant" requirements to profile as it already does to stage & region.

@pmuens

pmuens commented Jan 25, 2019

Copy link
Copy Markdown
Contributor

Thank you very much for working on this @jbreckel 👍

As @dschep pointed out there's another PR in the making which also addresses this problem. Given that I'll close this PR in favor of #5744.

@pmuens pmuens closed this Jan 25, 2019
@pmuens pmuens self-assigned this Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ssm inclusions fail

7 participants