-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
CloudFormation V2 Engine: Support for Pseudo Parameter References #12595
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
Changes from all commits
2106678
6d1d6c2
850d0f5
e487368
02fc9b6
971a8a7
af622e2
ae9dc0f
87bc478
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
from localstack.aws.api import RequestContext, handler | ||
from localstack.aws.api.cloudformation import ( | ||
Changes, | ||
ChangeSetNameOrId, | ||
ChangeSetNotFoundException, | ||
ChangeSetStatus, | ||
|
@@ -24,12 +25,16 @@ | |
RetainExceptOnCreate, | ||
RetainResources, | ||
RoleARN, | ||
RollbackConfiguration, | ||
StackName, | ||
StackNameOrId, | ||
StackStatus, | ||
) | ||
from localstack.services.cloudformation import api_utils | ||
from localstack.services.cloudformation.engine import template_preparer | ||
from localstack.services.cloudformation.engine.v2.change_set_model_describer import ( | ||
ChangeSetModelDescriber, | ||
) | ||
from localstack.services.cloudformation.engine.v2.change_set_model_executor import ( | ||
ChangeSetModelExecutor, | ||
) | ||
|
@@ -296,6 +301,32 @@ def _run(*args): | |
|
||
return ExecuteChangeSetOutput() | ||
|
||
def _describe_change_set( | ||
self, change_set: ChangeSet, include_property_values: bool | ||
) -> DescribeChangeSetOutput: | ||
change_set_describer = ChangeSetModelDescriber( | ||
change_set=change_set, include_property_values=include_property_values | ||
) | ||
changes: Changes = change_set_describer.get_changes() | ||
|
||
result = DescribeChangeSetOutput( | ||
Status=change_set.status, | ||
ChangeSetId=change_set.change_set_id, | ||
ChangeSetName=change_set.change_set_name, | ||
ExecutionStatus=change_set.execution_status, | ||
RollbackConfiguration=RollbackConfiguration(), | ||
StackId=change_set.stack.stack_id, | ||
StackName=change_set.stack.stack_name, | ||
CreationTime=change_set.creation_time, | ||
Parameters=[ | ||
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. Can we keep the todo about masking ? |
||
# TODO: add masking support. | ||
Parameter(ParameterKey=key, ParameterValue=value) | ||
for (key, value) in change_set.stack.resolved_parameters.items() | ||
], | ||
Changes=changes, | ||
) | ||
return result | ||
|
||
@handler("DescribeChangeSet") | ||
def describe_change_set( | ||
self, | ||
|
@@ -312,9 +343,8 @@ def describe_change_set( | |
change_set = find_change_set_v2(state, change_set_name, stack_name) | ||
if not change_set: | ||
raise ChangeSetNotFoundException(f"ChangeSet [{change_set_name}] does not exist") | ||
|
||
result = change_set.describe_details( | ||
include_property_values=include_property_values or False | ||
result = self._describe_change_set( | ||
change_set=change_set, include_property_values=include_property_values or False | ||
) | ||
return result | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -309,3 +309,40 @@ def test_immutable_property_update_causes_resource_replacement( | |
} | ||
} | ||
capture_update_process(snapshot, template_1, template_2) | ||
|
||
@markers.aws.validated | ||
def test_supported_pseudo_parameter( | ||
self, | ||
snapshot, | ||
capture_update_process, | ||
): | ||
topic_name_1 = f"topic-name-1-{long_uid()}" | ||
snapshot.add_transformer(RegexTransformer(topic_name_1, "topic_name_1")) | ||
topic_name_2 = f"topic-name-2-{long_uid()}" | ||
snapshot.add_transformer(RegexTransformer(topic_name_2, "topic_name_2")) | ||
snapshot.add_transformer(RegexTransformer("amazonaws.com", "url_suffix")) | ||
snapshot.add_transformer(RegexTransformer("localhost.localstack.cloud", "url_suffix")) | ||
template_1 = { | ||
"Resources": { | ||
"Topic1": {"Type": "AWS::SNS::Topic", "Properties": {"TopicName": topic_name_1}}, | ||
} | ||
} | ||
template_2 = { | ||
"Resources": { | ||
"Topic2": { | ||
"Type": "AWS::SNS::Topic", | ||
"Properties": { | ||
"TopicName": topic_name_2, | ||
"Tags": [ | ||
{"Key": "Partition", "Value": {"Ref": "AWS::Partition"}}, | ||
{"Key": "AccountId", "Value": {"Ref": "AWS::AccountId"}}, | ||
{"Key": "Region", "Value": {"Ref": "AWS::Region"}}, | ||
{"Key": "StackName", "Value": {"Ref": "AWS::StackName"}}, | ||
{"Key": "StackId", "Value": {"Ref": "AWS::StackId"}}, | ||
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. We don't cover urlsuffix here. I realise that by definition it will be different from AWS to LocalStack but at least it would be execute the code path |
||
{"Key": "URLSuffix", "Value": {"Ref": "AWS::URLSuffix"}}, | ||
], | ||
}, | ||
}, | ||
} | ||
} | ||
capture_update_process(snapshot, template_1, template_2) |
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.
Great I'm glad it's in the provider.