From 680cc01ca948e18c9ba467c122e8cfa84aa05e72 Mon Sep 17 00:00:00 2001 From: sannya-singal Date: Wed, 16 Oct 2024 14:41:09 +0530 Subject: [PATCH 1/2] cfn: fix mappings in mapping-ref-map-key template to support MA/MR --- tests/aws/services/cloudformation/engine/test_mappings.py | 2 ++ tests/aws/templates/mappings/mapping-ref-map-key.yaml | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/aws/services/cloudformation/engine/test_mappings.py b/tests/aws/services/cloudformation/engine/test_mappings.py index 0a18c0580262a..93268f81d4ff2 100644 --- a/tests/aws/services/cloudformation/engine/test_mappings.py +++ b/tests/aws/services/cloudformation/engine/test_mappings.py @@ -2,6 +2,7 @@ import pytest +from localstack.constants import AWS_REGION_US_EAST_1 from localstack.testing.pytest import markers from localstack.utils.files import load_file from localstack.utils.strings import short_uid @@ -173,6 +174,7 @@ def test_mapping_ref_map_key(self, deploy_cfn_template, aws_client, map_key, sho "MapName": "MyMap", "MapKey": map_key, "TopicName": topic_name, + "Region": AWS_REGION_US_EAST_1, }, ) diff --git a/tests/aws/templates/mappings/mapping-ref-map-key.yaml b/tests/aws/templates/mappings/mapping-ref-map-key.yaml index c2876f17ec588..34fa869f1487e 100644 --- a/tests/aws/templates/mappings/mapping-ref-map-key.yaml +++ b/tests/aws/templates/mappings/mapping-ref-map-key.yaml @@ -3,9 +3,10 @@ Mappings: us-east-1: A: "true" B: "false" + Conditions: MyCondition: !Equals - - !FindInMap [ !Ref MapName, !Ref AWS::Region, !Ref MapKey] + - !FindInMap [ !Ref MapName, !Ref Region, !Ref MapKey] - "true" Parameters: @@ -18,6 +19,9 @@ Parameters: TopicName: Type: String + Region: + Type: String + Resources: MyTopic: Type: AWS::SNS::Topic @@ -32,4 +36,3 @@ Outputs: TopicArn: Value: !Ref MyTopic Condition: MyCondition - From 8b5b233284f5e114caab5edbf5d143a93ca87b4f Mon Sep 17 00:00:00 2001 From: sannya-singal Date: Wed, 16 Oct 2024 14:54:47 +0530 Subject: [PATCH 2/2] use AWS::Region in mappings --- .../cloudformation/engine/test_mappings.py | 2 -- .../mappings/mapping-ref-map-key.yaml | 26 ++++++++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/tests/aws/services/cloudformation/engine/test_mappings.py b/tests/aws/services/cloudformation/engine/test_mappings.py index 93268f81d4ff2..0a18c0580262a 100644 --- a/tests/aws/services/cloudformation/engine/test_mappings.py +++ b/tests/aws/services/cloudformation/engine/test_mappings.py @@ -2,7 +2,6 @@ import pytest -from localstack.constants import AWS_REGION_US_EAST_1 from localstack.testing.pytest import markers from localstack.utils.files import load_file from localstack.utils.strings import short_uid @@ -174,7 +173,6 @@ def test_mapping_ref_map_key(self, deploy_cfn_template, aws_client, map_key, sho "MapName": "MyMap", "MapKey": map_key, "TopicName": topic_name, - "Region": AWS_REGION_US_EAST_1, }, ) diff --git a/tests/aws/templates/mappings/mapping-ref-map-key.yaml b/tests/aws/templates/mappings/mapping-ref-map-key.yaml index 34fa869f1487e..dd5a1b5f77ec6 100644 --- a/tests/aws/templates/mappings/mapping-ref-map-key.yaml +++ b/tests/aws/templates/mappings/mapping-ref-map-key.yaml @@ -3,10 +3,31 @@ Mappings: us-east-1: A: "true" B: "false" + us-east-2: + A: "true" + B: "false" + us-west-1: + A: "true" + B: "false" + us-west-2: + A: "true" + B: "false" + ap-southeast-2: + A: "true" + B: "false" + ap-northeast-1: + A: "true" + B: "false" + eu-central-1: + A: "true" + B: "false" + eu-west-1: + A: "true" + B: "false" Conditions: MyCondition: !Equals - - !FindInMap [ !Ref MapName, !Ref Region, !Ref MapKey] + - !FindInMap [ !Ref MapName, !Ref AWS::Region, !Ref MapKey] - "true" Parameters: @@ -19,9 +40,6 @@ Parameters: TopicName: Type: String - Region: - Type: String - Resources: MyTopic: Type: AWS::SNS::Topic