-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: replace DependsOn
to connector by its generated logical IDs
#2537
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a39c96e
Replace DependsOn to connector by its generated logical IDs
e2119ef
Merge branch 'develop' into replace-connector-dependson
hoffa 21772d6
Refactor
32aa855
Add tests
356b2d2
Refactor
7904afa
Clearer name
a663f96
Add tests
37a79b8
Add multiple ACs in tests
af216c2
Refactor
fb0a98a
make black
868bfa2
Stricter type
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import copy | ||
from typing import cast, Any, List | ||
|
||
|
||
def as_array(x: Any) -> List[Any]: | ||
"""Convert value to list if it already isn't.""" | ||
return x if isinstance(x, list) else [x] | ||
|
||
|
||
def insert_unique(xs: Any, vs: Any) -> List[Any]: | ||
""" | ||
Return copy of `xs` extended with values of `vs` that do not exist in `xs`. | ||
Inputs are converted to lists if they already aren't. | ||
""" | ||
xs = as_array(copy.deepcopy(xs)) | ||
vs = as_array(copy.deepcopy(vs)) | ||
|
||
for v in vs: | ||
if v not in xs: | ||
xs.append(v) | ||
|
||
return cast(List[Any], xs) # mypy doesn't recognize it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
Transform: AWS::Serverless-2016-10-31 | ||
Resources: | ||
# Stub resources | ||
SomeFunction: | ||
Type: AWS::Lambda::Function | ||
Properties: | ||
Role: !Ref SomeRole | ||
SomeTable: | ||
Type: AWS::DynamoDB::Table | ||
SomeTopic: | ||
Type: AWS::SNS::Topic | ||
SomeQueue: | ||
Type: AWS::SQS::Queue | ||
SomeRule: | ||
Type: AWS::Events::Rule | ||
|
||
# Test AWS_IAM_ROLE_MANAGED_POLICY | ||
IamRolePolicyConnector: | ||
Type: AWS::Serverless::Connector | ||
Properties: | ||
Source: | ||
Id: SomeFunction | ||
Destination: | ||
Id: SomeTable | ||
Permissions: | ||
- Read | ||
- Write | ||
TestIamRolePolicyConnector: | ||
DependsOn: IamRolePolicyConnector | ||
Type: AWS::Foo::Bar | ||
TestIamRolePolicyConnectorMulti: | ||
DependsOn: [Foo, Egg, IamRolePolicyConnector] | ||
Type: AWS::Foo::Bar | ||
|
||
# Test AWS_SNS_TOPIC_POLICY | ||
SnsTopicPolicyConnector: | ||
Type: AWS::Serverless::Connector | ||
Properties: | ||
Source: | ||
Id: SomeRule | ||
Destination: | ||
Id: SomeTopic | ||
Permissions: | ||
- Write | ||
TestSnsTopicPolicyConnector: | ||
DependsOn: SnsTopicPolicyConnector | ||
Type: AWS::Foo::Bar | ||
TestSnsTopicPolicyConnectorMulti: | ||
DependsOn: [Foo, SnsTopicPolicyConnector] | ||
Type: AWS::Foo::Bar | ||
|
||
# Test AWS_LAMBDA_PERMISSION | ||
LambdaPermissionConnector: | ||
Type: AWS::Serverless::Connector | ||
Properties: | ||
Source: | ||
Id: SomeTopic | ||
Destination: | ||
Id: SomeFunction | ||
Permissions: | ||
- Write | ||
TestLambdaPermissionConnector: | ||
DependsOn: LambdaPermissionConnector | ||
Type: AWS::Foo::Bar | ||
TestLambdaPermissionConnectorMulti: | ||
DependsOn: [Foo, LambdaPermissionConnector, Bar] | ||
Type: AWS::Foo::Bar | ||
|
||
# Test AWS_SQS_QUEUE_POLICY | ||
SqsQueuePolicyConnector: | ||
Type: AWS::Serverless::Connector | ||
Properties: | ||
Source: | ||
Id: SomeTopic | ||
Destination: | ||
Id: SomeQueue | ||
Permissions: | ||
- Write | ||
TestSqsQueuePolicyConnector: | ||
DependsOn: SqsQueuePolicyConnector | ||
Type: AWS::Foo::Bar | ||
TestSqsQueuePolicyConnectorMulti: | ||
DependsOn: [SqsQueuePolicyConnector, Foo] | ||
Type: AWS::Foo::Bar |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.