-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
CloudFormation: Store resource scaffolding in 'generated' directory. #13534
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
base: main
Are you sure you want to change the base?
Conversation
…o separate auto-generated code from human-written code.
0713e38 to
d8931e2
Compare
Test Results - Alternative Providers583 tests - 885 325 ✅ - 562 18m 24s ⏱️ - 14m 32s Results for commit dc934b6. ± Comparison against base commit ee0d438. This pull request removes 885 tests.♻️ This comment has been updated with latest results. |
Test Results (amd64) - Integration, Bootstrap 5 files ± 0 5 suites ±0 2h 4m 35s ⏱️ - 30m 58s Results for commit dc934b6. ± Comparison against base commit ee0d438. This pull request removes 1423 and adds 1 tests. Note that renamed tests count towards both.This pull request removes 252 skipped tests and adds 1 skipped test. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 1h 33m 13s ⏱️ - 23m 27s Results for commit dc934b6. ± Comparison against base commit ee0d438. This pull request removes 1045 and adds 1 tests. Note that renamed tests count towards both.This pull request removes 88 skipped tests and adds 1 skipped test. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
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.
I am hugely on board with this change, thank you! I have raised an issue about hiding the docstrings which I think will help developers build a conforming implementation (until we enforce an engine -> resource provider contract at least). I'd like to open a discussion about that.
I tried this out while implementing AWS::RDS::DBProxyEndpoint for a feature request. Thank you for making this change backwards compatible! It means that we can migrate the resource providers gradually! I really appreciate this.
I found that the files needed formatting. Can we maybe run make format-modified (or similar) after rendering the templates? That would make the initial experience much nicer.
| self, | ||
| request: ResourceRequest[{{ resource }}Properties], | ||
| ) -> ProgressEvent[{{ resource }}Properties]: | ||
| """ |
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.
issue: I don't like removing these docstrings to the base model. I realise that their content is autogenerated, and will get out of sync with the generated code but the docstrings are a great reminder of what
- properties the model needs to set (
writeOnlyProperties) - potential operations the method may need to invoke (through required iam actions)
I can see the docstring if I hover the method in PyCharm, but for people who have not written many resource providers it's not intuitive that this docstring is present. I bet the wouldn't look in the generated subdir anyway. To that end, relying on the schema.json file is also not a good solution.
| {%- endif %} | ||
| """ | ||
| raise NotImplementedError | ||
|
|
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.
suggestion: can we add the list method (from CloudControl) into the scaffolding? And make sure it's overridden in the subclass?
Something like:
| @abstractmethod | |
| def list( | |
| self, | |
| request: ResourceRequest[{{ resource }}Properties], | |
| ) -> ProgressEvent[{{ resource }}Properties]: | |
| """ | |
| List available resources of this type | |
| {% if list_permissions -%} | |
| IAM permissions required: | |
| {%- for permission in list_permissions %} | |
| - {{ permission }} | |
| {%- endfor %} | |
| {%- endif %} | |
| """ | |
| raise NotImplementedError |
|
Thanks @simonrw , I've made your suggested changes. |
Motivation
Generate CloudFormation resource scaffolding into a service's
resource_providers/generateddirectory to separate auto-generated code from hand-written code. Resource provider classes should inherit from their auto-generated base class, permitting automatic updates of the base class and associated data types, without overwriting any hand-written code.Changes
generated/<resource>_base.pyfile that contains auto-generated type definitions, as well as abstract CRUD methods. These can be re-generated at any time, without overwriting hand-written code.*_plugin.pyand*.schema.jsonfiles into thegeneratedsubdirectory.<resource>.pyfile that inherits types/methods from<resource>_base.py. This file is expected to be modified by hand and contain the full provider implementation.AWS::SQS::QueuePolicyprovider to demonstrate that this new split works correctly (other resource providers forAWS::SQSwill be updated in a later PR).Tests
Tested by:
AWS::SQS::QueuePolicyto use this new structure (included in this PR)Related