Repository navigation
Improve Stage and Region Usage - #4560
Conversation
Remove the errant (but understandable) distributed usage of region and stage settings. This otherwise locks in a multitude of bugs around the improper algorithm for selecting (given all context) the proper region or stage setting. Instead, all code should use the centralized algorithm for determining such values. This creates a strange first and second class configuration concept but these two are sufficiently varied and complex in their creation and use that this seems appropriate.
|
While these changes seem to be the "right" thing for the framework, there is a risk implicit that these changes could negatively impact plugins if it creates an asynchronicity between plugin's expectations of the frameworks evaluation of these values from the context and its own evaluation of them from the context (which may well be copied code from the framework). However, for the long term centralizing such algorithms (if not some time generalizing them) seems the right anti-entropy choice. |
HyperBrain
left a comment
There was a problem hiding this comment.
A big step in the right direction!
| timestamp: 1476779096930, | ||
| }; | ||
| serverless.setProvider('aws', new AwsProvider(serverless)); | ||
| provider = new AwsProvider(serverless); |
There was a problem hiding this comment.
@erikerikson The AwsProvider constructor in the tests should include the options parameter, as AwsProvider.options is evaluated to fetch the stage in getStage(). Otherwise it will default to whatever is set as default or set in serverless.config.stage or serverless.service.provider.stage.
E.g. the test options here set it to dev (which is coincidentally the default), but when setting it here to someStage it will fail, because you did not give the actual options to the constructor.
There was a problem hiding this comment.
Good catch. Incoming in a moment.
There was a problem hiding this comment.
Looks like there were others (a search for new AwsProvider(serverless) uncovered them easily). Given that no tests are failing, I'll add them in the cases where an options hive is defined but will otherwise not provide the parameter. Let me know if you think I should be more aggressive on that front.
There was a problem hiding this comment.
Be as aggressive as you have to be :-D
Imo, if there are explicit test options defined, they should be given to the provider.
There was a problem hiding this comment.
This and others are addressed in the latest commit.
horike37
left a comment
There was a problem hiding this comment.
Thanks @erikerikson 👍
LGTM since all tests have been passed.
However, for the long term centralizing such >algorithms (if not some time generalizing them) >seems the right anti-entropy choice.
You are right. The only thing for that quite recently is that doing test
thoroughly on the master branch before next release.
Add explicit use of options where they were defined.
|
This should be GTM unless Frank desires a more aggressive provision of option hives. |
|
I'm perfectly fine with that :) The other occurences that are out of scope here can be touched when someone works there. |
|
For the coverage decrease -> let's ignore that :) it seems it just uses different code branches now and draws in some files... |
|
Haha. Thanks for calling this out, the laugh was pleasant! |

What did you implement:
Centralize throughout the codebase to using the
awsprovider'sgetStageandgetRegionmethods.Remove the errant (but understandable) distributed usage of region and stage settings. This otherwise locks in a multitude of bugs around the improper algorithm for selecting (given all context) the proper region or stage setting. Instead, all code should use the centralized algorithm for determining such values. This creates a strange first and second class configuration concept but these two are sufficiently varied and complex in their creation and use that this seems appropriate.
How did you implement it:
Centralize throughout the codebase to using the
awsprovider'sgetStageandgetRegionmethods.How can we verify it:
verify by noting the tests continue to pass.
is there something more extensive than the unit tests that I should run in the future to verify across the cli interactions or the like?
Todos:
Is this ready for review?: YES
Is it a breaking change?: NO