From 1113c676aebc88cdfa5d19b8ac9e03444d8f3db8 Mon Sep 17 00:00:00 2001 From: Vichym Date: Mon, 24 Mar 2025 20:13:14 -0700 Subject: [PATCH 1/8] fix(lambda): enforce lambda alias alphanumeric logical id --- samtranslator/model/sam_resources.py | 21 ++++++++-- tests/translator/test_function_resources.py | 43 +++++++++++++++++++-- 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/samtranslator/model/sam_resources.py b/samtranslator/model/sam_resources.py index 397b7666d..c830f6bcd 100644 --- a/samtranslator/model/sam_resources.py +++ b/samtranslator/model/sam_resources.py @@ -1,6 +1,7 @@ """ SAM macro definitions """ import copy +import re from contextlib import suppress from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union, cast @@ -238,7 +239,6 @@ class SamFunction(SamResourceMacro): # DeadLetterQueue dead_letter_queue_policy_actions = {"SQS": "sqs:SendMessage", "SNS": "sns:Publish"} - # # Conditions conditions: Dict[str, Any] = {} # TODO: Replace `Any` with something more specific @@ -325,7 +325,7 @@ def to_cloudformation(self, **kwargs): # type: ignore[no-untyped-def] # noqa: P resources.append(url_permission) self._validate_deployment_preference_and_add_update_policy( - kwargs.get("deployment_preference_collection", None), + kwargs.get("deployment_preference_collection"), lambda_alias, intrinsics_resolver, cast(IntrinsicsResolver, mappings_resolver), # TODO: better handle mappings_resolver's Optional @@ -1002,7 +1002,22 @@ def _construct_alias(self, name: str, function: LambdaFunction, version: LambdaV if not name: raise InvalidResourceException(self.logical_id, "Alias name is required to create an alias") - logical_id = f"{function.logical_id}Alias{name}" + # Validate alias name against the required pattern: (?!^[0-9]+$)([a-zA-Z0-9-_]+) + # This ensures the alias name: + # 1. Contains only alphanumeric characters, hyphens, and underscores + # 2. Is not purely numeric + ALIAS_REGEX = r"(?!^[0-9]+$)([a-zA-Z0-9\-_]+)$" + if not re.match(ALIAS_REGEX, name): + raise InvalidResourceException( + self.logical_id, + f"Alias name ('{name}') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)", + ) + + # Strip hyphens and underscores from the alias name for the logical ID + # This ensures the logical ID contains only alphanumeric characters + alias_alphanumeric_name = re.sub(r"[-_]", "", name) + + logical_id = f"{function.logical_id}Alias{alias_alphanumeric_name}" alias = LambdaAlias(logical_id=logical_id, attributes=self.get_passthrough_resource_attributes()) alias.Name = name alias.FunctionName = function.get_runtime_attr("name") diff --git a/tests/translator/test_function_resources.py b/tests/translator/test_function_resources.py index 5fa2d0aa4..f58034967 100644 --- a/tests/translator/test_function_resources.py +++ b/tests/translator/test_function_resources.py @@ -776,9 +776,46 @@ def test_alias_creation(self): self.assertEqual(alias.FunctionName, {"Ref": self.lambda_func.logical_id}) self.assertEqual(alias.FunctionVersion, {"Fn::GetAtt": [self.lambda_version.logical_id, "Version"]}) - def test_alias_creation_error(self): - with self.assertRaises(InvalidResourceException): - self.sam_func._construct_alias(None, self.lambda_func, self.lambda_version) + @parameterized.expand([ + # Valid cases + # Expect logical id should be {fn name}{'Alias'}{alphanumerica alias name without `-`` or `_`} + ("aliasname", "fooAliasaliasname"), + ("alias-name", "fooAliasaliasname"), + ("alias_name", "fooAliasaliasname"), + ("alias123", "fooAliasalias123"), + ("123alias", "fooAlias123alias"), + ("UPPERCASE", "fooAliasUPPERCASE"), + ("mixed-Case_123", "fooAliasmixedCase123"), + ("a", "fooAliasa"), # Single character + ("1a", 'fooAlias1a'), # Starts with number but contains letter + ]) + def test_alias_creation(self, alias_name, expected_logical_id): + alias = self.sam_func._construct_alias(alias_name, self.lambda_func, self.lambda_version) + + self.assertEqual(alias.logical_id, expected_logical_id) + self.assertEqual(alias.Name, alias_name) + self.assertEqual(alias.FunctionName, {"Ref": self.lambda_func.logical_id}) + self.assertEqual(alias.FunctionVersion, {"Fn::GetAtt": [self.lambda_version.logical_id, "Version"]}) + + + @parameterized.expand([ + # Invalid cases + ("", "Resource with id [foo] is invalid. Alias name is required to create an alias"), + (None, "Resource with id [foo] is invalid. Alias name is required to create an alias"), + ("123", "Resource with id [foo] is invalid. Alias name ('123') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)"), + ("name with space", "Resource with id [foo] is invalid. Alias name ('name with space') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)"), + ("alias@name", "Resource with id [foo] is invalid. Alias name ('alias@name') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)"), + ("alias/name", "Resource with id [foo] is invalid. Alias name ('alias/name') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)"), + ]) + def test_alias_creation_error(self, alias_name, expected_error_massage): + with self.assertRaises(InvalidResourceException) as context: + self.sam_func._construct_alias(alias_name, self.lambda_func, self.lambda_version) + + error = context.exception + self.assertEqual( + str(error.message), + expected_error_massage + ) def test_get_resolved_alias_name_must_work(self): property_name = "something" From fc8711447d85eff1c220a95e37b3fa91fb0eaf10 Mon Sep 17 00:00:00 2001 From: Vichym Date: Mon, 24 Mar 2025 20:28:27 -0700 Subject: [PATCH 2/8] fix lint --- tests/translator/test_function_resources.py | 68 ++++++++++++--------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/tests/translator/test_function_resources.py b/tests/translator/test_function_resources.py index f58034967..b721b880a 100644 --- a/tests/translator/test_function_resources.py +++ b/tests/translator/test_function_resources.py @@ -776,19 +776,21 @@ def test_alias_creation(self): self.assertEqual(alias.FunctionName, {"Ref": self.lambda_func.logical_id}) self.assertEqual(alias.FunctionVersion, {"Fn::GetAtt": [self.lambda_version.logical_id, "Version"]}) - @parameterized.expand([ - # Valid cases - # Expect logical id should be {fn name}{'Alias'}{alphanumerica alias name without `-`` or `_`} - ("aliasname", "fooAliasaliasname"), - ("alias-name", "fooAliasaliasname"), - ("alias_name", "fooAliasaliasname"), - ("alias123", "fooAliasalias123"), - ("123alias", "fooAlias123alias"), - ("UPPERCASE", "fooAliasUPPERCASE"), - ("mixed-Case_123", "fooAliasmixedCase123"), - ("a", "fooAliasa"), # Single character - ("1a", 'fooAlias1a'), # Starts with number but contains letter - ]) + @parameterized.expand( + [ + # Valid cases + # Expect logical id should be {fn name}{'Alias'}{alphanumerica alias name without `-`` or `_`} + ("aliasname", "fooAliasaliasname"), + ("alias-name", "fooAliasaliasname"), + ("alias_name", "fooAliasaliasname"), + ("alias123", "fooAliasalias123"), + ("123alias", "fooAlias123alias"), + ("UPPERCASE", "fooAliasUPPERCASE"), + ("mixed-Case_123", "fooAliasmixedCase123"), + ("a", "fooAliasa"), # Single character + ("1a", "fooAlias1a"), # Starts with number but contains letter + ] + ) def test_alias_creation(self, alias_name, expected_logical_id): alias = self.sam_func._construct_alias(alias_name, self.lambda_func, self.lambda_version) @@ -797,25 +799,35 @@ def test_alias_creation(self, alias_name, expected_logical_id): self.assertEqual(alias.FunctionName, {"Ref": self.lambda_func.logical_id}) self.assertEqual(alias.FunctionVersion, {"Fn::GetAtt": [self.lambda_version.logical_id, "Version"]}) - - @parameterized.expand([ - # Invalid cases - ("", "Resource with id [foo] is invalid. Alias name is required to create an alias"), - (None, "Resource with id [foo] is invalid. Alias name is required to create an alias"), - ("123", "Resource with id [foo] is invalid. Alias name ('123') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)"), - ("name with space", "Resource with id [foo] is invalid. Alias name ('name with space') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)"), - ("alias@name", "Resource with id [foo] is invalid. Alias name ('alias@name') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)"), - ("alias/name", "Resource with id [foo] is invalid. Alias name ('alias/name') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)"), - ]) + @parameterized.expand( + [ + # Invalid cases + ("", "Resource with id [foo] is invalid. Alias name is required to create an alias"), + (None, "Resource with id [foo] is invalid. Alias name is required to create an alias"), + ( + "123", + "Resource with id [foo] is invalid. Alias name ('123') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)", + ), + ( + "name with space", + "Resource with id [foo] is invalid. Alias name ('name with space') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)", + ), + ( + "alias@name", + "Resource with id [foo] is invalid. Alias name ('alias@name') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)", + ), + ( + "alias/name", + "Resource with id [foo] is invalid. Alias name ('alias/name') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)", + ), + ] + ) def test_alias_creation_error(self, alias_name, expected_error_massage): with self.assertRaises(InvalidResourceException) as context: self.sam_func._construct_alias(alias_name, self.lambda_func, self.lambda_version) - + error = context.exception - self.assertEqual( - str(error.message), - expected_error_massage - ) + self.assertEqual(str(error.message), expected_error_massage) def test_get_resolved_alias_name_must_work(self): property_name = "something" From a986f96752b94cf0bf119c2999227446cc6c1cd4 Mon Sep 17 00:00:00 2001 From: Vichym Date: Mon, 24 Mar 2025 20:31:44 -0700 Subject: [PATCH 3/8] fix: rename duplicate test method to resolve linting error --- tests/translator/test_function_resources.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tests/translator/test_function_resources.py b/tests/translator/test_function_resources.py index b721b880a..ce6f47511 100644 --- a/tests/translator/test_function_resources.py +++ b/tests/translator/test_function_resources.py @@ -765,17 +765,6 @@ def test_version_logical_id_changes_with_snapstart(self): self.assertNotEqual(version1.logical_id, version_snapstart.logical_id) self.assertEqual(version1.logical_id, version_snapstart_none.logical_id) - def test_alias_creation(self): - name = "aliasname" - - alias = self.sam_func._construct_alias(name, self.lambda_func, self.lambda_version) - - expected_logical_id = f"{self.lambda_func.logical_id}Alias{name}" - self.assertEqual(alias.logical_id, expected_logical_id) - self.assertEqual(alias.Name, name) - self.assertEqual(alias.FunctionName, {"Ref": self.lambda_func.logical_id}) - self.assertEqual(alias.FunctionVersion, {"Fn::GetAtt": [self.lambda_version.logical_id, "Version"]}) - @parameterized.expand( [ # Valid cases From 1b88bb3133ad6351124bf0b5c2f1d23a73932e0a Mon Sep 17 00:00:00 2001 From: Vichym Date: Mon, 24 Mar 2025 20:48:43 -0700 Subject: [PATCH 4/8] fix lint issue with _validate_deployment_preference_and_add_update_policy() --- samtranslator/model/sam_resources.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samtranslator/model/sam_resources.py b/samtranslator/model/sam_resources.py index c830f6bcd..0832dcb6d 100644 --- a/samtranslator/model/sam_resources.py +++ b/samtranslator/model/sam_resources.py @@ -1029,7 +1029,7 @@ def _construct_alias(self, name: str, function: LambdaFunction, version: LambdaV def _validate_deployment_preference_and_add_update_policy( # noqa: PLR0913 self, - deployment_preference_collection: DeploymentPreferenceCollection, + deployment_preference_collection: Optional[DeploymentPreferenceCollection], lambda_alias: Optional[LambdaAlias], intrinsics_resolver: IntrinsicsResolver, mappings_resolver: IntrinsicsResolver, From 023ea1a780c7b1097f9d1d8d71e4fb3eec0453ae Mon Sep 17 00:00:00 2001 From: Vichym Date: Tue, 25 Mar 2025 15:03:13 -0700 Subject: [PATCH 5/8] update logic for alias logical id --- samtranslator/model/sam_resources.py | 2 +- tests/translator/test_function_resources.py | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/samtranslator/model/sam_resources.py b/samtranslator/model/sam_resources.py index 0832dcb6d..2d31de7cd 100644 --- a/samtranslator/model/sam_resources.py +++ b/samtranslator/model/sam_resources.py @@ -1015,7 +1015,7 @@ def _construct_alias(self, name: str, function: LambdaFunction, version: LambdaV # Strip hyphens and underscores from the alias name for the logical ID # This ensures the logical ID contains only alphanumeric characters - alias_alphanumeric_name = re.sub(r"[-_]", "", name) + alias_alphanumeric_name = name.replace("-", "D").replace("_", "U") logical_id = f"{function.logical_id}Alias{alias_alphanumeric_name}" alias = LambdaAlias(logical_id=logical_id, attributes=self.get_passthrough_resource_attributes()) diff --git a/tests/translator/test_function_resources.py b/tests/translator/test_function_resources.py index ce6f47511..455de710d 100644 --- a/tests/translator/test_function_resources.py +++ b/tests/translator/test_function_resources.py @@ -768,16 +768,26 @@ def test_version_logical_id_changes_with_snapstart(self): @parameterized.expand( [ # Valid cases - # Expect logical id should be {fn name}{'Alias'}{alphanumerica alias name without `-`` or `_`} + # Expect logical id should be {fn name}{'Alias'}{alphanumerica alias name without `-` or `_`} ("aliasname", "fooAliasaliasname"), - ("alias-name", "fooAliasaliasname"), - ("alias_name", "fooAliasaliasname"), + ("alias-name", "fooAliasaliasDname"), + ("alias_name", "fooAliasaliasUname"), ("alias123", "fooAliasalias123"), ("123alias", "fooAlias123alias"), ("UPPERCASE", "fooAliasUPPERCASE"), - ("mixed-Case_123", "fooAliasmixedCase123"), + ("mixed-Case_123", "fooAliasmixedDCaseU123"), ("a", "fooAliasa"), # Single character - ("1a", "fooAlias1a"), # Starts with number but contains letter + ("1a", "fooAlias1a"), # Starts with number + # Check the placement of dash and underscore + ("1-1_1", "fooAlias1D1U1"), + ("1_1-1", "fooAlias1U1D1"), + ("11-1", "fooAlias11D1"), + ("1-11", "fooAlias1D11"), + ("11_1", "fooAlias11U1"), + ("1_11", "fooAlias1U11"), + ("1-1-1", "fooAlias1D1D1"), + ("-1-1-1-", "fooAliasD1D1D1D"), + ("_1_1-1-", "fooAliasU1U1D1D"), ] ) def test_alias_creation(self, alias_name, expected_logical_id): From 549bb676875c145d4d6bb263976d390e73fb67f4 Mon Sep 17 00:00:00 2001 From: Vichym Date: Thu, 27 Mar 2025 10:53:57 -0700 Subject: [PATCH 6/8] add transform failure test and update error message --- samtranslator/model/sam_resources.py | 2 +- .../error_function_invalid_autopublishalias_name.yaml | 9 +++++++++ .../error_function_invalid_autopublishalias_name.json | 9 +++++++++ tests/translator/test_function_resources.py | 8 ++++---- 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 tests/translator/input/error_function_invalid_autopublishalias_name.yaml create mode 100644 tests/translator/output/error_function_invalid_autopublishalias_name.json diff --git a/samtranslator/model/sam_resources.py b/samtranslator/model/sam_resources.py index 2d31de7cd..f50cc00f5 100644 --- a/samtranslator/model/sam_resources.py +++ b/samtranslator/model/sam_resources.py @@ -1010,7 +1010,7 @@ def _construct_alias(self, name: str, function: LambdaFunction, version: LambdaV if not re.match(ALIAS_REGEX, name): raise InvalidResourceException( self.logical_id, - f"Alias name ('{name}') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)", + f"AutoPublishAlias name ('{name}') must contain only alphanumeric characters, hyphens, or underscores matching (?!^[0-9]+$)([a-zA-Z0-9-_]+) pattern.", ) # Strip hyphens and underscores from the alias name for the logical ID diff --git a/tests/translator/input/error_function_invalid_autopublishalias_name.yaml b/tests/translator/input/error_function_invalid_autopublishalias_name.yaml new file mode 100644 index 000000000..34eb31ff1 --- /dev/null +++ b/tests/translator/input/error_function_invalid_autopublishalias_name.yaml @@ -0,0 +1,9 @@ +Resources: + MyFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/hello.zip + Handler: hello.handler + Runtime: python3.9 + # Using an invalid alias name with special characters that can't be properly transformed + AutoPublishAlias: invalid*alias@name diff --git a/tests/translator/output/error_function_invalid_autopublishalias_name.json b/tests/translator/output/error_function_invalid_autopublishalias_name.json new file mode 100644 index 000000000..dd8cc09ec --- /dev/null +++ b/tests/translator/output/error_function_invalid_autopublishalias_name.json @@ -0,0 +1,9 @@ +{ + "_autoGeneratedBreakdownErrorMessage": [ + "Invalid Serverless Application Specification document. ", + "Number of errors found: 1. ", + "Resource with id [MyFunction] is invalid. ", + "AutoPublishAlias name ('invalid*alias@name') must contain only alphanumeric characters, hyphens, or underscores matching (?!^[0-9]+$)([a-zA-Z0-9-_]+) pattern." + ], + "errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [MyFunction] is invalid. AutoPublishAlias name ('invalid*alias@name') must contain only alphanumeric characters, hyphens, or underscores matching (?!^[0-9]+$)([a-zA-Z0-9-_]+) pattern." +} diff --git a/tests/translator/test_function_resources.py b/tests/translator/test_function_resources.py index 455de710d..ad0c0185f 100644 --- a/tests/translator/test_function_resources.py +++ b/tests/translator/test_function_resources.py @@ -805,19 +805,19 @@ def test_alias_creation(self, alias_name, expected_logical_id): (None, "Resource with id [foo] is invalid. Alias name is required to create an alias"), ( "123", - "Resource with id [foo] is invalid. Alias name ('123') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)", + "Resource with id [foo] is invalid. AutoPublishAlias name ('123') must contain only alphanumeric characters, hyphens, or underscores matching (?!^[0-9]+$)([a-zA-Z0-9-_]+) pattern.", ), ( "name with space", - "Resource with id [foo] is invalid. Alias name ('name with space') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)", + "Resource with id [foo] is invalid. AutoPublishAlias name ('name with space') must contain only alphanumeric characters, hyphens, or underscores matching (?!^[0-9]+$)([a-zA-Z0-9-_]+) pattern.", ), ( "alias@name", - "Resource with id [foo] is invalid. Alias name ('alias@name') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)", + "Resource with id [foo] is invalid. AutoPublishAlias name ('alias@name') must contain only alphanumeric characters, hyphens, or underscores matching (?!^[0-9]+$)([a-zA-Z0-9-_]+) pattern.", ), ( "alias/name", - "Resource with id [foo] is invalid. Alias name ('alias/name') does not match pattern (?!^[0-9]+$)([a-zA-Z0-9-_]+)", + "Resource with id [foo] is invalid. AutoPublishAlias name ('alias/name') must contain only alphanumeric characters, hyphens, or underscores matching (?!^[0-9]+$)([a-zA-Z0-9-_]+) pattern.", ), ] ) From 8be8d8d0e93c893b42823dfebceb78e5035a7811 Mon Sep 17 00:00:00 2001 From: Vichym Date: Fri, 4 Apr 2025 15:00:47 -0700 Subject: [PATCH 7/8] add positve test --- .../function_with_alias_valid_names.yaml | 54 +++ .../function_with_alias_valid_names.json | 424 ++++++++++++++++++ .../function_with_alias_valid_names.json | 424 ++++++++++++++++++ .../function_with_alias_valid_names.json | 424 ++++++++++++++++++ 4 files changed, 1326 insertions(+) create mode 100644 tests/translator/input/function_with_alias_valid_names.yaml create mode 100644 tests/translator/output/aws-cn/function_with_alias_valid_names.json create mode 100644 tests/translator/output/aws-us-gov/function_with_alias_valid_names.json create mode 100644 tests/translator/output/function_with_alias_valid_names.json diff --git a/tests/translator/input/function_with_alias_valid_names.yaml b/tests/translator/input/function_with_alias_valid_names.yaml new file mode 100644 index 000000000..e053f0543 --- /dev/null +++ b/tests/translator/input/function_with_alias_valid_names.yaml @@ -0,0 +1,54 @@ +Resources: + FunctionAliasNameCamelCase: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/hello.zip + Handler: hello.handler + Runtime: python3.9 + AutoPublishAlias: camelCaseName + VersionDescription: sam-testing + + FunctionAliasNameUpperCase: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/hello.zip + Handler: hello.handler + Runtime: python3.9 + AutoPublishAlias: UPPERCASE + VersionDescription: sam-testing + + FunctionAliasNameLowerCase: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/hello.zip + Handler: hello.handler + Runtime: python3.9 + AutoPublishAlias: lowercase + VersionDescription: sam-testing + + FunctionAliasNameUnderscore: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/hello.zip + Handler: hello.handler + Runtime: python3.9 + AutoPublishAlias: _underscore_name_ + VersionDescription: sam-testing + + FunctionAliasNameDash: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/hello.zip + Handler: hello.handler + Runtime: python3.9 + AutoPublishAlias: underscore-name + VersionDescription: sam-testing + + FunctionAliasNameMix: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/hello.zip + Handler: hello.handler + Runtime: python3.9 + AutoPublishAlias: underScoreNAME_with-dash-01234 + VersionDescription: sam-testing diff --git a/tests/translator/output/aws-cn/function_with_alias_valid_names.json b/tests/translator/output/aws-cn/function_with_alias_valid_names.json new file mode 100644 index 000000000..3362a5c27 --- /dev/null +++ b/tests/translator/output/aws-cn/function_with_alias_valid_names.json @@ -0,0 +1,424 @@ +{ + "Resources": { + "FunctionAliasNameCamelCase": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameCamelCaseRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameCamelCaseVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameCamelCase" + } + } + }, + "FunctionAliasNameCamelCaseAliascamelCaseName": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "camelCaseName", + "FunctionName": { + "Ref": "FunctionAliasNameCamelCase" + }, + "FunctionVersion": { + "Fn::GetAtt": [ + "FunctionAliasNameCamelCaseVersion640128d35d", + "Version" + ] + } + } + }, + "FunctionAliasNameCamelCaseRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameUpperCase": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameUpperCaseRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameUpperCaseVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameUpperCase" + } + } + }, + "FunctionAliasNameUpperCaseAliasUPPERCASE": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "UPPERCASE", + "FunctionName": { + "Ref": "FunctionAliasNameUpperCase" + }, + "FunctionVersion": { + "Fn::GetAtt": [ + "FunctionAliasNameUpperCaseVersion640128d35d", + "Version" + ] + } + } + }, + "FunctionAliasNameUpperCaseRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameLowerCase": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameLowerCaseRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameLowerCaseVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameLowerCase" + } + } + }, + "FunctionAliasNameLowerCaseAliaslowercase": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "lowercase", + "FunctionName": { + "Ref": "FunctionAliasNameLowerCase" + }, + "FunctionVersion": { + "Fn::GetAtt": [ + "FunctionAliasNameLowerCaseVersion640128d35d", + "Version" + ] + } + } + }, + "FunctionAliasNameLowerCaseRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameUnderscore": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameUnderscoreRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameUnderscoreVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameUnderscore" + } + } + }, + "FunctionAliasNameUnderscoreAliasUunderscoreUnameU": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "_underscore_name_", + "FunctionName": { + "Ref": "FunctionAliasNameUnderscore" + }, + "FunctionVersion": { + "Fn::GetAtt": [ + "FunctionAliasNameUnderscoreVersion640128d35d", + "Version" + ] + } + } + }, + "FunctionAliasNameUnderscoreRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameDash": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameDashRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameDashVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameDash" + } + } + }, + "FunctionAliasNameDashAliasunderscoreDname": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "underscore-name", + "FunctionName": { + "Ref": "FunctionAliasNameDash" + }, + "FunctionVersion": { + "Fn::GetAtt": ["FunctionAliasNameDashVersion640128d35d", "Version"] + } + } + }, + "FunctionAliasNameDashRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameMix": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameMixRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameMixVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameMix" + } + } + }, + "FunctionAliasNameMixAliasunderScoreNAMEUwithDdashD01234": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "underScoreNAME_with-dash-01234", + "FunctionName": { + "Ref": "FunctionAliasNameMix" + }, + "FunctionVersion": { + "Fn::GetAtt": ["FunctionAliasNameMixVersion640128d35d", "Version"] + } + } + }, + "FunctionAliasNameMixRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + } + } +} diff --git a/tests/translator/output/aws-us-gov/function_with_alias_valid_names.json b/tests/translator/output/aws-us-gov/function_with_alias_valid_names.json new file mode 100644 index 000000000..fd6f7bf80 --- /dev/null +++ b/tests/translator/output/aws-us-gov/function_with_alias_valid_names.json @@ -0,0 +1,424 @@ +{ + "Resources": { + "FunctionAliasNameCamelCase": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameCamelCaseRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameCamelCaseVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameCamelCase" + } + } + }, + "FunctionAliasNameCamelCaseAliascamelCaseName": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "camelCaseName", + "FunctionName": { + "Ref": "FunctionAliasNameCamelCase" + }, + "FunctionVersion": { + "Fn::GetAtt": [ + "FunctionAliasNameCamelCaseVersion640128d35d", + "Version" + ] + } + } + }, + "FunctionAliasNameCamelCaseRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameUpperCase": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameUpperCaseRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameUpperCaseVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameUpperCase" + } + } + }, + "FunctionAliasNameUpperCaseAliasUPPERCASE": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "UPPERCASE", + "FunctionName": { + "Ref": "FunctionAliasNameUpperCase" + }, + "FunctionVersion": { + "Fn::GetAtt": [ + "FunctionAliasNameUpperCaseVersion640128d35d", + "Version" + ] + } + } + }, + "FunctionAliasNameUpperCaseRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameLowerCase": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameLowerCaseRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameLowerCaseVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameLowerCase" + } + } + }, + "FunctionAliasNameLowerCaseAliaslowercase": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "lowercase", + "FunctionName": { + "Ref": "FunctionAliasNameLowerCase" + }, + "FunctionVersion": { + "Fn::GetAtt": [ + "FunctionAliasNameLowerCaseVersion640128d35d", + "Version" + ] + } + } + }, + "FunctionAliasNameLowerCaseRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameUnderscore": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameUnderscoreRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameUnderscoreVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameUnderscore" + } + } + }, + "FunctionAliasNameUnderscoreAliasUunderscoreUnameU": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "_underscore_name_", + "FunctionName": { + "Ref": "FunctionAliasNameUnderscore" + }, + "FunctionVersion": { + "Fn::GetAtt": [ + "FunctionAliasNameUnderscoreVersion640128d35d", + "Version" + ] + } + } + }, + "FunctionAliasNameUnderscoreRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameDash": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameDashRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameDashVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameDash" + } + } + }, + "FunctionAliasNameDashAliasunderscoreDname": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "underscore-name", + "FunctionName": { + "Ref": "FunctionAliasNameDash" + }, + "FunctionVersion": { + "Fn::GetAtt": ["FunctionAliasNameDashVersion640128d35d", "Version"] + } + } + }, + "FunctionAliasNameDashRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameMix": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameMixRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameMixVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameMix" + } + } + }, + "FunctionAliasNameMixAliasunderScoreNAMEUwithDdashD01234": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "underScoreNAME_with-dash-01234", + "FunctionName": { + "Ref": "FunctionAliasNameMix" + }, + "FunctionVersion": { + "Fn::GetAtt": ["FunctionAliasNameMixVersion640128d35d", "Version"] + } + } + }, + "FunctionAliasNameMixRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + } + } +} diff --git a/tests/translator/output/function_with_alias_valid_names.json b/tests/translator/output/function_with_alias_valid_names.json new file mode 100644 index 000000000..c40f14234 --- /dev/null +++ b/tests/translator/output/function_with_alias_valid_names.json @@ -0,0 +1,424 @@ +{ + "Resources": { + "FunctionAliasNameCamelCase": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameCamelCaseRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameCamelCaseVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameCamelCase" + } + } + }, + "FunctionAliasNameCamelCaseAliascamelCaseName": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "camelCaseName", + "FunctionName": { + "Ref": "FunctionAliasNameCamelCase" + }, + "FunctionVersion": { + "Fn::GetAtt": [ + "FunctionAliasNameCamelCaseVersion640128d35d", + "Version" + ] + } + } + }, + "FunctionAliasNameCamelCaseRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameUpperCase": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameUpperCaseRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameUpperCaseVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameUpperCase" + } + } + }, + "FunctionAliasNameUpperCaseAliasUPPERCASE": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "UPPERCASE", + "FunctionName": { + "Ref": "FunctionAliasNameUpperCase" + }, + "FunctionVersion": { + "Fn::GetAtt": [ + "FunctionAliasNameUpperCaseVersion640128d35d", + "Version" + ] + } + } + }, + "FunctionAliasNameUpperCaseRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameLowerCase": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameLowerCaseRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameLowerCaseVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameLowerCase" + } + } + }, + "FunctionAliasNameLowerCaseAliaslowercase": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "lowercase", + "FunctionName": { + "Ref": "FunctionAliasNameLowerCase" + }, + "FunctionVersion": { + "Fn::GetAtt": [ + "FunctionAliasNameLowerCaseVersion640128d35d", + "Version" + ] + } + } + }, + "FunctionAliasNameLowerCaseRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameUnderscore": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameUnderscoreRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameUnderscoreVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameUnderscore" + } + } + }, + "FunctionAliasNameUnderscoreAliasUunderscoreUnameU": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "_underscore_name_", + "FunctionName": { + "Ref": "FunctionAliasNameUnderscore" + }, + "FunctionVersion": { + "Fn::GetAtt": [ + "FunctionAliasNameUnderscoreVersion640128d35d", + "Version" + ] + } + } + }, + "FunctionAliasNameUnderscoreRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameDash": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameDashRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameDashVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameDash" + } + } + }, + "FunctionAliasNameDashAliasunderscoreDname": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "underscore-name", + "FunctionName": { + "Ref": "FunctionAliasNameDash" + }, + "FunctionVersion": { + "Fn::GetAtt": ["FunctionAliasNameDashVersion640128d35d", "Version"] + } + } + }, + "FunctionAliasNameDashRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameMix": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": ["FunctionAliasNameMixRole", "Arn"] + }, + "Runtime": "python3.9", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "FunctionAliasNameMixVersion640128d35d": { + "Type": "AWS::Lambda::Version", + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameMix" + } + } + }, + "FunctionAliasNameMixAliasunderScoreNAMEUwithDdashD01234": { + "Type": "AWS::Lambda::Alias", + "Properties": { + "Name": "underScoreNAME_with-dash-01234", + "FunctionName": { + "Ref": "FunctionAliasNameMix" + }, + "FunctionVersion": { + "Fn::GetAtt": ["FunctionAliasNameMixVersion640128d35d", "Version"] + } + } + }, + "FunctionAliasNameMixRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": ["sts:AssumeRole"], + "Effect": "Allow", + "Principal": { + "Service": ["lambda.amazonaws.com"] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + } + } +} From 9f976be9593c1f70724fb55ba2ee7f7e11b12388 Mon Sep 17 00:00:00 2001 From: Vichym Date: Fri, 4 Apr 2025 15:33:18 -0700 Subject: [PATCH 8/8] fix make pr issue --- .../function_with_alias_valid_names.json | 364 ++++++++++-------- .../function_with_alias_valid_names.json | 364 ++++++++++-------- .../function_with_alias_valid_names.json | 364 ++++++++++-------- 3 files changed, 618 insertions(+), 474 deletions(-) diff --git a/tests/translator/output/aws-cn/function_with_alias_valid_names.json b/tests/translator/output/aws-cn/function_with_alias_valid_names.json index 3362a5c27..ebcb45936 100644 --- a/tests/translator/output/aws-cn/function_with_alias_valid_names.json +++ b/tests/translator/output/aws-cn/function_with_alias_valid_names.json @@ -1,7 +1,6 @@ { "Resources": { "FunctionAliasNameCamelCase": { - "Type": "AWS::Lambda::Function", "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -9,7 +8,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameCamelCaseRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameCamelCaseRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -18,22 +20,11 @@ "Value": "SAM" } ] - } - }, - "FunctionAliasNameCamelCaseVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameCamelCase" - } - } + }, + "Type": "AWS::Lambda::Function" }, "FunctionAliasNameCamelCaseAliascamelCaseName": { - "Type": "AWS::Lambda::Alias", "Properties": { - "Name": "camelCaseName", "FunctionName": { "Ref": "FunctionAliasNameCamelCase" }, @@ -42,23 +33,28 @@ "FunctionAliasNameCamelCaseVersion640128d35d", "Version" ] - } - } + }, + "Name": "camelCaseName" + }, + "Type": "AWS::Lambda::Alias" }, "FunctionAliasNameCamelCaseRole": { - "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -69,10 +65,20 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" }, - "FunctionAliasNameUpperCase": { - "Type": "AWS::Lambda::Function", + "FunctionAliasNameCamelCaseVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameCamelCase" + } + }, + "Type": "AWS::Lambda::Version" + }, + "FunctionAliasNameDash": { "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -80,7 +86,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameUpperCaseRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameDashRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -89,47 +98,41 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::Lambda::Function" }, - "FunctionAliasNameUpperCaseVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameUpperCase" - } - } - }, - "FunctionAliasNameUpperCaseAliasUPPERCASE": { - "Type": "AWS::Lambda::Alias", + "FunctionAliasNameDashAliasunderscoreDname": { "Properties": { - "Name": "UPPERCASE", "FunctionName": { - "Ref": "FunctionAliasNameUpperCase" + "Ref": "FunctionAliasNameDash" }, "FunctionVersion": { "Fn::GetAtt": [ - "FunctionAliasNameUpperCaseVersion640128d35d", + "FunctionAliasNameDashVersion640128d35d", "Version" ] - } - } + }, + "Name": "underscore-name" + }, + "Type": "AWS::Lambda::Alias" }, - "FunctionAliasNameUpperCaseRole": { - "Type": "AWS::IAM::Role", + "FunctionAliasNameDashRole": { "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -140,10 +143,20 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" + }, + "FunctionAliasNameDashVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameDash" + } + }, + "Type": "AWS::Lambda::Version" }, "FunctionAliasNameLowerCase": { - "Type": "AWS::Lambda::Function", "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -151,7 +164,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameLowerCaseRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameLowerCaseRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -160,22 +176,11 @@ "Value": "SAM" } ] - } - }, - "FunctionAliasNameLowerCaseVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameLowerCase" - } - } + }, + "Type": "AWS::Lambda::Function" }, "FunctionAliasNameLowerCaseAliaslowercase": { - "Type": "AWS::Lambda::Alias", "Properties": { - "Name": "lowercase", "FunctionName": { "Ref": "FunctionAliasNameLowerCase" }, @@ -184,23 +189,28 @@ "FunctionAliasNameLowerCaseVersion640128d35d", "Version" ] - } - } + }, + "Name": "lowercase" + }, + "Type": "AWS::Lambda::Alias" }, "FunctionAliasNameLowerCaseRole": { - "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -211,10 +221,20 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" }, - "FunctionAliasNameUnderscore": { - "Type": "AWS::Lambda::Function", + "FunctionAliasNameLowerCaseVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameLowerCase" + } + }, + "Type": "AWS::Lambda::Version" + }, + "FunctionAliasNameMix": { "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -222,7 +242,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameUnderscoreRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameMixRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -231,47 +254,41 @@ "Value": "SAM" } ] - } - }, - "FunctionAliasNameUnderscoreVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameUnderscore" - } - } + }, + "Type": "AWS::Lambda::Function" }, - "FunctionAliasNameUnderscoreAliasUunderscoreUnameU": { - "Type": "AWS::Lambda::Alias", + "FunctionAliasNameMixAliasunderScoreNAMEUwithDdashD01234": { "Properties": { - "Name": "_underscore_name_", "FunctionName": { - "Ref": "FunctionAliasNameUnderscore" + "Ref": "FunctionAliasNameMix" }, "FunctionVersion": { "Fn::GetAtt": [ - "FunctionAliasNameUnderscoreVersion640128d35d", + "FunctionAliasNameMixVersion640128d35d", "Version" ] - } - } + }, + "Name": "underScoreNAME_with-dash-01234" + }, + "Type": "AWS::Lambda::Alias" }, - "FunctionAliasNameUnderscoreRole": { - "Type": "AWS::IAM::Role", + "FunctionAliasNameMixRole": { "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -282,10 +299,20 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" }, - "FunctionAliasNameDash": { - "Type": "AWS::Lambda::Function", + "FunctionAliasNameMixVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameMix" + } + }, + "Type": "AWS::Lambda::Version" + }, + "FunctionAliasNameUnderscore": { "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -293,7 +320,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameDashRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameUnderscoreRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -302,44 +332,41 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::Lambda::Function" }, - "FunctionAliasNameDashVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameDash" - } - } - }, - "FunctionAliasNameDashAliasunderscoreDname": { - "Type": "AWS::Lambda::Alias", + "FunctionAliasNameUnderscoreAliasUunderscoreUnameU": { "Properties": { - "Name": "underscore-name", "FunctionName": { - "Ref": "FunctionAliasNameDash" + "Ref": "FunctionAliasNameUnderscore" }, "FunctionVersion": { - "Fn::GetAtt": ["FunctionAliasNameDashVersion640128d35d", "Version"] - } - } + "Fn::GetAtt": [ + "FunctionAliasNameUnderscoreVersion640128d35d", + "Version" + ] + }, + "Name": "_underscore_name_" + }, + "Type": "AWS::Lambda::Alias" }, - "FunctionAliasNameDashRole": { - "Type": "AWS::IAM::Role", + "FunctionAliasNameUnderscoreRole": { "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -350,10 +377,20 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" }, - "FunctionAliasNameMix": { - "Type": "AWS::Lambda::Function", + "FunctionAliasNameUnderscoreVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameUnderscore" + } + }, + "Type": "AWS::Lambda::Version" + }, + "FunctionAliasNameUpperCase": { "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -361,7 +398,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameMixRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameUpperCaseRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -370,44 +410,41 @@ "Value": "SAM" } ] - } - }, - "FunctionAliasNameMixVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameMix" - } - } + }, + "Type": "AWS::Lambda::Function" }, - "FunctionAliasNameMixAliasunderScoreNAMEUwithDdashD01234": { - "Type": "AWS::Lambda::Alias", + "FunctionAliasNameUpperCaseAliasUPPERCASE": { "Properties": { - "Name": "underScoreNAME_with-dash-01234", "FunctionName": { - "Ref": "FunctionAliasNameMix" + "Ref": "FunctionAliasNameUpperCase" }, "FunctionVersion": { - "Fn::GetAtt": ["FunctionAliasNameMixVersion640128d35d", "Version"] - } - } + "Fn::GetAtt": [ + "FunctionAliasNameUpperCaseVersion640128d35d", + "Version" + ] + }, + "Name": "UPPERCASE" + }, + "Type": "AWS::Lambda::Alias" }, - "FunctionAliasNameMixRole": { - "Type": "AWS::IAM::Role", + "FunctionAliasNameUpperCaseRole": { "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -418,7 +455,18 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" + }, + "FunctionAliasNameUpperCaseVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameUpperCase" + } + }, + "Type": "AWS::Lambda::Version" } } } diff --git a/tests/translator/output/aws-us-gov/function_with_alias_valid_names.json b/tests/translator/output/aws-us-gov/function_with_alias_valid_names.json index fd6f7bf80..f4e163674 100644 --- a/tests/translator/output/aws-us-gov/function_with_alias_valid_names.json +++ b/tests/translator/output/aws-us-gov/function_with_alias_valid_names.json @@ -1,7 +1,6 @@ { "Resources": { "FunctionAliasNameCamelCase": { - "Type": "AWS::Lambda::Function", "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -9,7 +8,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameCamelCaseRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameCamelCaseRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -18,22 +20,11 @@ "Value": "SAM" } ] - } - }, - "FunctionAliasNameCamelCaseVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameCamelCase" - } - } + }, + "Type": "AWS::Lambda::Function" }, "FunctionAliasNameCamelCaseAliascamelCaseName": { - "Type": "AWS::Lambda::Alias", "Properties": { - "Name": "camelCaseName", "FunctionName": { "Ref": "FunctionAliasNameCamelCase" }, @@ -42,23 +33,28 @@ "FunctionAliasNameCamelCaseVersion640128d35d", "Version" ] - } - } + }, + "Name": "camelCaseName" + }, + "Type": "AWS::Lambda::Alias" }, "FunctionAliasNameCamelCaseRole": { - "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -69,10 +65,20 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" }, - "FunctionAliasNameUpperCase": { - "Type": "AWS::Lambda::Function", + "FunctionAliasNameCamelCaseVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameCamelCase" + } + }, + "Type": "AWS::Lambda::Version" + }, + "FunctionAliasNameDash": { "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -80,7 +86,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameUpperCaseRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameDashRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -89,47 +98,41 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::Lambda::Function" }, - "FunctionAliasNameUpperCaseVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameUpperCase" - } - } - }, - "FunctionAliasNameUpperCaseAliasUPPERCASE": { - "Type": "AWS::Lambda::Alias", + "FunctionAliasNameDashAliasunderscoreDname": { "Properties": { - "Name": "UPPERCASE", "FunctionName": { - "Ref": "FunctionAliasNameUpperCase" + "Ref": "FunctionAliasNameDash" }, "FunctionVersion": { "Fn::GetAtt": [ - "FunctionAliasNameUpperCaseVersion640128d35d", + "FunctionAliasNameDashVersion640128d35d", "Version" ] - } - } + }, + "Name": "underscore-name" + }, + "Type": "AWS::Lambda::Alias" }, - "FunctionAliasNameUpperCaseRole": { - "Type": "AWS::IAM::Role", + "FunctionAliasNameDashRole": { "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -140,10 +143,20 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" + }, + "FunctionAliasNameDashVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameDash" + } + }, + "Type": "AWS::Lambda::Version" }, "FunctionAliasNameLowerCase": { - "Type": "AWS::Lambda::Function", "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -151,7 +164,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameLowerCaseRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameLowerCaseRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -160,22 +176,11 @@ "Value": "SAM" } ] - } - }, - "FunctionAliasNameLowerCaseVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameLowerCase" - } - } + }, + "Type": "AWS::Lambda::Function" }, "FunctionAliasNameLowerCaseAliaslowercase": { - "Type": "AWS::Lambda::Alias", "Properties": { - "Name": "lowercase", "FunctionName": { "Ref": "FunctionAliasNameLowerCase" }, @@ -184,23 +189,28 @@ "FunctionAliasNameLowerCaseVersion640128d35d", "Version" ] - } - } + }, + "Name": "lowercase" + }, + "Type": "AWS::Lambda::Alias" }, "FunctionAliasNameLowerCaseRole": { - "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -211,10 +221,20 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" }, - "FunctionAliasNameUnderscore": { - "Type": "AWS::Lambda::Function", + "FunctionAliasNameLowerCaseVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameLowerCase" + } + }, + "Type": "AWS::Lambda::Version" + }, + "FunctionAliasNameMix": { "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -222,7 +242,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameUnderscoreRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameMixRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -231,47 +254,41 @@ "Value": "SAM" } ] - } - }, - "FunctionAliasNameUnderscoreVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameUnderscore" - } - } + }, + "Type": "AWS::Lambda::Function" }, - "FunctionAliasNameUnderscoreAliasUunderscoreUnameU": { - "Type": "AWS::Lambda::Alias", + "FunctionAliasNameMixAliasunderScoreNAMEUwithDdashD01234": { "Properties": { - "Name": "_underscore_name_", "FunctionName": { - "Ref": "FunctionAliasNameUnderscore" + "Ref": "FunctionAliasNameMix" }, "FunctionVersion": { "Fn::GetAtt": [ - "FunctionAliasNameUnderscoreVersion640128d35d", + "FunctionAliasNameMixVersion640128d35d", "Version" ] - } - } + }, + "Name": "underScoreNAME_with-dash-01234" + }, + "Type": "AWS::Lambda::Alias" }, - "FunctionAliasNameUnderscoreRole": { - "Type": "AWS::IAM::Role", + "FunctionAliasNameMixRole": { "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -282,10 +299,20 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" }, - "FunctionAliasNameDash": { - "Type": "AWS::Lambda::Function", + "FunctionAliasNameMixVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameMix" + } + }, + "Type": "AWS::Lambda::Version" + }, + "FunctionAliasNameUnderscore": { "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -293,7 +320,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameDashRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameUnderscoreRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -302,44 +332,41 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::Lambda::Function" }, - "FunctionAliasNameDashVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameDash" - } - } - }, - "FunctionAliasNameDashAliasunderscoreDname": { - "Type": "AWS::Lambda::Alias", + "FunctionAliasNameUnderscoreAliasUunderscoreUnameU": { "Properties": { - "Name": "underscore-name", "FunctionName": { - "Ref": "FunctionAliasNameDash" + "Ref": "FunctionAliasNameUnderscore" }, "FunctionVersion": { - "Fn::GetAtt": ["FunctionAliasNameDashVersion640128d35d", "Version"] - } - } + "Fn::GetAtt": [ + "FunctionAliasNameUnderscoreVersion640128d35d", + "Version" + ] + }, + "Name": "_underscore_name_" + }, + "Type": "AWS::Lambda::Alias" }, - "FunctionAliasNameDashRole": { - "Type": "AWS::IAM::Role", + "FunctionAliasNameUnderscoreRole": { "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -350,10 +377,20 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" }, - "FunctionAliasNameMix": { - "Type": "AWS::Lambda::Function", + "FunctionAliasNameUnderscoreVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameUnderscore" + } + }, + "Type": "AWS::Lambda::Version" + }, + "FunctionAliasNameUpperCase": { "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -361,7 +398,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameMixRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameUpperCaseRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -370,44 +410,41 @@ "Value": "SAM" } ] - } - }, - "FunctionAliasNameMixVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameMix" - } - } + }, + "Type": "AWS::Lambda::Function" }, - "FunctionAliasNameMixAliasunderScoreNAMEUwithDdashD01234": { - "Type": "AWS::Lambda::Alias", + "FunctionAliasNameUpperCaseAliasUPPERCASE": { "Properties": { - "Name": "underScoreNAME_with-dash-01234", "FunctionName": { - "Ref": "FunctionAliasNameMix" + "Ref": "FunctionAliasNameUpperCase" }, "FunctionVersion": { - "Fn::GetAtt": ["FunctionAliasNameMixVersion640128d35d", "Version"] - } - } + "Fn::GetAtt": [ + "FunctionAliasNameUpperCaseVersion640128d35d", + "Version" + ] + }, + "Name": "UPPERCASE" + }, + "Type": "AWS::Lambda::Alias" }, - "FunctionAliasNameMixRole": { - "Type": "AWS::IAM::Role", + "FunctionAliasNameUpperCaseRole": { "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -418,7 +455,18 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" + }, + "FunctionAliasNameUpperCaseVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameUpperCase" + } + }, + "Type": "AWS::Lambda::Version" } } } diff --git a/tests/translator/output/function_with_alias_valid_names.json b/tests/translator/output/function_with_alias_valid_names.json index c40f14234..7538f1e17 100644 --- a/tests/translator/output/function_with_alias_valid_names.json +++ b/tests/translator/output/function_with_alias_valid_names.json @@ -1,7 +1,6 @@ { "Resources": { "FunctionAliasNameCamelCase": { - "Type": "AWS::Lambda::Function", "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -9,7 +8,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameCamelCaseRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameCamelCaseRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -18,22 +20,11 @@ "Value": "SAM" } ] - } - }, - "FunctionAliasNameCamelCaseVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameCamelCase" - } - } + }, + "Type": "AWS::Lambda::Function" }, "FunctionAliasNameCamelCaseAliascamelCaseName": { - "Type": "AWS::Lambda::Alias", "Properties": { - "Name": "camelCaseName", "FunctionName": { "Ref": "FunctionAliasNameCamelCase" }, @@ -42,23 +33,28 @@ "FunctionAliasNameCamelCaseVersion640128d35d", "Version" ] - } - } + }, + "Name": "camelCaseName" + }, + "Type": "AWS::Lambda::Alias" }, "FunctionAliasNameCamelCaseRole": { - "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -69,10 +65,20 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" }, - "FunctionAliasNameUpperCase": { - "Type": "AWS::Lambda::Function", + "FunctionAliasNameCamelCaseVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameCamelCase" + } + }, + "Type": "AWS::Lambda::Version" + }, + "FunctionAliasNameDash": { "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -80,7 +86,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameUpperCaseRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameDashRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -89,47 +98,41 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::Lambda::Function" }, - "FunctionAliasNameUpperCaseVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameUpperCase" - } - } - }, - "FunctionAliasNameUpperCaseAliasUPPERCASE": { - "Type": "AWS::Lambda::Alias", + "FunctionAliasNameDashAliasunderscoreDname": { "Properties": { - "Name": "UPPERCASE", "FunctionName": { - "Ref": "FunctionAliasNameUpperCase" + "Ref": "FunctionAliasNameDash" }, "FunctionVersion": { "Fn::GetAtt": [ - "FunctionAliasNameUpperCaseVersion640128d35d", + "FunctionAliasNameDashVersion640128d35d", "Version" ] - } - } + }, + "Name": "underscore-name" + }, + "Type": "AWS::Lambda::Alias" }, - "FunctionAliasNameUpperCaseRole": { - "Type": "AWS::IAM::Role", + "FunctionAliasNameDashRole": { "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -140,10 +143,20 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" + }, + "FunctionAliasNameDashVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameDash" + } + }, + "Type": "AWS::Lambda::Version" }, "FunctionAliasNameLowerCase": { - "Type": "AWS::Lambda::Function", "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -151,7 +164,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameLowerCaseRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameLowerCaseRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -160,22 +176,11 @@ "Value": "SAM" } ] - } - }, - "FunctionAliasNameLowerCaseVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameLowerCase" - } - } + }, + "Type": "AWS::Lambda::Function" }, "FunctionAliasNameLowerCaseAliaslowercase": { - "Type": "AWS::Lambda::Alias", "Properties": { - "Name": "lowercase", "FunctionName": { "Ref": "FunctionAliasNameLowerCase" }, @@ -184,23 +189,28 @@ "FunctionAliasNameLowerCaseVersion640128d35d", "Version" ] - } - } + }, + "Name": "lowercase" + }, + "Type": "AWS::Lambda::Alias" }, "FunctionAliasNameLowerCaseRole": { - "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -211,10 +221,20 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" }, - "FunctionAliasNameUnderscore": { - "Type": "AWS::Lambda::Function", + "FunctionAliasNameLowerCaseVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameLowerCase" + } + }, + "Type": "AWS::Lambda::Version" + }, + "FunctionAliasNameMix": { "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -222,7 +242,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameUnderscoreRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameMixRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -231,47 +254,41 @@ "Value": "SAM" } ] - } - }, - "FunctionAliasNameUnderscoreVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameUnderscore" - } - } + }, + "Type": "AWS::Lambda::Function" }, - "FunctionAliasNameUnderscoreAliasUunderscoreUnameU": { - "Type": "AWS::Lambda::Alias", + "FunctionAliasNameMixAliasunderScoreNAMEUwithDdashD01234": { "Properties": { - "Name": "_underscore_name_", "FunctionName": { - "Ref": "FunctionAliasNameUnderscore" + "Ref": "FunctionAliasNameMix" }, "FunctionVersion": { "Fn::GetAtt": [ - "FunctionAliasNameUnderscoreVersion640128d35d", + "FunctionAliasNameMixVersion640128d35d", "Version" ] - } - } + }, + "Name": "underScoreNAME_with-dash-01234" + }, + "Type": "AWS::Lambda::Alias" }, - "FunctionAliasNameUnderscoreRole": { - "Type": "AWS::IAM::Role", + "FunctionAliasNameMixRole": { "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -282,10 +299,20 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" }, - "FunctionAliasNameDash": { - "Type": "AWS::Lambda::Function", + "FunctionAliasNameMixVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameMix" + } + }, + "Type": "AWS::Lambda::Version" + }, + "FunctionAliasNameUnderscore": { "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -293,7 +320,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameDashRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameUnderscoreRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -302,44 +332,41 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::Lambda::Function" }, - "FunctionAliasNameDashVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameDash" - } - } - }, - "FunctionAliasNameDashAliasunderscoreDname": { - "Type": "AWS::Lambda::Alias", + "FunctionAliasNameUnderscoreAliasUunderscoreUnameU": { "Properties": { - "Name": "underscore-name", "FunctionName": { - "Ref": "FunctionAliasNameDash" + "Ref": "FunctionAliasNameUnderscore" }, "FunctionVersion": { - "Fn::GetAtt": ["FunctionAliasNameDashVersion640128d35d", "Version"] - } - } + "Fn::GetAtt": [ + "FunctionAliasNameUnderscoreVersion640128d35d", + "Version" + ] + }, + "Name": "_underscore_name_" + }, + "Type": "AWS::Lambda::Alias" }, - "FunctionAliasNameDashRole": { - "Type": "AWS::IAM::Role", + "FunctionAliasNameUnderscoreRole": { "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -350,10 +377,20 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" }, - "FunctionAliasNameMix": { - "Type": "AWS::Lambda::Function", + "FunctionAliasNameUnderscoreVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameUnderscore" + } + }, + "Type": "AWS::Lambda::Version" + }, + "FunctionAliasNameUpperCase": { "Properties": { "Code": { "S3Bucket": "sam-demo-bucket", @@ -361,7 +398,10 @@ }, "Handler": "hello.handler", "Role": { - "Fn::GetAtt": ["FunctionAliasNameMixRole", "Arn"] + "Fn::GetAtt": [ + "FunctionAliasNameUpperCaseRole", + "Arn" + ] }, "Runtime": "python3.9", "Tags": [ @@ -370,44 +410,41 @@ "Value": "SAM" } ] - } - }, - "FunctionAliasNameMixVersion640128d35d": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "Description": "sam-testing", - "FunctionName": { - "Ref": "FunctionAliasNameMix" - } - } + }, + "Type": "AWS::Lambda::Function" }, - "FunctionAliasNameMixAliasunderScoreNAMEUwithDdashD01234": { - "Type": "AWS::Lambda::Alias", + "FunctionAliasNameUpperCaseAliasUPPERCASE": { "Properties": { - "Name": "underScoreNAME_with-dash-01234", "FunctionName": { - "Ref": "FunctionAliasNameMix" + "Ref": "FunctionAliasNameUpperCase" }, "FunctionVersion": { - "Fn::GetAtt": ["FunctionAliasNameMixVersion640128d35d", "Version"] - } - } + "Fn::GetAtt": [ + "FunctionAliasNameUpperCaseVersion640128d35d", + "Version" + ] + }, + "Name": "UPPERCASE" + }, + "Type": "AWS::Lambda::Alias" }, - "FunctionAliasNameMixRole": { - "Type": "AWS::IAM::Role", + "FunctionAliasNameUpperCaseRole": { "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", "Statement": [ { - "Action": ["sts:AssumeRole"], + "Action": [ + "sts:AssumeRole" + ], "Effect": "Allow", "Principal": { - "Service": ["lambda.amazonaws.com"] + "Service": [ + "lambda.amazonaws.com" + ] } } - ] + ], + "Version": "2012-10-17" }, "ManagedPolicyArns": [ "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" @@ -418,7 +455,18 @@ "Value": "SAM" } ] - } + }, + "Type": "AWS::IAM::Role" + }, + "FunctionAliasNameUpperCaseVersion640128d35d": { + "DeletionPolicy": "Retain", + "Properties": { + "Description": "sam-testing", + "FunctionName": { + "Ref": "FunctionAliasNameUpperCase" + } + }, + "Type": "AWS::Lambda::Version" } } }