Skip to content

Commit e214dac

Browse files
authored
Merge pull request #2232 from aws/hotfix_remove_lambdaurls
Revert "feat: Lambda URLs (#2229)"
2 parents 28b2b72 + 5391e1e commit e214dac

File tree

35 files changed

+5
-1679
lines changed

35 files changed

+5
-1679
lines changed

integration/resources/expected/single/basic_function_with_function_url_config.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

integration/resources/expected/single/basic_function_with_function_url_with_autopuplishalias.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

integration/resources/templates/single/basic_function_with_function_url_config.yaml

Lines changed: 0 additions & 21 deletions
This file was deleted.

integration/resources/templates/single/basic_function_with_function_url_with_autopuplishalias.yaml

Lines changed: 0 additions & 22 deletions
This file was deleted.

integration/single/test_basic_function.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -66,39 +66,6 @@ def test_basic_function_with_architecture(self, file_name, architecture):
6666

6767
self.assertEqual(function_architecture, architecture)
6868

69-
@parameterized.expand(
70-
[
71-
("single/basic_function_with_function_url_config", None),
72-
("single/basic_function_with_function_url_with_autopuplishalias", "live"),
73-
]
74-
)
75-
@skipIf(current_region_does_not_support(["Url"]), "Url is not supported in this testing region")
76-
def test_basic_function_with_url_config(self, file_name, qualifier):
77-
"""
78-
Creates a basic lambda function with Function Url enabled
79-
"""
80-
self.create_and_verify_stack(file_name)
81-
82-
lambda_client = self.client_provider.lambda_client
83-
84-
function_name = self.get_physical_id_by_type("AWS::Lambda::Function")
85-
function_url_config = (
86-
lambda_client.get_function_url_config(FunctionName=function_name, Qualifier=qualifier)
87-
if qualifier
88-
else lambda_client.get_function_url_config(FunctionName=function_name)
89-
)
90-
cors_config = {
91-
"AllowOrigins": ["https://foo.com"],
92-
"AllowMethods": ["POST"],
93-
"AllowCredentials": True,
94-
"AllowHeaders": ["x-Custom-Header"],
95-
"ExposeHeaders": ["x-amzn-header"],
96-
"MaxAge": 10,
97-
}
98-
99-
self.assertEqual(function_url_config["AuthorizationType"], "NONE")
100-
self.assertEqual(function_url_config["Cors"], cors_config)
101-
10269
def test_function_with_deployment_preference_alarms_intrinsic_if(self):
10370
self.create_and_verify_stack("single/function_with_deployment_preference_alarms_intrinsic_if")
10471

samtranslator/model/lambda_.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,3 @@ class LambdaLayerVersion(Resource):
121121
}
122122

123123
runtime_attrs = {"name": lambda self: ref(self.logical_id), "arn": lambda self: fnGetAtt(self.logical_id, "Arn")}
124-
125-
126-
class LambdaUrl(Resource):
127-
resource_type = "AWS::Lambda::Url"
128-
property_types = {
129-
"TargetFunctionArn": PropertyType(True, one_of(is_str(), is_type(dict))),
130-
"AuthorizationType": PropertyType(True, is_str()),
131-
"Cors": PropertyType(False, is_type(dict)),
132-
}

