AWS: Throw an error if ${ssm} fail to populate value, as same as ${cf} and ${s3} #5770
AWS: Throw an error if ${ssm} fail to populate value, as same as ${cf} and ${s3} #5770exoego wants to merge 4 commits into
Conversation
|
@exoego I see some updates here, what's the status of this PR? |
# Conflicts: # lib/classes/Variables.test.js
|
This PR is now ready to review. The change introduced in this PR will provider a broad-based and long-time-awaited behavior, but will be a breaking change, as @pmuens said in #3367 (comment), I believe fixing this drastically improve DX by preventing deploying broken services, unifying behavior of all variable syntaxes, and providing choices to users. I have a little preference on merging this breaking change to |
pmuens
left a comment
There was a problem hiding this comment.
@exoego thank you very much for working on this! 👍
I just tested it today and it works fine. Unfortuantely this will intorduce a breaking change which means that we would have to bump to version 2 (as you already mentioned in your comment). Given this I'd say that we should postpone this PR / feature for the v2 release.
Thanks again for taking the time to work on this 🙏
We'll revisit this PR once we're looking into v2!
| expect(warnIfNotFoundSpy.callCount).to.equal(0); | ||
| }) | ||
| .finally(() => { | ||
| requestStub.restore(); |
There was a problem hiding this comment.
Restores like this should be moved in a beforeEach / afterEach block so that the test suite takes care of the cleanup.
| `Error getting value for ssm:${param}.`, | ||
| `Parameter ${param} not found.`, | ||
| ].join(' ')) | ||
| .then().finally(() => requestStub.restore()); |
There was a problem hiding this comment.
Same comment about restore applies here.
|
Is there any workaround to have similar behaviour in v1.38? I don't feel confident if a deploy could go through to production with invalid SSM param setup |
|
I very much agree. This is very unfortunate behavior. |
|
Also would love this to be revisited in 1.0 -- what's the scenario where a deployment should continue if the lookup fails? Sincerely asking, as I've never encountered this situation without immediately following it up with another deploy. (EDIT: Obligatory xkcd reference) |
|
@troyready I've encountered a few cases where these should optional. E.g. A logger service has the ability to send to different SaaS. But it only sends to those that have an api key configured. The fallback would solve that nicely though and also make it explicit. |
|
@eahefnawy / @medikoo will a v2 branch be opened soon to address some of these changes that have been around for quite some time? |
|
@bryantbiggs See #3367 it outlines a proposed solution, for which we will welcome a PR. |
What did you implement:
Closes #4447
Closes #5757
Closes #5781
How did you implement it:
Before this PR,
${ssm}catches400error from AWS SSM, and returnsundefinedas fulfilled value.This may cause broken service deployment and user may not notice that.
And, such behavior is incosistent with
${cf}and${s3}.After this PR,
${ssm}aborts whenver SSM returns error.The error can be recovered with the fallback value in the form of
${ssm:/path/param, "fallback"}(already implemented).So every AWS-specific variable syntaxes has uniform behavior.
How can we verify it:
sls deployand confirm it aborts like$ sls deploy Serverless Error --------------------------------------- Error getting value for ssm:/path/to/service/myParamS. ParameterNotFound Get Support -------------------------------------------- Docs: docs.serverless.com Bugs: github.com/serverless/serverless/issues Issues: forum.serverless.com Your Environment Information ----------------------------- OS: linux Node Version: 8.10.0 Serverless Version: 1.36.3ssmVar: ${ssm:/path/to/service/myParamS, 'fallback'}sls deployand confirm it complete successfullyTodos:
Write documentationN/AIs this ready for review?: YES
Is it a breaking change?: COULD BE