From 5391e1e131c69b6763c047c28c37d9b78f95b12a Mon Sep 17 00:00:00 2001 From: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com> Date: Fri, 19 Nov 2021 18:05:51 -0800 Subject: [PATCH] Revert "feat: Lambda URLs (#2229)" This reverts commit a3c2cae711b903123cefde6db3dc99f73426bc95. --- ...sic_function_with_function_url_config.json | 14 -- ...th_function_url_with_autopuplishalias.json | 22 --- ...sic_function_with_function_url_config.yaml | 21 --- ...th_function_url_with_autopuplishalias.yaml | 22 --- integration/single/test_basic_function.py | 33 ---- samtranslator/model/lambda_.py | 9 - samtranslator/model/sam_resources.py | 84 --------- samtranslator/plugins/globals/globals.py | 10 +- tests/model/test_sam_resources.py | 161 +----------------- tests/plugins/globals/test_globals.py | 16 -- ...rl_config_with_invalid_cors_parameter.yaml | 17 -- ...with_invalid_cors_parameter_data_type.yaml | 16 -- ...url_config_with_no_authorization_type.yaml | 28 --- .../function_with_function_url_config.yaml | 29 ---- ...ction_url_config_and_autopublishalias.yaml | 30 ---- ...h_function_url_config_with_intrinsics.yaml | 31 ---- ...nction_url_config_without_cors_config.yaml | 15 -- .../function_with_function_url_config.json | 90 ---------- ...ction_url_config_and_autopublishalias.json | 114 ------------- ...h_function_url_config_with_intrinsics.json | 94 ---------- ...nction_url_config_without_cors_config.json | 71 -------- .../function_with_function_url_config.json | 90 ---------- ...ction_url_config_and_autopublishalias.json | 114 ------------- ...h_function_url_config_with_intrinsics.json | 94 ---------- ...nction_url_config_without_cors_config.json | 71 -------- ...rl_config_with_invalid_cors_parameter.json | 3 - ...with_invalid_cors_parameter_data_type.json | 3 - ...url_config_with_no_authorization_type.json | 3 - .../error_globals_unsupported_property.json | 4 +- .../function_with_function_url_config.json | 90 ---------- ...ction_url_config_and_autopublishalias.json | 114 ------------- ...h_function_url_config_with_intrinsics.json | 94 ---------- ...nction_url_config_without_cors_config.json | 71 -------- tests/translator/test_translator.py | 4 - versions/2016-10-31.md | 2 - 35 files changed, 5 insertions(+), 1679 deletions(-) delete mode 100644 integration/resources/expected/single/basic_function_with_function_url_config.json delete mode 100644 integration/resources/expected/single/basic_function_with_function_url_with_autopuplishalias.json delete mode 100644 integration/resources/templates/single/basic_function_with_function_url_config.yaml delete mode 100644 integration/resources/templates/single/basic_function_with_function_url_with_autopuplishalias.yaml delete mode 100644 tests/translator/input/error_function_with_function_url_config_with_invalid_cors_parameter.yaml delete mode 100644 tests/translator/input/error_function_with_function_url_config_with_invalid_cors_parameter_data_type.yaml delete mode 100644 tests/translator/input/error_function_with_function_url_config_with_no_authorization_type.yaml delete mode 100644 tests/translator/input/function_with_function_url_config.yaml delete mode 100644 tests/translator/input/function_with_function_url_config_and_autopublishalias.yaml delete mode 100644 tests/translator/input/function_with_function_url_config_with_intrinsics.yaml delete mode 100644 tests/translator/input/function_with_function_url_config_without_cors_config.yaml delete mode 100644 tests/translator/output/aws-cn/function_with_function_url_config.json delete mode 100644 tests/translator/output/aws-cn/function_with_function_url_config_and_autopublishalias.json delete mode 100644 tests/translator/output/aws-cn/function_with_function_url_config_with_intrinsics.json delete mode 100644 tests/translator/output/aws-cn/function_with_function_url_config_without_cors_config.json delete mode 100644 tests/translator/output/aws-us-gov/function_with_function_url_config.json delete mode 100644 tests/translator/output/aws-us-gov/function_with_function_url_config_and_autopublishalias.json delete mode 100644 tests/translator/output/aws-us-gov/function_with_function_url_config_with_intrinsics.json delete mode 100644 tests/translator/output/aws-us-gov/function_with_function_url_config_without_cors_config.json delete mode 100644 tests/translator/output/error_function_with_function_url_config_with_invalid_cors_parameter.json delete mode 100644 tests/translator/output/error_function_with_function_url_config_with_invalid_cors_parameter_data_type.json delete mode 100644 tests/translator/output/error_function_with_function_url_config_with_no_authorization_type.json delete mode 100644 tests/translator/output/function_with_function_url_config.json delete mode 100644 tests/translator/output/function_with_function_url_config_and_autopublishalias.json delete mode 100644 tests/translator/output/function_with_function_url_config_with_intrinsics.json delete mode 100644 tests/translator/output/function_with_function_url_config_without_cors_config.json diff --git a/integration/resources/expected/single/basic_function_with_function_url_config.json b/integration/resources/expected/single/basic_function_with_function_url_config.json deleted file mode 100644 index df2301ea07..0000000000 --- a/integration/resources/expected/single/basic_function_with_function_url_config.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "LogicalResourceId": "MyLambdaFunction", - "ResourceType": "AWS::Lambda::Function" - }, - { - "LogicalResourceId": "MyLambdaFunctionUrl", - "ResourceType": "AWS::Lambda::Url" - }, - { - "LogicalResourceId": "MyLambdaFunctionRole", - "ResourceType": "AWS::IAM::Role" - } -] \ No newline at end of file diff --git a/integration/resources/expected/single/basic_function_with_function_url_with_autopuplishalias.json b/integration/resources/expected/single/basic_function_with_function_url_with_autopuplishalias.json deleted file mode 100644 index 3bef57f140..0000000000 --- a/integration/resources/expected/single/basic_function_with_function_url_with_autopuplishalias.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "LogicalResourceId": "MyLambdaFunction", - "ResourceType": "AWS::Lambda::Function" - }, - { - "LogicalResourceId": "MyLambdaFunctionUrl", - "ResourceType": "AWS::Lambda::Url" - }, - { - "LogicalResourceId": "MyLambdaFunctionRole", - "ResourceType": "AWS::IAM::Role" - }, - { - "LogicalResourceId": "MyLambdaFunctionAliaslive", - "ResourceType": "AWS::Lambda::Alias" - }, - { - "LogicalResourceId": "MyLambdaFunctionVersion", - "ResourceType": "AWS::Lambda::Version" - } -] \ No newline at end of file diff --git a/integration/resources/templates/single/basic_function_with_function_url_config.yaml b/integration/resources/templates/single/basic_function_with_function_url_config.yaml deleted file mode 100644 index aa15a61afe..0000000000 --- a/integration/resources/templates/single/basic_function_with_function_url_config.yaml +++ /dev/null @@ -1,21 +0,0 @@ -Resources: - MyLambdaFunction: - Type: AWS::Serverless::Function - Properties: - Handler: index.handler - Runtime: nodejs12.x - CodeUri: ${codeuri} - MemorySize: 128 - FunctionUrlConfig: - AuthorizationType: NONE - Cors: - AllowOrigins: - - "https://foo.com" - AllowMethods: - - "POST" - AllowCredentials: true - AllowHeaders: - - "x-Custom-Header" - ExposeHeaders: - - "x-amzn-header" - MaxAge: 10 diff --git a/integration/resources/templates/single/basic_function_with_function_url_with_autopuplishalias.yaml b/integration/resources/templates/single/basic_function_with_function_url_with_autopuplishalias.yaml deleted file mode 100644 index f413074647..0000000000 --- a/integration/resources/templates/single/basic_function_with_function_url_with_autopuplishalias.yaml +++ /dev/null @@ -1,22 +0,0 @@ -Resources: - MyLambdaFunction: - Type: AWS::Serverless::Function - Properties: - Handler: index.handler - Runtime: nodejs12.x - CodeUri: ${codeuri} - MemorySize: 128 - AutoPublishAlias: live - FunctionUrlConfig: - AuthorizationType: NONE - Cors: - AllowOrigins: - - "https://foo.com" - AllowMethods: - - "POST" - AllowCredentials: true - AllowHeaders: - - "x-Custom-Header" - ExposeHeaders: - - "x-amzn-header" - MaxAge: 10 diff --git a/integration/single/test_basic_function.py b/integration/single/test_basic_function.py index 8e63d7bdd0..1b441a631e 100644 --- a/integration/single/test_basic_function.py +++ b/integration/single/test_basic_function.py @@ -66,39 +66,6 @@ def test_basic_function_with_architecture(self, file_name, architecture): self.assertEqual(function_architecture, architecture) - @parameterized.expand( - [ - ("single/basic_function_with_function_url_config", None), - ("single/basic_function_with_function_url_with_autopuplishalias", "live"), - ] - ) - @skipIf(current_region_does_not_support(["Url"]), "Url is not supported in this testing region") - def test_basic_function_with_url_config(self, file_name, qualifier): - """ - Creates a basic lambda function with Function Url enabled - """ - self.create_and_verify_stack(file_name) - - lambda_client = self.client_provider.lambda_client - - function_name = self.get_physical_id_by_type("AWS::Lambda::Function") - function_url_config = ( - lambda_client.get_function_url_config(FunctionName=function_name, Qualifier=qualifier) - if qualifier - else lambda_client.get_function_url_config(FunctionName=function_name) - ) - cors_config = { - "AllowOrigins": ["https://foo.com"], - "AllowMethods": ["POST"], - "AllowCredentials": True, - "AllowHeaders": ["x-Custom-Header"], - "ExposeHeaders": ["x-amzn-header"], - "MaxAge": 10, - } - - self.assertEqual(function_url_config["AuthorizationType"], "NONE") - self.assertEqual(function_url_config["Cors"], cors_config) - def test_function_with_deployment_preference_alarms_intrinsic_if(self): self.create_and_verify_stack("single/function_with_deployment_preference_alarms_intrinsic_if") diff --git a/samtranslator/model/lambda_.py b/samtranslator/model/lambda_.py index 6fc0eeaa53..75089bc045 100644 --- a/samtranslator/model/lambda_.py +++ b/samtranslator/model/lambda_.py @@ -121,12 +121,3 @@ class LambdaLayerVersion(Resource): } runtime_attrs = {"name": lambda self: ref(self.logical_id), "arn": lambda self: fnGetAtt(self.logical_id, "Arn")} - - -class LambdaUrl(Resource): - resource_type = "AWS::Lambda::Url" - property_types = { - "TargetFunctionArn": PropertyType(True, one_of(is_str(), is_type(dict))), - "AuthorizationType": PropertyType(True, is_str()), - "Cors": PropertyType(False, is_type(dict)), - } diff --git a/samtranslator/model/sam_resources.py b/samtranslator/model/sam_resources.py index 33cd4b3acd..2469e5cadc 100644 --- a/samtranslator/model/sam_resources.py +++ b/samtranslator/model/sam_resources.py @@ -34,7 +34,6 @@ LambdaAlias, LambdaLayerVersion, LambdaEventInvokeConfig, - LambdaUrl, ) from samtranslator.model.types import dict_of, is_str, is_type, list_of, one_of, any_type from samtranslator.translator import logical_id_generator @@ -94,7 +93,6 @@ class SamFunction(SamResourceMacro): "ImageConfig": PropertyType(False, is_type(dict)), "CodeSigningConfigArn": PropertyType(False, is_str()), "Architectures": PropertyType(False, list_of(one_of(is_str(), is_type(dict)))), - "FunctionUrlConfig": PropertyType(False, is_type(dict)), } event_resolver = ResourceTypeResolver( samtranslator.model.eventsources, @@ -171,10 +169,6 @@ def to_cloudformation(self, **kwargs): resources.append(lambda_version) resources.append(lambda_alias) - if self.FunctionUrlConfig: - lambda_url = self._construct_lambda_url(lambda_function, lambda_alias) - resources.append(lambda_url) - if self.DeploymentPreference: self._validate_deployment_preference_and_add_update_policy( kwargs.get("deployment_preference_collection", None), @@ -849,84 +843,6 @@ def _validate_deployment_preference_and_add_update_policy( "UpdatePolicy", deployment_preference_collection.update_policy(self.logical_id).to_dict() ) - def _construct_lambda_url(self, lambda_function, lambda_alias): - """ - This method is used to construct a lambda url resource - - Parameters - ---------- - lambda_function : LambdaFunction - Lambda Function resource - lambda_alias : LambdaAlias - Lambda Alias resource - - Returns - ------- - LambdaUrl - Lambda Url resource - """ - self._validate_function_url_params(lambda_function) - - logical_id = "{id}Url".format(id=lambda_function.logical_id) - lambda_url = LambdaUrl(logical_id=logical_id) - - cors = self.FunctionUrlConfig.get("Cors") - if cors: - lambda_url.Cors = cors - lambda_url.AuthorizationType = self.FunctionUrlConfig.get("AuthorizationType") - lambda_url.TargetFunctionArn = ( - lambda_alias.get_runtime_attr("arn") if lambda_alias else lambda_function.get_runtime_attr("name") - ) - return lambda_url - - def _validate_function_url_params(self, lambda_function): - """ - Validate parameters provided to configure Lambda Urls - """ - self._validate_url_auth_type(lambda_function) - self._validate_cors_config_parameter(lambda_function) - - def _validate_url_auth_type(self, lambda_function): - if is_intrinsic(self.FunctionUrlConfig): - return - - if not self.FunctionUrlConfig.get("AuthorizationType"): - raise InvalidResourceException( - lambda_function.logical_id, - "AuthorizationType is required to configure function property `FunctionUrlConfig`. Please provide either an IAM role name or NONE.", - ) - - def _validate_cors_config_parameter(self, lambda_function): - if is_intrinsic(self.FunctionUrlConfig): - return - - cors_property_data_type = { - "AllowOrigins": list, - "AllowMethods": list, - "AllowCredentials": bool, - "AllowHeaders": list, - "ExposeHeaders": list, - "MaxAge": int, - } - - cors = self.FunctionUrlConfig.get("Cors") - - if not cors or is_intrinsic(cors): - return - - for prop_name, prop_value in cors.items(): - if prop_name not in cors_property_data_type: - raise InvalidResourceException( - lambda_function.logical_id, - "{} is not a valid property for configuring Cors.".format(prop_name), - ) - prop_type = cors_property_data_type.get(prop_name) - if not is_intrinsic(prop_value) and not isinstance(prop_value, prop_type): - raise InvalidResourceException( - lambda_function.logical_id, - "{} must be of type {}.".format(prop_name, str(prop_type).split("'")[1]), - ) - class SamApi(SamResourceMacro): """SAM rest API macro.""" diff --git a/samtranslator/plugins/globals/globals.py b/samtranslator/plugins/globals/globals.py index 9f0bcb73b4..950b5583cb 100644 --- a/samtranslator/plugins/globals/globals.py +++ b/samtranslator/plugins/globals/globals.py @@ -43,7 +43,6 @@ class Globals(object): "FileSystemConfigs", "CodeSigningConfigArn", "Architectures", - "FunctionUrlConfig", ], # Everything except # DefinitionBody: because its hard to reason about merge of Swagger dictionaries @@ -81,8 +80,6 @@ class Globals(object): ], SamResourceType.SimpleTable.value: ["SSESpecification"], } - # unreleased_properties *must be* part of supported_properties too - unreleased_properties = {} def __init__(self, template): """ @@ -198,17 +195,14 @@ def _parse(self, globals_dict): if not isinstance(properties, dict): raise InvalidGlobalsSectionException(self._KEYWORD, "Value of ${section} must be a dictionary") - supported = self.supported_properties[resource_type] - supported_displayed = [ - prop for prop in supported if prop not in self.unreleased_properties.get(resource_type, []) - ] for key, value in properties.items(): + supported = self.supported_properties[resource_type] if key not in supported: raise InvalidGlobalsSectionException( self._KEYWORD, "'{key}' is not a supported property of '{section}'. " "Must be one of the following values - {supported}".format( - key=key, section=section_name, supported=supported_displayed + key=key, section=section_name, supported=supported ), ) diff --git a/tests/model/test_sam_resources.py b/tests/model/test_sam_resources.py index 4865b19b3e..2b2fd808ce 100644 --- a/tests/model/test_sam_resources.py +++ b/tests/model/test_sam_resources.py @@ -5,7 +5,7 @@ from samtranslator.intrinsics.resolver import IntrinsicsResolver from samtranslator.model import InvalidResourceException from samtranslator.model.apigatewayv2 import ApiGatewayV2HttpApi -from samtranslator.model.lambda_ import LambdaFunction, LambdaLayerVersion, LambdaVersion, LambdaUrl +from samtranslator.model.lambda_ import LambdaFunction, LambdaLayerVersion, LambdaVersion from samtranslator.model.apigateway import ApiGatewayDeployment, ApiGatewayRestApi from samtranslator.model.apigateway import ApiGatewayStage from samtranslator.model.iam import IAMRole @@ -461,162 +461,3 @@ def test_invalid_compatible_architectures(self): layer.CompatibleArchitectures = architecturea with pytest.raises(InvalidResourceException): layer.to_cloudformation(**self.kwargs) - - -class TestFunctionUrlConfig(TestCase): - kwargs = { - "intrinsics_resolver": IntrinsicsResolver({}), - "event_resources": [], - "managed_policy_map": {"foo": "bar"}, - } - - @patch("boto3.session.Session.region_name", "ap-southeast-1") - def test_with_function_url_config_with_no_authorization_type(self): - function = SamFunction("foo") - function.CodeUri = "s3://foobar/foo.zip" - function.Runtime = "foo" - function.Handler = "bar" - function.FunctionUrlConfig = {"Cors": {"AllowOrigins": ["example1.com"]}} - with pytest.raises(InvalidResourceException) as e: - function.to_cloudformation(**self.kwargs) - self.assertEqual( - str(e.value.message), - "Resource with id [foo] is invalid. AuthorizationType is required to configure" - + " function property `FunctionUrlConfig`. Please provide either an IAM role name or NONE.", - ) - - @patch("boto3.session.Session.region_name", "ap-southeast-1") - def test_with_function_url_config_with_no_cors_config(self): - function = SamFunction("foo") - function.CodeUri = "s3://foobar/foo.zip" - function.Runtime = "foo" - function.Handler = "bar" - function.FunctionUrlConfig = {"AuthorizationType": "sample_IAM_role"} - cfnResources = function.to_cloudformation(**self.kwargs) - generatedUrlList = [x for x in cfnResources if isinstance(x, LambdaUrl)] - self.assertEqual(generatedUrlList.__len__(), 1) - self.assertEqual(generatedUrlList[0].AuthorizationType, "sample_IAM_role") - - @patch("boto3.session.Session.region_name", "ap-southeast-1") - def test_validate_function_url_config_properties_with_intrinsic(self): - function = SamFunction("foo") - function.CodeUri = "s3://foobar/foo.zip" - function.Runtime = "foo" - function.Handler = "bar" - function.FunctionUrlConfig = {"AuthorizationType": {"Ref": "MyIAMRef"}, "Cors": {"Ref": "MyCorConfigRef"}} - - cfnResources = function.to_cloudformation(**self.kwargs) - generatedUrlList = [x for x in cfnResources if isinstance(x, LambdaUrl)] - self.assertEqual(generatedUrlList.__len__(), 1) - generatedUrlList = [x for x in cfnResources if isinstance(x, LambdaUrl)] - self.assertEqual(generatedUrlList.__len__(), 1) - self.assertEqual(generatedUrlList[0].AuthorizationType, {"Ref": "MyIAMRef"}) - self.assertEqual(generatedUrlList[0].Cors, {"Ref": "MyCorConfigRef"}) - - @patch("boto3.session.Session.region_name", "ap-southeast-1") - def test_with_valid_function_url_config(self): - cors = { - "AllowOrigins": ["example1.com", "example2.com", "example2.com"], - "AllowMethods": ["GET"], - "AllowCredentials": True, - "AllowHeaders": ["X-Custom-Header"], - "ExposeHeaders": ["x-amzn-header"], - "MaxAge": 10, - } - function = SamFunction("foo") - function.CodeUri = "s3://foobar/foo.zip" - function.Runtime = "foo" - function.Handler = "bar" - function.FunctionUrlConfig = {"AuthorizationType": "NONE", "Cors": cors} - - cfnResources = function.to_cloudformation(**self.kwargs) - generatedUrlList = [x for x in cfnResources if isinstance(x, LambdaUrl)] - self.assertEqual(generatedUrlList.__len__(), 1) - self.assertEqual(generatedUrlList[0].AuthorizationType, "NONE") - self.assertEqual(generatedUrlList[0].Cors, cors) - - @patch("boto3.session.Session.region_name", "ap-southeast-1") - def test_with_valid_function_url_config_with_Intrinsics(self): - function = SamFunction("foo") - function.CodeUri = "s3://foobar/foo.zip" - function.Runtime = "foo" - function.Handler = "bar" - function.FunctionUrlConfig = {"Ref": "MyFunctionUrlConfig"} - - cfnResources = function.to_cloudformation(**self.kwargs) - generatedUrlList = [x for x in cfnResources if isinstance(x, LambdaUrl)] - self.assertEqual(generatedUrlList.__len__(), 1) - - @patch("boto3.session.Session.region_name", "ap-southeast-1") - def test_with_function_url_config_with_invalid_cors_parameter(self): - function = SamFunction("foo") - function.CodeUri = "s3://foobar/foo.zip" - function.Runtime = "foo" - function.Handler = "bar" - function.FunctionUrlConfig = {"AuthorizationType": "NONE", "Cors": {"AllowOrigin": ["example1.com"]}} - with pytest.raises(InvalidResourceException) as e: - function.to_cloudformation(**self.kwargs) - self.assertEqual( - str(e.value.message), - "Resource with id [foo] is invalid. AllowOrigin is not a valid property for configuring Cors.", - ) - - @patch("boto3.session.Session.region_name", "ap-southeast-1") - def test_with_function_url_config_with_invalid_cors_parameter_data_type(self): - function = SamFunction("foo") - function.CodeUri = "s3://foobar/foo.zip" - function.Runtime = "foo" - function.Handler = "bar" - function.FunctionUrlConfig = {"AuthorizationType": "NONE", "Cors": {"AllowOrigins": "example1.com"}} - with pytest.raises(InvalidResourceException) as e: - function.to_cloudformation(**self.kwargs) - self.assertEqual( - str(e.value.message), - "Resource with id [foo] is invalid. AllowOrigins must be of type list.", - ) - - @patch("boto3.session.Session.region_name", "ap-southeast-1") - def test_with_valid_function_url_config_without_auto_publish_alias(self): - function = SamFunction("foo") - function.CodeUri = "s3://foobar/foo.zip" - function.Runtime = "foo" - function.Handler = "bar" - function.FunctionUrlConfig = {"AuthorizationType": "NONE", "Cors": {"AllowOrigins": ["example1.com"]}} - - cfnResources = function.to_cloudformation(**self.kwargs) - generatedUrlList = [x for x in cfnResources if isinstance(x, LambdaUrl)] - self.assertEqual(generatedUrlList.__len__(), 1) - expected_url_logicalid = {"Ref": "foo"} - self.assertEqual(generatedUrlList[0].TargetFunctionArn, expected_url_logicalid) - - @patch("boto3.session.Session.region_name", "ap-southeast-1") - def test_with_valid_function_url_config_with_auto_publish_alias(self): - function = SamFunction("foo") - function.CodeUri = "s3://foobar/foo.zip" - function.Runtime = "foo" - function.Handler = "bar" - function.AutoPublishAlias = "live" - function.FunctionUrlConfig = {"AuthorizationType": "NONE", "Cors": {"AllowOrigins": ["example1.com"]}} - - cfnResources = function.to_cloudformation(**self.kwargs) - generatedUrlList = [x for x in cfnResources if isinstance(x, LambdaUrl)] - self.assertEqual(generatedUrlList.__len__(), 1) - expected_url_logicalid = {"Ref": "fooAliaslive"} - self.assertEqual(generatedUrlList[0].TargetFunctionArn, expected_url_logicalid) - - @patch("boto3.session.Session.region_name", "ap-southeast-1") - def test_with_valid_function_url_config_with_authorization_type_value_as_None(self): - - function = SamFunction("foo") - function.CodeUri = "s3://foobar/foo.zip" - function.Runtime = "foo" - function.Handler = "bar" - function.FunctionUrlConfig = {"AuthorizationType": None} - - with pytest.raises(InvalidResourceException) as e: - cfnResources = function.to_cloudformation(**self.kwargs) - self.assertEqual( - str(e.value.message), - "Resource with id [foo] is invalid. AuthorizationType is required to configure function property " - + "`FunctionUrlConfig`. Please provide either an IAM role name or NONE.", - ) diff --git a/tests/plugins/globals/test_globals.py b/tests/plugins/globals/test_globals.py index 36ec64324a..eef6123ec5 100644 --- a/tests/plugins/globals/test_globals.py +++ b/tests/plugins/globals/test_globals.py @@ -206,16 +206,12 @@ def setUp(self): self._originals = { "resource_prefix": Globals._RESOURCE_PREFIX, "supported_properties": Globals.supported_properties, - "unreleased_properties": Globals.unreleased_properties, } Globals._RESOURCE_PREFIX = "prefix_" Globals.supported_properties = { "prefix_type1": ["prop1", "prop2"], "prefix_type2": ["otherprop1", "otherprop2"], } - Globals.unreleased_properties = { - "prefix_type1": ["prop2"], - } self.template = { "Globals": { @@ -227,7 +223,6 @@ def setUp(self): def tearDown(self): Globals._RESOURCE_PREFIX = self._originals["resource_prefix"] Globals.supported_properties = self._originals["supported_properties"] - Globals.unreleased_properties = self._originals["unreleased_properties"] def test_parse_should_parse_all_known_resource_types(self): globals = Globals(self.template) @@ -392,17 +387,6 @@ def test_merge_end_to_end_unknown_type(self): self.assertEqual(expected, result) - def test_should_not_include_unreleased_properties_in_error_message(self): - template = {"Globals": {"type1": {"unsupported_property": "value"}}} - - with self.assertRaises(InvalidGlobalsSectionException) as exc: - Globals(template) - expected_message = ( - "'Globals' section is invalid. 'unsupported_property' is not a supported property of 'type1'. " - + "Must be one of the following values - ['prop1']" - ) - self.assertEqual(exc.exception.message, expected_message) - class TestGlobalsOpenApi(TestCase): template = {"Globals": {"Api": {"OpenApiVersion": "3.0"}}} diff --git a/tests/translator/input/error_function_with_function_url_config_with_invalid_cors_parameter.yaml b/tests/translator/input/error_function_with_function_url_config_with_invalid_cors_parameter.yaml deleted file mode 100644 index 35e5dafc26..0000000000 --- a/tests/translator/input/error_function_with_function_url_config_with_invalid_cors_parameter.yaml +++ /dev/null @@ -1,17 +0,0 @@ -AWSTemplateFormatVersion: '2010-09-09' -Parameters: {} -Resources: - MyFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: s3://sam-demo-bucket/hello.zip - Description: Created by SAM - Handler: index.handler - MemorySize: 1024 - Runtime: nodejs12.x - Timeout: 3 - FunctionUrlConfig: - AuthorizationType: NONE - Cors: - AllowOrigin: - - "https://example.com" diff --git a/tests/translator/input/error_function_with_function_url_config_with_invalid_cors_parameter_data_type.yaml b/tests/translator/input/error_function_with_function_url_config_with_invalid_cors_parameter_data_type.yaml deleted file mode 100644 index 00fa41bdb5..0000000000 --- a/tests/translator/input/error_function_with_function_url_config_with_invalid_cors_parameter_data_type.yaml +++ /dev/null @@ -1,16 +0,0 @@ -AWSTemplateFormatVersion: '2010-09-09' -Parameters: {} -Resources: - MyFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: s3://sam-demo-bucket/hello.zip - Description: Created by SAM - Handler: index.handler - MemorySize: 1024 - Runtime: nodejs12.x - Timeout: 3 - FunctionUrlConfig: - AuthorizationType: NONE - Cors: - MaxAge: "10" diff --git a/tests/translator/input/error_function_with_function_url_config_with_no_authorization_type.yaml b/tests/translator/input/error_function_with_function_url_config_with_no_authorization_type.yaml deleted file mode 100644 index 6ad04451e0..0000000000 --- a/tests/translator/input/error_function_with_function_url_config_with_no_authorization_type.yaml +++ /dev/null @@ -1,28 +0,0 @@ -AWSTemplateFormatVersion: '2010-09-09' -Parameters: {} -Resources: - MyFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: s3://sam-demo-bucket/hello.zip - Description: Created by SAM - Handler: index.handler - MemorySize: 1024 - Runtime: nodejs12.x - Timeout: 3 - FunctionUrlConfig: - Cors: - AllowOrigins: - - "https://example.com" - - "example1.com" - - "example2.com" - - "example2.com" - AllowMethods: - - "GET" - AllowCredentials: true - AllowHeaders: - - "x-Custom-Header" - ExposeHeaders: - - "x-amzn-header" - MaxAge: 10 - diff --git a/tests/translator/input/function_with_function_url_config.yaml b/tests/translator/input/function_with_function_url_config.yaml deleted file mode 100644 index 531bcd7bda..0000000000 --- a/tests/translator/input/function_with_function_url_config.yaml +++ /dev/null @@ -1,29 +0,0 @@ -AWSTemplateFormatVersion: '2010-09-09' -Parameters: {} -Resources: - MyFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: s3://sam-demo-bucket/hello.zip - Description: Created by SAM - Handler: index.handler - MemorySize: 1024 - Runtime: nodejs12.x - Timeout: 3 - FunctionUrlConfig: - AuthorizationType: NONE - Cors: - AllowOrigins: - - "https://example.com" - - "example1.com" - - "example2.com" - - "example2.com" - AllowMethods: - - "GET" - AllowCredentials: true - AllowHeaders: - - "x-Custom-Header" - ExposeHeaders: - - "x-amzn-header" - MaxAge: 10 - diff --git a/tests/translator/input/function_with_function_url_config_and_autopublishalias.yaml b/tests/translator/input/function_with_function_url_config_and_autopublishalias.yaml deleted file mode 100644 index c2f0fa530f..0000000000 --- a/tests/translator/input/function_with_function_url_config_and_autopublishalias.yaml +++ /dev/null @@ -1,30 +0,0 @@ -AWSTemplateFormatVersion: '2010-09-09' -Parameters: {} -Resources: - MyFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: s3://sam-demo-bucket/hello.zip - Description: Created by SAM - AutoPublishAlias: live - Handler: index.handler - MemorySize: 1024 - Runtime: nodejs12.x - Timeout: 3 - FunctionUrlConfig: - AuthorizationType: NONE - Cors: - AllowOrigins: - - "https://example.com" - - "example1.com" - - "example2.com" - - "example2.com" - AllowMethods: - - "GET" - AllowCredentials: true - AllowHeaders: - - "x-Custom-Header" - ExposeHeaders: - - "x-amzn-header" - MaxAge: 10 - diff --git a/tests/translator/input/function_with_function_url_config_with_intrinsics.yaml b/tests/translator/input/function_with_function_url_config_with_intrinsics.yaml deleted file mode 100644 index ef06ccbb9c..0000000000 --- a/tests/translator/input/function_with_function_url_config_with_intrinsics.yaml +++ /dev/null @@ -1,31 +0,0 @@ -AWSTemplateFormatVersion: '2010-09-09' -Parameters: - AuthorizationTypeRef: - Type: String - Default: NONE - - AllowOriginsRef: - Type: CommaDelimitedList - Default: "https://example.com" - - AllowMethodsRef: - Type: CommaDelimitedList - Default: "GET" - -Resources: - MyFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: s3://sam-demo-bucket/hello.zip - Description: Created by SAM - Handler: index.handler - MemorySize: 1024 - Runtime: nodejs12.x - Timeout: 3 - FunctionUrlConfig: - AuthorizationType: !Ref AuthorizationTypeRef - Cors: - AllowOrigins: !Ref AllowOriginsRef - AllowMethods: !Ref AllowMethodsRef - - diff --git a/tests/translator/input/function_with_function_url_config_without_cors_config.yaml b/tests/translator/input/function_with_function_url_config_without_cors_config.yaml deleted file mode 100644 index 4cd3e094e7..0000000000 --- a/tests/translator/input/function_with_function_url_config_without_cors_config.yaml +++ /dev/null @@ -1,15 +0,0 @@ -AWSTemplateFormatVersion: '2010-09-09' -Parameters: {} -Resources: - MyFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: s3://sam-demo-bucket/hello.zip - Description: Created by SAM - Handler: index.handler - MemorySize: 1024 - Runtime: nodejs12.x - Timeout: 3 - FunctionUrlConfig: - AuthorizationType: NONE - diff --git a/tests/translator/output/aws-cn/function_with_function_url_config.json b/tests/translator/output/aws-cn/function_with_function_url_config.json deleted file mode 100644 index 4f8fe2be84..0000000000 --- a/tests/translator/output/aws-cn/function_with_function_url_config.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "AWSTemplateFormatVersion": "2010-09-09", - "Parameters": {}, - "Resources": { - "MyFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "hello.zip" - }, - "Description": "Created by SAM", - "Handler": "index.handler", - "MemorySize": 1024, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs12.x", - "Timeout": 3, - "Tags": [ - { - "Key": "lambda:createdBy", - "Value": "SAM" - } - ] - } - }, - "MyFunctionUrl": { - "Type": "AWS::Lambda::Url", - "Properties": { - "TargetFunctionArn": { - "Ref": "MyFunction" - }, - "AuthorizationType": "NONE", - "Cors": { - "AllowOrigins": [ - "https://example.com", - "example1.com", - "example2.com", - "example2.com" - ], - "AllowMethods": [ - "GET" - ], - "AllowCredentials": true, - "AllowHeaders": [ - "x-Custom-Header" - ], - "ExposeHeaders": [ - "x-amzn-header" - ], - "MaxAge": 10 - } - } - }, - "MyFunctionRole": { - "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" - } - ] - } - } - } -} \ No newline at end of file diff --git a/tests/translator/output/aws-cn/function_with_function_url_config_and_autopublishalias.json b/tests/translator/output/aws-cn/function_with_function_url_config_and_autopublishalias.json deleted file mode 100644 index 233611bed3..0000000000 --- a/tests/translator/output/aws-cn/function_with_function_url_config_and_autopublishalias.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "AWSTemplateFormatVersion": "2010-09-09", - "Parameters": {}, - "Resources": { - "MyFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "hello.zip" - }, - "Description": "Created by SAM", - "Handler": "index.handler", - "MemorySize": 1024, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs12.x", - "Timeout": 3, - "Tags": [ - { - "Key": "lambda:createdBy", - "Value": "SAM" - } - ] - } - }, - "MyFunctionVersion7eab81fa22": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "FunctionName": { - "Ref": "MyFunction" - } - } - }, - "MyFunctionAliaslive": { - "Type": "AWS::Lambda::Alias", - "Properties": { - "Name": "live", - "FunctionName": { - "Ref": "MyFunction" - }, - "FunctionVersion": { - "Fn::GetAtt": [ - "MyFunctionVersion7eab81fa22", - "Version" - ] - } - } - }, - "MyFunctionUrl": { - "Type": "AWS::Lambda::Url", - "Properties": { - "TargetFunctionArn": { - "Ref": "MyFunctionAliaslive" - }, - "AuthorizationType": "NONE", - "Cors": { - "AllowOrigins": [ - "https://example.com", - "example1.com", - "example2.com", - "example2.com" - ], - "AllowMethods": [ - "GET" - ], - "AllowCredentials": true, - "AllowHeaders": [ - "x-Custom-Header" - ], - "ExposeHeaders": [ - "x-amzn-header" - ], - "MaxAge": 10 - } - } - }, - "MyFunctionRole": { - "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" - } - ] - } - } - } -} \ No newline at end of file diff --git a/tests/translator/output/aws-cn/function_with_function_url_config_with_intrinsics.json b/tests/translator/output/aws-cn/function_with_function_url_config_with_intrinsics.json deleted file mode 100644 index 2d03c3f34a..0000000000 --- a/tests/translator/output/aws-cn/function_with_function_url_config_with_intrinsics.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "AWSTemplateFormatVersion": "2010-09-09", - "Parameters": { - "AuthorizationTypeRef": { - "Type": "String", - "Default": "NONE" - }, - "AllowOriginsRef": { - "Type": "CommaDelimitedList", - "Default": "https://example.com" - }, - "AllowMethodsRef": { - "Type": "CommaDelimitedList", - "Default": "GET" - } - }, - "Resources": { - "MyFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "hello.zip" - }, - "Description": "Created by SAM", - "Handler": "index.handler", - "MemorySize": 1024, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs12.x", - "Timeout": 3, - "Tags": [ - { - "Key": "lambda:createdBy", - "Value": "SAM" - } - ] - } - }, - "MyFunctionUrl": { - "Type": "AWS::Lambda::Url", - "Properties": { - "TargetFunctionArn": { - "Ref": "MyFunction" - }, - "AuthorizationType": { - "Ref": "AuthorizationTypeRef" - }, - "Cors": { - "AllowOrigins": { - "Ref": "AllowOriginsRef" - }, - "AllowMethods": { - "Ref": "AllowMethodsRef" - } - } - } - }, - "MyFunctionRole": { - "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" - } - ] - } - } - } -} \ No newline at end of file diff --git a/tests/translator/output/aws-cn/function_with_function_url_config_without_cors_config.json b/tests/translator/output/aws-cn/function_with_function_url_config_without_cors_config.json deleted file mode 100644 index d8d4898b0b..0000000000 --- a/tests/translator/output/aws-cn/function_with_function_url_config_without_cors_config.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "AWSTemplateFormatVersion": "2010-09-09", - "Parameters": {}, - "Resources": { - "MyFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "hello.zip" - }, - "Description": "Created by SAM", - "Handler": "index.handler", - "MemorySize": 1024, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs12.x", - "Timeout": 3, - "Tags": [ - { - "Key": "lambda:createdBy", - "Value": "SAM" - } - ] - } - }, - "MyFunctionUrl": { - "Type": "AWS::Lambda::Url", - "Properties": { - "TargetFunctionArn": { - "Ref": "MyFunction" - }, - "AuthorizationType": "NONE" - } - }, - "MyFunctionRole": { - "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" - } - ] - } - } - } -} \ No newline at end of file diff --git a/tests/translator/output/aws-us-gov/function_with_function_url_config.json b/tests/translator/output/aws-us-gov/function_with_function_url_config.json deleted file mode 100644 index 9d22ea4688..0000000000 --- a/tests/translator/output/aws-us-gov/function_with_function_url_config.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "AWSTemplateFormatVersion": "2010-09-09", - "Parameters": {}, - "Resources": { - "MyFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "hello.zip" - }, - "Description": "Created by SAM", - "Handler": "index.handler", - "MemorySize": 1024, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs12.x", - "Timeout": 3, - "Tags": [ - { - "Key": "lambda:createdBy", - "Value": "SAM" - } - ] - } - }, - "MyFunctionUrl": { - "Type": "AWS::Lambda::Url", - "Properties": { - "TargetFunctionArn": { - "Ref": "MyFunction" - }, - "AuthorizationType": "NONE", - "Cors": { - "AllowOrigins": [ - "https://example.com", - "example1.com", - "example2.com", - "example2.com" - ], - "AllowMethods": [ - "GET" - ], - "AllowCredentials": true, - "AllowHeaders": [ - "x-Custom-Header" - ], - "ExposeHeaders": [ - "x-amzn-header" - ], - "MaxAge": 10 - } - } - }, - "MyFunctionRole": { - "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" - } - ] - } - } - } -} \ No newline at end of file diff --git a/tests/translator/output/aws-us-gov/function_with_function_url_config_and_autopublishalias.json b/tests/translator/output/aws-us-gov/function_with_function_url_config_and_autopublishalias.json deleted file mode 100644 index 9299370b6b..0000000000 --- a/tests/translator/output/aws-us-gov/function_with_function_url_config_and_autopublishalias.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "AWSTemplateFormatVersion": "2010-09-09", - "Parameters": {}, - "Resources": { - "MyFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "hello.zip" - }, - "Description": "Created by SAM", - "Handler": "index.handler", - "MemorySize": 1024, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs12.x", - "Timeout": 3, - "Tags": [ - { - "Key": "lambda:createdBy", - "Value": "SAM" - } - ] - } - }, - "MyFunctionVersion7eab81fa22": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "FunctionName": { - "Ref": "MyFunction" - } - } - }, - "MyFunctionAliaslive": { - "Type": "AWS::Lambda::Alias", - "Properties": { - "Name": "live", - "FunctionName": { - "Ref": "MyFunction" - }, - "FunctionVersion": { - "Fn::GetAtt": [ - "MyFunctionVersion7eab81fa22", - "Version" - ] - } - } - }, - "MyFunctionUrl": { - "Type": "AWS::Lambda::Url", - "Properties": { - "TargetFunctionArn": { - "Ref": "MyFunctionAliaslive" - }, - "AuthorizationType": "NONE", - "Cors": { - "AllowOrigins": [ - "https://example.com", - "example1.com", - "example2.com", - "example2.com" - ], - "AllowMethods": [ - "GET" - ], - "AllowCredentials": true, - "AllowHeaders": [ - "x-Custom-Header" - ], - "ExposeHeaders": [ - "x-amzn-header" - ], - "MaxAge": 10 - } - } - }, - "MyFunctionRole": { - "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" - } - ] - } - } - } -} \ No newline at end of file diff --git a/tests/translator/output/aws-us-gov/function_with_function_url_config_with_intrinsics.json b/tests/translator/output/aws-us-gov/function_with_function_url_config_with_intrinsics.json deleted file mode 100644 index 339db4ba30..0000000000 --- a/tests/translator/output/aws-us-gov/function_with_function_url_config_with_intrinsics.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "AWSTemplateFormatVersion": "2010-09-09", - "Parameters": { - "AuthorizationTypeRef": { - "Type": "String", - "Default": "NONE" - }, - "AllowOriginsRef": { - "Type": "CommaDelimitedList", - "Default": "https://example.com" - }, - "AllowMethodsRef": { - "Type": "CommaDelimitedList", - "Default": "GET" - } - }, - "Resources": { - "MyFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "hello.zip" - }, - "Description": "Created by SAM", - "Handler": "index.handler", - "MemorySize": 1024, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs12.x", - "Timeout": 3, - "Tags": [ - { - "Key": "lambda:createdBy", - "Value": "SAM" - } - ] - } - }, - "MyFunctionUrl": { - "Type": "AWS::Lambda::Url", - "Properties": { - "TargetFunctionArn": { - "Ref": "MyFunction" - }, - "AuthorizationType": { - "Ref": "AuthorizationTypeRef" - }, - "Cors": { - "AllowOrigins": { - "Ref": "AllowOriginsRef" - }, - "AllowMethods": { - "Ref": "AllowMethodsRef" - } - } - } - }, - "MyFunctionRole": { - "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" - } - ] - } - } - } -} \ No newline at end of file diff --git a/tests/translator/output/aws-us-gov/function_with_function_url_config_without_cors_config.json b/tests/translator/output/aws-us-gov/function_with_function_url_config_without_cors_config.json deleted file mode 100644 index 33d7c09114..0000000000 --- a/tests/translator/output/aws-us-gov/function_with_function_url_config_without_cors_config.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "AWSTemplateFormatVersion": "2010-09-09", - "Parameters": {}, - "Resources": { - "MyFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "hello.zip" - }, - "Description": "Created by SAM", - "Handler": "index.handler", - "MemorySize": 1024, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs12.x", - "Timeout": 3, - "Tags": [ - { - "Key": "lambda:createdBy", - "Value": "SAM" - } - ] - } - }, - "MyFunctionUrl": { - "Type": "AWS::Lambda::Url", - "Properties": { - "TargetFunctionArn": { - "Ref": "MyFunction" - }, - "AuthorizationType": "NONE" - } - }, - "MyFunctionRole": { - "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" - } - ] - } - } - } -} \ No newline at end of file diff --git a/tests/translator/output/error_function_with_function_url_config_with_invalid_cors_parameter.json b/tests/translator/output/error_function_with_function_url_config_with_invalid_cors_parameter.json deleted file mode 100644 index 749880b677..0000000000 --- a/tests/translator/output/error_function_with_function_url_config_with_invalid_cors_parameter.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [MyFunction] is invalid. AllowOrigin is not a valid property for configuring Cors." -} \ No newline at end of file diff --git a/tests/translator/output/error_function_with_function_url_config_with_invalid_cors_parameter_data_type.json b/tests/translator/output/error_function_with_function_url_config_with_invalid_cors_parameter_data_type.json deleted file mode 100644 index 4f02f1bc4e..0000000000 --- a/tests/translator/output/error_function_with_function_url_config_with_invalid_cors_parameter_data_type.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [MyFunction] is invalid. MaxAge must be of type int." -} \ No newline at end of file diff --git a/tests/translator/output/error_function_with_function_url_config_with_no_authorization_type.json b/tests/translator/output/error_function_with_function_url_config_with_no_authorization_type.json deleted file mode 100644 index 43bd0b6b51..0000000000 --- a/tests/translator/output/error_function_with_function_url_config_with_no_authorization_type.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [MyFunction] is invalid. AuthorizationType is required to configure function property `FunctionUrlConfig`. Please provide either an IAM role name or NONE." -} \ No newline at end of file diff --git a/tests/translator/output/error_globals_unsupported_property.json b/tests/translator/output/error_globals_unsupported_property.json index 899441b952..706b2aabd7 100644 --- a/tests/translator/output/error_globals_unsupported_property.json +++ b/tests/translator/output/error_globals_unsupported_property.json @@ -1,8 +1,8 @@ { "errors": [ { - "errorMessage": "'Globals' section is invalid. 'SomeKey' is not a supported property of 'Function'. Must be one of the following values - ['Handler', 'Runtime', 'CodeUri', 'DeadLetterQueue', 'Description', 'MemorySize', 'Timeout', 'VpcConfig', 'Environment', 'Tags', 'Tracing', 'KmsKeyArn', 'AutoPublishAlias', 'Layers', 'DeploymentPreference', 'PermissionsBoundary', 'ReservedConcurrentExecutions', 'ProvisionedConcurrencyConfig', 'EventInvokeConfig', 'FileSystemConfigs', 'CodeSigningConfigArn', 'Architectures', 'FunctionUrlConfig']" + "errorMessage": "'Globals' section is invalid. 'SomeKey' is not a supported property of 'Function'. Must be one of the following values - ['Handler', 'Runtime', 'CodeUri', 'DeadLetterQueue', 'Description', 'MemorySize', 'Timeout', 'VpcConfig', 'Environment', 'Tags', 'Tracing', 'KmsKeyArn', 'AutoPublishAlias', 'Layers', 'DeploymentPreference', 'PermissionsBoundary', 'ReservedConcurrentExecutions', 'ProvisionedConcurrencyConfig', 'EventInvokeConfig', 'FileSystemConfigs', 'CodeSigningConfigArn', 'Architectures']" } ], - "errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. 'Globals' section is invalid. 'SomeKey' is not a supported property of 'Function'. Must be one of the following values - ['Handler', 'Runtime', 'CodeUri', 'DeadLetterQueue', 'Description', 'MemorySize', 'Timeout', 'VpcConfig', 'Environment', 'Tags', 'Tracing', 'KmsKeyArn', 'AutoPublishAlias', 'Layers', 'DeploymentPreference', 'PermissionsBoundary', 'ReservedConcurrentExecutions', 'ProvisionedConcurrencyConfig', 'AssumeRolePolicyDocument', 'EventInvokeConfig', 'FileSystemConfigs', 'CodeSigningConfigArn', 'Architectures', 'FunctionUrlConfig']" + "errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. 'Globals' section is invalid. 'SomeKey' is not a supported property of 'Function'. Must be one of the following values - ['Handler', 'Runtime', 'CodeUri', 'DeadLetterQueue', 'Description', 'MemorySize', 'Timeout', 'VpcConfig', 'Environment', 'Tags', 'Tracing', 'KmsKeyArn', 'AutoPublishAlias', 'Layers', 'DeploymentPreference', 'PermissionsBoundary', 'ReservedConcurrentExecutions', 'ProvisionedConcurrencyConfig', 'AssumeRolePolicyDocument', 'EventInvokeConfig', 'FileSystemConfigs', 'CodeSigningConfigArn', 'Architectures']" } \ No newline at end of file diff --git a/tests/translator/output/function_with_function_url_config.json b/tests/translator/output/function_with_function_url_config.json deleted file mode 100644 index 799542dad9..0000000000 --- a/tests/translator/output/function_with_function_url_config.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "AWSTemplateFormatVersion": "2010-09-09", - "Parameters": {}, - "Resources": { - "MyFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "hello.zip" - }, - "Description": "Created by SAM", - "Handler": "index.handler", - "MemorySize": 1024, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs12.x", - "Timeout": 3, - "Tags": [ - { - "Key": "lambda:createdBy", - "Value": "SAM" - } - ] - } - }, - "MyFunctionUrl": { - "Type": "AWS::Lambda::Url", - "Properties": { - "TargetFunctionArn": { - "Ref": "MyFunction" - }, - "AuthorizationType": "NONE", - "Cors": { - "AllowOrigins": [ - "https://example.com", - "example1.com", - "example2.com", - "example2.com" - ], - "AllowMethods": [ - "GET" - ], - "AllowCredentials": true, - "AllowHeaders": [ - "x-Custom-Header" - ], - "ExposeHeaders": [ - "x-amzn-header" - ], - "MaxAge": 10 - } - } - }, - "MyFunctionRole": { - "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" - } - ] - } - } - } -} \ No newline at end of file diff --git a/tests/translator/output/function_with_function_url_config_and_autopublishalias.json b/tests/translator/output/function_with_function_url_config_and_autopublishalias.json deleted file mode 100644 index 89ed8e439d..0000000000 --- a/tests/translator/output/function_with_function_url_config_and_autopublishalias.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "AWSTemplateFormatVersion": "2010-09-09", - "Parameters": {}, - "Resources": { - "MyFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "hello.zip" - }, - "Description": "Created by SAM", - "Handler": "index.handler", - "MemorySize": 1024, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs12.x", - "Timeout": 3, - "Tags": [ - { - "Key": "lambda:createdBy", - "Value": "SAM" - } - ] - } - }, - "MyFunctionVersion7eab81fa22": { - "Type": "AWS::Lambda::Version", - "DeletionPolicy": "Retain", - "Properties": { - "FunctionName": { - "Ref": "MyFunction" - } - } - }, - "MyFunctionAliaslive": { - "Type": "AWS::Lambda::Alias", - "Properties": { - "Name": "live", - "FunctionName": { - "Ref": "MyFunction" - }, - "FunctionVersion": { - "Fn::GetAtt": [ - "MyFunctionVersion7eab81fa22", - "Version" - ] - } - } - }, - "MyFunctionUrl": { - "Type": "AWS::Lambda::Url", - "Properties": { - "TargetFunctionArn": { - "Ref": "MyFunctionAliaslive" - }, - "AuthorizationType": "NONE", - "Cors": { - "AllowOrigins": [ - "https://example.com", - "example1.com", - "example2.com", - "example2.com" - ], - "AllowMethods": [ - "GET" - ], - "AllowCredentials": true, - "AllowHeaders": [ - "x-Custom-Header" - ], - "ExposeHeaders": [ - "x-amzn-header" - ], - "MaxAge": 10 - } - } - }, - "MyFunctionRole": { - "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" - } - ] - } - } - } -} \ No newline at end of file diff --git a/tests/translator/output/function_with_function_url_config_with_intrinsics.json b/tests/translator/output/function_with_function_url_config_with_intrinsics.json deleted file mode 100644 index 4eaa593ab0..0000000000 --- a/tests/translator/output/function_with_function_url_config_with_intrinsics.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "AWSTemplateFormatVersion": "2010-09-09", - "Parameters": { - "AuthorizationTypeRef": { - "Type": "String", - "Default": "NONE" - }, - "AllowOriginsRef": { - "Type": "CommaDelimitedList", - "Default": "https://example.com" - }, - "AllowMethodsRef": { - "Type": "CommaDelimitedList", - "Default": "GET" - } - }, - "Resources": { - "MyFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "hello.zip" - }, - "Description": "Created by SAM", - "Handler": "index.handler", - "MemorySize": 1024, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs12.x", - "Timeout": 3, - "Tags": [ - { - "Key": "lambda:createdBy", - "Value": "SAM" - } - ] - } - }, - "MyFunctionUrl": { - "Type": "AWS::Lambda::Url", - "Properties": { - "TargetFunctionArn": { - "Ref": "MyFunction" - }, - "AuthorizationType": { - "Ref": "AuthorizationTypeRef" - }, - "Cors": { - "AllowOrigins": { - "Ref": "AllowOriginsRef" - }, - "AllowMethods": { - "Ref": "AllowMethodsRef" - } - } - } - }, - "MyFunctionRole": { - "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" - } - ] - } - } - } -} \ No newline at end of file diff --git a/tests/translator/output/function_with_function_url_config_without_cors_config.json b/tests/translator/output/function_with_function_url_config_without_cors_config.json deleted file mode 100644 index cb2c9db27c..0000000000 --- a/tests/translator/output/function_with_function_url_config_without_cors_config.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "AWSTemplateFormatVersion": "2010-09-09", - "Parameters": {}, - "Resources": { - "MyFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "hello.zip" - }, - "Description": "Created by SAM", - "Handler": "index.handler", - "MemorySize": 1024, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs12.x", - "Timeout": 3, - "Tags": [ - { - "Key": "lambda:createdBy", - "Value": "SAM" - } - ] - } - }, - "MyFunctionUrl": { - "Type": "AWS::Lambda::Url", - "Properties": { - "TargetFunctionArn": { - "Ref": "MyFunction" - }, - "AuthorizationType": "NONE" - } - }, - "MyFunctionRole": { - "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" - } - ] - } - } - } -} \ No newline at end of file diff --git a/tests/translator/test_translator.py b/tests/translator/test_translator.py index 5048e15f85..1cf5673bab 100644 --- a/tests/translator/test_translator.py +++ b/tests/translator/test_translator.py @@ -455,10 +455,6 @@ class TestTranslatorEndToEnd(AbstractTestTranslator): "function_with_self_managed_kafka", "function_with_auth_mechanism_for_self_managed_kafka", "function_with_vpc_permission_for_self_managed_kafka", - "function_with_function_url_config", - "function_with_function_url_config_with_intrinsics", - "function_with_function_url_config_and_autopublishalias", - "function_with_function_url_config_without_cors_config", ], [ ("aws", "ap-southeast-1"), diff --git a/versions/2016-10-31.md b/versions/2016-10-31.md index 6273228461..3794356fe1 100644 --- a/versions/2016-10-31.md +++ b/versions/2016-10-31.md @@ -137,8 +137,6 @@ ReservedConcurrentExecutions | `integer` | The maximum of concurrent executions ProvisionedConcurrencyConfig | [ProvisionedConcurrencyConfig Object](#provisioned-concurrency-config-object) | Configure provisioned capacity for a number of concurrent executions on Lambda Alias property. EventInvokeConfig | [EventInvokeConfig object](#event-invoke-config-object) | Configure options for [asynchronous invocation](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html) on the function. Architectures | List of `string` | The CPU architecture to run on (x86_64 or arm64), accepts only one value. Defaults to x86_64. -FunctionUrlConfig | Map of Url configuration parameters | A map that defines the configuration properties needed to create a Lambda URL resource. These properties are `AuthorizationType` (a required property that accepts an `IAM role` or `NONE`) and `Cors` (similar to [HttpApiCorsConfiguration](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-httpapi-httpapicorsconfiguration.html)) - ##### Return values