-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
Adding FunctionUrlConfig to a serverless function definition which also has a pre-traffic hook creates a lambda permission that points to the latest version of the funciton, not the 'live' alias and browsing the lambda endpoint returns {"error": "Forbidden"}.
Using the AWS Console, the lambda function shows the Permission on the latest version, but does not show the URL. Changing to the live alias shows the URL but not the permission.
Example template:
` MyTestLambda:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/
Handler: main.lambda_handler
Runtime: python3.9
FunctionName: MyTestLambda
Description: Test lambda
AutoPublishAlias: live
DeploymentPreference:
Type: AllAtOnce
Hooks:
PreTraffic: !Ref PreTrafficHook
FunctionUrlConfig:
AuthType: NONE
For ref, this is what I had to add as a workaround:
Type: AWS::Lambda::Permission
Properties:
Action: lambda:InvokeFunctionUrl
Principal: "*"
FunctionName:
!Sub
- "${name}:live"
- name:
!Ref myTestLambda
FunctionUrlAuthType: NONE
`
Using aws-sam-cli version 1.46 on both macOS and Linux.