Repository navigation
Open
Labels
area/intrinsicsRef, If, Sub, GetAtt, ...area/local/start-apisam local start-api commandstage/bug-reproThe issue/bug needs to be reproduced
Description
Description:
Got this error when trying to test my lambda authorizer locally with sam build and sam local start-api: Unable to parse the Lambda ARN for Authorizer 'LambdaAuthorizer', skipping
here's my cloudformation template:
lambdaAuthorizer:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub LambdaAuthorizer-${StageName}
CodeUri: lambda_authorizer/
Handler: src/handlers/authorizer.handler
Runtime: nodejs20.x
Timeout: 900
MemorySize: 512
Role: !GetAtt MyLambdaExecutionRole.Arn
Environment:
Variables:
COGNITO_USERPOOL_ID: "..."
COGNITO_CLIENT_ID: "..."
MyApi:
Type: AWS::Serverless::Api
Properties:
# StageName: dev
StageName: !Sub MyApi-${StageName}
Auth:
DefaultAuthorizer: CognitoAuthorizer
AddDefaultAuthorizerToCorsPreflight: False
Authorizers:
LambdaAuthorizer:
FunctionArn: !GetAtt lambdaAuthorizer.Arn
CognitoAuthorizer:
UserPoolArn: arn:aws:cognito-idp:us-east-1:$account_id:userpool/...
Steps to reproduce:
Observed result:
The authorizer lambda function's arn cannot be parsed, but i have followed multiple AWS docs and it seems this is the only correct way to do it
Expected result:
I think this is quite a straightforward cloudformation and i don't understand why it cannot parse the arn
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Mac
sam --version: SAM CLI, version 1.124.0- AWS region: us-east-1
{
"version": "1.124.0",
"system": {
"python": "3.8.20",
"os": "macOS-12.7.5-x86_64-i386-64bit"
},
"additional_dependencies": {
"docker_engine": "20.10.16",
"aws_cdk": "Not available",
"terraform": "1.9.3"
},
"available_beta_feature_env_vars": [
"SAM_CLI_BETA_FEATURES",
"SAM_CLI_BETA_BUILD_PERFORMANCE",
"SAM_CLI_BETA_TERRAFORM_SUPPORT",
"SAM_CLI_BETA_RUST_CARGO_LAMBDA"
]
}
Add --debug flag to command you are running
Reacted by Sai Phaninder Reddy Jonnala
Metadata
Metadata
Assignees
Labels
area/intrinsicsRef, If, Sub, GetAtt, ...area/local/start-apisam local start-api commandstage/bug-reproThe issue/bug needs to be reproduced
Activity
sidhujus commentedon Sep 19, 2024
Hi @gnowobu thanks for raising this issue! Could you provide the full sam cli output when running the command with the
--debugflag?I tried with a couple different templates and was unable to reproduce the error.
gnowobu commentedon Sep 19, 2024
Hi @sidhujus thanks for reaching out. Here's the debug output that i think it's related, please let me know if you need more output from that.
sernone commentedon Apr 4, 2025
I am having this same issue , its been driving me crazy i tried everything is there an update on this fix ?
damiengiese commentedon Sep 30, 2025
Here's another template that exhibits this issue.
When
sam local start-apiis executed, we get the following:With the
--debugoption, we get the following, which I suppose is the problem.If we remove the
FunctionNameproperty fromMyAuthFunctionor change it to a fixed value, SAM works as expected.My current workaround requires conditionally creating an alternate nameless authorizer resource for use with SAM. Obviously, not ideal.
lukacssandor commentedon Nov 19, 2025
After some debugging and reviewing the CLI local command implementations, I discovered that it only supports the
Subintrinsic function: https://github.com/aws/aws-sam-cli/blob/main/samcli/commands/local/lib/swagger/integration_uri.py#L96.So a possible solution now would be to construct the authorizer function's ARN manually:
This is still far from ideal, but an acceptable workaround in my opinion, as you can't reuse the function name because CF doesn't support intrinsic functions in any of the template sections where you might define it.