-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Support resource extensions #7352
Conversation
The merge logic for extending resources with the existing framework using `resources.Resources` has some surprising behaviours. This introduces a more formalized definition for extending resources, where `Metadata` and `Properties` will be shallowly merged (the values for existing keys will be replaced instead of merged), the `DependsOn` list will be added to, and the values for `CreationPolicy`, `DeletionPolicy`, `UpdatePolicy`, and `UpdateReplacePolicy` will be replaced if they exist in the extension. Extension of other resource attributes is not supported at this time.
Codecov Report
@@ Coverage Diff @@
## master #7352 +/- ##
==========================================
+ Coverage 87.99% 88.02% +0.02%
==========================================
Files 240 240
Lines 8997 9007 +10
==========================================
+ Hits 7917 7928 +11
+ Misses 1080 1079 -1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@glb looks great! I've just posted a suggestion to use more natural constructs for iteration.
@pmuens please take a look, I think it's an imporant addition (with v2 we probably should drop support for resources.Resources
entirely, and propose resources.addition
instead and validate they do not override anything generated by the framework).
I'd also improve the documentation (I'll do it prior merging PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat idea 👍
Do we also plan to support other cloud providers as well? I'm asking since resources
was the central place where every provider plugin could expect custom provider related resources. How would an extension
work if we implement this for another provider (e.g. Azure)? Is an extension
provider independent or should it only be used for AWS?
I think it's a CloudFormation specific thing. Not sure if other providers have that, and if, whether it's still named resources (?) Technically currently If we agree that all top level should be assumed as provider-agnostic, then I would probably move it to @pmuens What are your thoughts? |
@medikoo / @pmuens I'm not super-comfortable with the direction this conversation is taking ... this PR came about because @medikoo suggested that
If you're talking about a future change to remove Personally I liked the direction that this was going in, even though it was different from what I'd originally proposed, but ultimately my (selfish) goal is to be able to reliably add something to the I suppose another option would be to write a plugin that does the specific thing I need? |
@glb This PR is intended to be purely about introduction of What I'm discussing with @pmuens is wheter it's not better to provide extensions at Simply to coin right config schema from a start. We will do changes to |
Thanks @medikoo ... I think you had a very good point when you suggested that Personally I put |
As I inspected history of I assume that intention was that It's probably ok to not change that
@pmuens I think idea should be same as in case of AWS, that General idea is to replace This distinction will allow to fix such issues. In v1 we can add |
The
That sounds reasonable, however I agree with @glb that the IMHO it's not a big deal to introduce the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pmuens can you give it a second look? |
Merge logic for extending resources with the existing framework using `resources.Resources` has some surprising behaviours. This introduces a more formalized definition for extending resources, where `Metadata` and `Properties` will be shallowly merged (the values for existing keys will be replaced instead of merged), the `DependsOn` list will be added to, and the values for `CreationPolicy`, `DeletionPolicy`, `UpdatePolicy`, and `UpdateReplacePolicy` will be replaced if they exist in the extension. Extension of other resource attributes is not supported at this time.
What did you implement
The merge logic for extending resources with the existing framework using
resources.Resources
has some surprising behaviours.This introduces a more formalized definition for extending resources, where
Metadata
andProperties
will be shallowly merged (the values for existing keys will be replaced instead of merged), theDependsOn
list will be added to, and the values forCreationPolicy
,DeletionPolicy
,UpdatePolicy
, andUpdateReplacePolicy
will be replaced if they exist in the extension.Extension of other resource attributes is not supported at this time.
Related to but does not completely address the requirements in #6575, as fully complying with those requirements would be a breaking change.
Related to #7338.
How can we verify it
Copy
serverless.yml
below to disk.Run
serverless package
.Examine
.serverless/cloudformation-template-update-stack.json
. Validate that theSampleLogGroup
resource hasRetentionInDays
set to"30"
.See also the automated tests that validate the full behaviour.
serverless.yml
Todos
Is this ready for review?: YES
Is it a breaking change?: NO