-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
CloudFormation v2 Engine: Base Support for Fn::Split #12698
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
17 commits
Select commit
Hold shift + click to select a range
8f14387
base support for dependson and apigw test unlock
MEPalma 2bfc135
base support for fn sub
MEPalma 648fcf1
Merge branch 'master' into MEP-CFN-fn_sub
MEPalma 66937e0
v1 tests port, test annotations, batch of parity improvements
MEPalma 75d12d6
base support for fn::transform
MEPalma 47a0a1a
typing migration, change types compute, unskip
MEPalma 653122e
None bindins prune the value
MEPalma bcb65f2
minor
MEPalma 52008ee
minor
MEPalma 795d3a0
support for fn::select
MEPalma 2833ff3
tests
MEPalma f55f012
split tests
MEPalma 498c08b
base support for split
MEPalma 08dec8f
conflicts
MEPalma a465e2f
cleanup
MEPalma 1efeb73
missing type hint
MEPalma f0b1dfc
skip message
MEPalma 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
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
243 changes: 243 additions & 0 deletions
243
tests/aws/services/cloudformation/v2/test_change_set_fn_split.py
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,243 @@ | ||
import pytest | ||
from localstack_snapshot.snapshots.transformer import RegexTransformer | ||
|
||
from localstack.services.cloudformation.v2.utils import is_v2_engine | ||
from localstack.testing.aws.util import is_aws_cloud | ||
from localstack.testing.pytest import markers | ||
from localstack.utils.strings import long_uid | ||
|
||
|
||
@pytest.mark.skipif( | ||
condition=not is_v2_engine() and not is_aws_cloud(), reason="Requires the V2 engine" | ||
) | ||
@markers.snapshot.skip_snapshot_verify( | ||
paths=[ | ||
"per-resource-events..*", | ||
"delete-describe..*", | ||
# | ||
# Before/After Context | ||
"$..Capabilities", | ||
"$..NotificationARNs", | ||
"$..IncludeNestedStacks", | ||
"$..Scope", | ||
"$..Details", | ||
"$..Parameters", | ||
"$..Replacement", | ||
"$..PolicyAction", | ||
"$..StatusReason", | ||
] | ||
) | ||
class TestChangeSetFnSplit: | ||
@markers.aws.validated | ||
def test_fn_split_add_to_static_property( | ||
self, | ||
snapshot, | ||
capture_update_process, | ||
): | ||
name1 = f"topic-name-1-{long_uid()}" | ||
snapshot.add_transformer(RegexTransformer(name1, "topic-name-1")) | ||
snapshot.add_transformer(RegexTransformer(name1.replace("-", "_"), "topic_name_1")) | ||
template_1 = { | ||
"Resources": { | ||
"Topic1": {"Type": "AWS::SNS::Topic", "Properties": {"DisplayName": name1}} | ||
} | ||
} | ||
template_2 = { | ||
"Resources": { | ||
"Topic1": { | ||
"Type": "AWS::SNS::Topic", | ||
"Properties": { | ||
"DisplayName": { | ||
"Fn::Join": [ | ||
"_", | ||
{"Fn::Split": ["-", "part1-part2-part3"]}, | ||
] | ||
} | ||
}, | ||
} | ||
} | ||
} | ||
capture_update_process(snapshot, template_1, template_2) | ||
|
||
@markers.aws.validated | ||
def test_fn_split_remove_from_static_property( | ||
self, | ||
snapshot, | ||
capture_update_process, | ||
): | ||
name1 = f"topic-name-1-{long_uid()}" | ||
snapshot.add_transformer(RegexTransformer(name1, "topic-name-1")) | ||
snapshot.add_transformer(RegexTransformer(name1, "topic-name-1")) | ||
snapshot.add_transformer(RegexTransformer(name1.replace("-", "_"), "topic_name_1")) | ||
template_1 = { | ||
"Resources": { | ||
"Topic1": { | ||
"Type": "AWS::SNS::Topic", | ||
"Properties": { | ||
"DisplayName": { | ||
"Fn::Join": [ | ||
"_", | ||
{"Fn::Split": ["-", "part1-part2-part3"]}, | ||
] | ||
} | ||
}, | ||
} | ||
} | ||
} | ||
template_2 = { | ||
"Resources": { | ||
"Topic1": {"Type": "AWS::SNS::Topic", "Properties": {"DisplayName": name1}} | ||
} | ||
} | ||
capture_update_process(snapshot, template_1, template_2) | ||
|
||
@markers.aws.validated | ||
def test_fn_split_change_delimiter( | ||
self, | ||
snapshot, | ||
capture_update_process, | ||
): | ||
template_1 = { | ||
"Resources": { | ||
"Topic1": { | ||
"Type": "AWS::SNS::Topic", | ||
"Properties": { | ||
"DisplayName": {"Fn::Join": ["_", {"Fn::Split": ["-", "a-b--c::d"]}]} | ||
}, | ||
} | ||
} | ||
} | ||
template_2 = { | ||
"Resources": { | ||
"Topic1": { | ||
"Type": "AWS::SNS::Topic", | ||
"Properties": { | ||
"DisplayName": {"Fn::Join": ["_", {"Fn::Split": [":", "a-b--c::d"]}]} | ||
}, | ||
} | ||
} | ||
} | ||
capture_update_process(snapshot, template_1, template_2) | ||
|
||
@markers.aws.validated | ||
def test_fn_split_change_source_string_only( | ||
self, | ||
snapshot, | ||
capture_update_process, | ||
): | ||
template_1 = { | ||
"Resources": { | ||
"Topic1": { | ||
"Type": "AWS::SNS::Topic", | ||
"Properties": {"DisplayName": {"Fn::Join": ["_", {"Fn::Split": ["-", "a-b"]}]}}, | ||
} | ||
} | ||
} | ||
template_2 = { | ||
"Resources": { | ||
"Topic1": { | ||
"Type": "AWS::SNS::Topic", | ||
"Properties": { | ||
"DisplayName": {"Fn::Join": ["_", {"Fn::Split": ["-", "x-y-z"]}]} | ||
}, | ||
} | ||
} | ||
} | ||
capture_update_process(snapshot, template_1, template_2) | ||
|
||
@markers.aws.validated | ||
def test_fn_split_with_ref_as_string_source( | ||
self, | ||
snapshot, | ||
capture_update_process, | ||
): | ||
param_name = "DelimiterParam" | ||
template_1 = { | ||
"Parameters": {param_name: {"Type": "String", "Default": "hello-world"}}, | ||
"Resources": { | ||
"Topic1": { | ||
"Type": "AWS::SNS::Topic", | ||
"Properties": { | ||
"DisplayName": { | ||
"Fn::Join": ["_", {"Fn::Split": ["-", {"Ref": param_name}]}] | ||
} | ||
}, | ||
} | ||
}, | ||
} | ||
template_2 = { | ||
"Parameters": {param_name: {"Type": "String", "Default": "foo-bar-baz"}}, | ||
"Resources": { | ||
"Topic1": { | ||
"Type": "AWS::SNS::Topic", | ||
"Properties": { | ||
"DisplayName": { | ||
"Fn::Join": ["_", {"Fn::Split": ["-", {"Ref": param_name}]}] | ||
} | ||
}, | ||
} | ||
}, | ||
} | ||
capture_update_process(snapshot, template_1, template_2) | ||
|
||
@markers.snapshot.skip_snapshot_verify( | ||
paths=[ | ||
# Reason: AWS incorrectly does not list the second and third topic as | ||
# needing modifying, however it needs to | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😂 |
||
"describe-change-set-2-prop-values..Changes", | ||
] | ||
) | ||
@markers.aws.validated | ||
def test_fn_split_with_get_att( | ||
self, | ||
snapshot, | ||
capture_update_process, | ||
): | ||
name1 = f"topic-name-1-{long_uid()}" | ||
name2 = f"topic-name-2-{long_uid()}" | ||
snapshot.add_transformer(RegexTransformer(name1, "topic-name-1")) | ||
snapshot.add_transformer(RegexTransformer(name1.replace("-", "_"), "topic_name_1")) | ||
snapshot.add_transformer(RegexTransformer(name2, "topic-name-2")) | ||
snapshot.add_transformer(RegexTransformer(name2.replace("-", "_"), "topic_name_2")) | ||
|
||
template_1 = { | ||
"Resources": { | ||
"Topic1": { | ||
"Type": "AWS::SNS::Topic", | ||
"Properties": {"DisplayName": name1}, | ||
}, | ||
"Topic2": { | ||
"Type": "AWS::SNS::Topic", | ||
"Properties": { | ||
"DisplayName": { | ||
"Fn::Join": [ | ||
"_", | ||
{"Fn::Split": ["-", {"Fn::GetAtt": ["Topic1", "DisplayName"]}]}, | ||
] | ||
} | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
template_2 = { | ||
"Resources": { | ||
"Topic1": { | ||
"Type": "AWS::SNS::Topic", | ||
"Properties": {"DisplayName": name2}, | ||
}, | ||
"Topic2": { | ||
"Type": "AWS::SNS::Topic", | ||
"Properties": { | ||
"DisplayName": { | ||
"Fn::Join": [ | ||
"_", | ||
{"Fn::Split": ["-", {"Fn::GetAtt": ["Topic1", "DisplayName"]}]}, | ||
] | ||
} | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
capture_update_process(snapshot, template_1, template_2) |
Oops, something went wrong.
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.
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.
🎉