samtranslator/model/sam_resources.py

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
LambdaAlias,
3535
LambdaLayerVersion,
3636
LambdaEventInvokeConfig,
37-
LambdaUrl,
3837
)
3938
from samtranslator.model.types import dict_of, is_str, is_type, list_of, one_of, any_type
4039
from samtranslator.translator import logical_id_generator
@@ -94,7 +93,6 @@ class SamFunction(SamResourceMacro):
9493
"ImageConfig": PropertyType(False, is_type(dict)),
9594
"CodeSigningConfigArn": PropertyType(False, is_str()),
9695
"Architectures": PropertyType(False, list_of(one_of(is_str(), is_type(dict)))),
97-
"FunctionUrlConfig": PropertyType(False, is_type(dict)),
9896
}
9997
event_resolver = ResourceTypeResolver(
10098
samtranslator.model.eventsources,
@@ -171,10 +169,6 @@ def to_cloudformation(self, **kwargs):
171169
resources.append(lambda_version)
172170
resources.append(lambda_alias)
173171

174-
if self.FunctionUrlConfig:
175-
lambda_url = self._construct_lambda_url(lambda_function, lambda_alias)
176-
resources.append(lambda_url)
177-
178172
if self.DeploymentPreference:
179173
self._validate_deployment_preference_and_add_update_policy(
180174
kwargs.get("deployment_preference_collection", None),
@@ -849,84 +843,6 @@ def _validate_deployment_preference_and_add_update_policy(
849843
"UpdatePolicy", deployment_preference_collection.update_policy(self.logical_id).to_dict()
850844
)
851845

852-
def _construct_lambda_url(self, lambda_function, lambda_alias):
853-
"""
854-
This method is used to construct a lambda url resource
855-
856-
Parameters
857-
----------
858-
lambda_function : LambdaFunction
859-
Lambda Function resource
860-
lambda_alias : LambdaAlias
861-
Lambda Alias resource
862-
863-
Returns
864-
-------
865-
LambdaUrl
866-
Lambda Url resource
867-
"""
868-
self._validate_function_url_params(lambda_function)
869-
870-
logical_id = "{id}Url".format(id=lambda_function.logical_id)
871-
lambda_url = LambdaUrl(logical_id=logical_id)
872-
873-
cors = self.FunctionUrlConfig.get("Cors")
874-
if cors:
875-
lambda_url.Cors = cors
876-
lambda_url.AuthorizationType = self.FunctionUrlConfig.get("AuthorizationType")
877-
lambda_url.TargetFunctionArn = (
878-
lambda_alias.get_runtime_attr("arn") if lambda_alias else lambda_function.get_runtime_attr("name")
879-
)
880-
return lambda_url
881-
882-
def _validate_function_url_params(self, lambda_function):
883-
"""
884-
Validate parameters provided to configure Lambda Urls
885-
"""
886-
self._validate_url_auth_type(lambda_function)
887-
self._validate_cors_config_parameter(lambda_function)
888-
889-
def _validate_url_auth_type(self, lambda_function):
890-
if is_intrinsic(self.FunctionUrlConfig):
891-
return
892-
893-
if not self.FunctionUrlConfig.get("AuthorizationType"):
894-
raise InvalidResourceException(
895-
lambda_function.logical_id,
896-
"AuthorizationType is required to configure function property `FunctionUrlConfig`. Please provide either an IAM role name or NONE.",
897-
)
898-
899-
def _validate_cors_config_parameter(self, lambda_function):
900-
if is_intrinsic(self.FunctionUrlConfig):
901-
return
902-
903-
cors_property_data_type = {
904-
"AllowOrigins": list,
905-
"AllowMethods": list,
906-
"AllowCredentials": bool,
907-
"AllowHeaders": list,
908-
"ExposeHeaders": list,
909-
"MaxAge": int,
910-
}
911-
912-
cors = self.FunctionUrlConfig.get("Cors")
913-
914-
if not cors or is_intrinsic(cors):
915-
return
916-
917-
for prop_name, prop_value in cors.items():
918-
if prop_name not in cors_property_data_type:
919-
raise InvalidResourceException(
920-
lambda_function.logical_id,
921-
"{} is not a valid property for configuring Cors.".format(prop_name),
922-
)
923-
prop_type = cors_property_data_type.get(prop_name)
924-
if not is_intrinsic(prop_value) and not isinstance(prop_value, prop_type):
925-
raise InvalidResourceException(
926-
lambda_function.logical_id,
927-
"{} must be of type {}.".format(prop_name, str(prop_type).split("'")[1]),
928-
)
929-
930846

931847
class SamApi(SamResourceMacro):
932848
"""SAM rest API macro."""

samtranslator/plugins/globals/globals.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class Globals(object):
4343
"FileSystemConfigs",
4444
"CodeSigningConfigArn",
4545
"Architectures",
46-
"FunctionUrlConfig",
4746
],
4847
# Everything except
4948
# DefinitionBody: because its hard to reason about merge of Swagger dictionaries
@@ -81,8 +80,6 @@ class Globals(object):
8180
],
8281
SamResourceType.SimpleTable.value: ["SSESpecification"],
8382
}
84-
# unreleased_properties *must be* part of supported_properties too
85-
unreleased_properties = {}
8683

8784
def __init__(self, template):
8885
"""
@@ -198,17 +195,14 @@ def _parse(self, globals_dict):
198195
if not isinstance(properties, dict):
199196
raise InvalidGlobalsSectionException(self._KEYWORD, "Value of ${section} must be a dictionary")
200197

201-
supported = self.supported_properties[resource_type]
202-
supported_displayed = [
203-
prop for prop in supported if prop not in self.unreleased_properties.get(resource_type, [])
204-
]
205198
for key, value in properties.items():
199+
supported = self.supported_properties[resource_type]
206200
if key not in supported:
207201
raise InvalidGlobalsSectionException(
208202
self._KEYWORD,
209203
"'{key}' is not a supported property of '{section}'. "
210204
"Must be one of the following values - {supported}".format(
211-
key=key, section=section_name, supported=supported_displayed
205+
key=key, section=section_name, supported=supported
212206
),
213207
)
214208

0 commit comments

Comments
 (0)