Skip to content

Commit

Permalink
Furl AutopublishAlias bug fix (aws#2378)
Browse files Browse the repository at this point in the history
* furl autopublishing bug fix

* failing test fix
  • Loading branch information
jonife authored May 19, 2022
1 parent f7418d8 commit 6188d82
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
11 changes: 8 additions & 3 deletions samtranslator/model/sam_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def to_cloudformation(self, **kwargs):
if self.FunctionUrlConfig:
lambda_url = self._construct_function_url(lambda_function, lambda_alias)
resources.append(lambda_url)
url_permission = self._construct_url_permission(lambda_function)
url_permission = self._construct_url_permission(lambda_function, lambda_alias)
if url_permission:
resources.append(url_permission)

Expand Down Expand Up @@ -1006,7 +1006,7 @@ def _validate_cors_config_parameter(self, lambda_function):
"{} must be of type {}.".format(prop_name, str(prop_type).split("'")[1]),
)

def _construct_url_permission(self, lambda_function):
def _construct_url_permission(self, lambda_function, lambda_alias):
"""
Construct the lambda permission associated with the function url resource in a case
for public access when AuthType is NONE
Expand All @@ -1016,6 +1016,9 @@ def _construct_url_permission(self, lambda_function):
lambda_function : LambdaUrl
Lambda Function resource
llambda_alias : LambdaAlias
Lambda Alias resource
Returns
-------
LambdaPermission
Expand All @@ -1030,7 +1033,9 @@ def _construct_url_permission(self, lambda_function):
lambda_permission_attributes = self.get_passthrough_resource_attributes()
lambda_permission = LambdaPermission(logical_id=logical_id, attributes=lambda_permission_attributes)
lambda_permission.Action = "lambda:InvokeFunctionUrl"
lambda_permission.FunctionName = lambda_function.get_runtime_attr("name")
lambda_permission.FunctionName = (
lambda_alias.get_runtime_attr("arn") if lambda_alias else lambda_function.get_runtime_attr("name")
)
lambda_permission.Principal = "*"
lambda_permission.FunctionUrlAuthType = auth_type
return lambda_permission
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"Properties": {
"Action": "lambda:InvokeFunctionUrl",
"FunctionName": {
"Ref": "MyFunction"
"Ref": "MyFunctionAliaslive"
},
"Principal": "*",
"FunctionUrlAuthType": "NONE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"Properties": {
"Action": "lambda:InvokeFunctionUrl",
"FunctionName": {
"Ref": "MyFunction"
"Ref": "MyFunctionAliaslive"
},
"Principal": "*",
"FunctionUrlAuthType": "NONE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"Properties": {
"Action": "lambda:InvokeFunctionUrl",
"FunctionName": {
"Ref": "MyFunction"
"Ref": "MyFunctionAliaslive"
},
"Principal": "*",
"FunctionUrlAuthType": "NONE"
Expand Down

0 comments on commit 6188d82

Please sign in to comment.