# ServerlessFrameWork- SharedAwsCustomAuthorizer

**URL:** https://forum.serverless.com/t/serverlessframework-sharedawscustomauthorizer/12161
**Category:** Serverless Framework
**Tags:** lambda
**Created:** [July 30, 2020, 5:02pm UTC](https://forum.serverless.com/t/serverlessframework-sharedawscustomauthorizer/12161 "2020-07-30T17:02:46Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![magizam](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@magizam](https://forum.serverless.com/u/magizam)
#### Post date: [July 30, 2020, 5:02pm UTC](https://forum.serverless.com/t/serverlessframework-sharedawscustomauthorizer/12161/1 "2020-07-30T17:02:46Z")

</div>

Hi,  
We are trying to share the aws lambda custom authorizer function across multiple API-Gateway, we are deploying this using serverless framework, while trying the same we got the below error.

**Error Message:**  
Logicai Id: “ArnLambdaPermissionApiGateway”  
status Reason: “Function not found: FunctionName (Service: AWSLambda; Status Code: 404; Error Code: ResourceNotFoundException; Request ID: \*\*\*\*)”

We are using serverless framework for the deploy, I have mentioned the reference url which we also referred.

FYI  
Shared Api gateway method:  
ref:[https://www.serverless.com/framework/docs/providers/aws/events/apigateway/#share-api-gateway-and-api-resources](https://www.serverless.com/framework/docs/providers/aws/events/apigateway/#share-api-gateway-and-api-resources)

Shared authorizers  
ref:[https://stackoverflow.com/questions/53302266/shared-lambda-authorizer-setup-in-serverless-framework?rq=1](https://stackoverflow.com/questions/53302266/shared-lambda-authorizer-setup-in-serverless-framework?rq=1)

Could any one please help us on this.I also shared the service.yml file and dummy project folder.

I have the below service.yaml file in the main folder

service: api  
provider:  
name: aws  
runtime: nodejs12.x  
stage: PreProd  
region: us-east-1  
versionFunctions: false # optional, default is true  
environment:  
STAGE: PreProd  
apiKeys:  
- serverless-apikey  
ApiGatewayRestApi:  
restApiId:  
“Fn::ImportValue”: apiGateway-RestApiId  
stackTags:  
Billing: \*\*\*\*\*\*  
Support: \*\*\*\*  
Author: \*\*\*\*\*  
Owner: \*\*\*\*\*  
Project: ProjectName  
Application: ApplicationName  
Enviroment: Preproduction  
tags:  
Billing: “\*\*\*\*\*\*”  
Support: \*\*\*\*  
Author: \*\*\*\*\*  
Owner: \*\*\*\*\*\*  
Project: \*\*\*\*\*  
Application: \*\*\*  
Enviroment: Preproduction  
deploymentBucket: bucketname

functions:  
sharedAuthorizer:  
handler: ./authorizers/authorizer.js  
name: SharedApiGateway-Authorizer  
role: arn:aws:iam::\*\*\*\*\*\*\*\*  
vpc:  
securityGroupIds:  
- sg-\*\*\*\*\*\*  
subnetIds:  
- subnet-\*\*\*\*\*\*\*  
- subnet-\*\*\*\*\*\*\*\*  
description: deploying from serverless  
tags:  
Name: PREPROD-SHAREDAPIGATEWAY-AUTHORIZER-LAMBDA  
healthCheck:  
handler: ./health\_check/health\_check.handler  
role: arn:aws:iam::\*\*\*  
vpc:  
securityGroupIds:  
- sg-  
subnetIds:  
- subnet  
- subnet  
description: deploying from serverless  
tags:  
Name: PREPROD-HEALTH-CHECK-LAMBDA  
events:  
- http:  
path: v1/healthcheck  
method: get  
private: true  
cors: true  
integration: lambda  
documentation:  
summary: “HealthCheck API returns status Okay to everyone if infrastructure is available”  
description: “HealthCheck API”  
custom:  
apiGatewayCloudWatchSettings:  
metricsEnabled: true  
exportOutputs:  
- apiGatewayRestApiId  
- apiGatewayRestApiRootResourceId  
documentation:  
api:  
info:  
version: “1”  
title: “Data Scince Group Grapevine - Analytics API”  
description: “API to get analytics data”  
termsOfService: \*\*\*\*\*  
contact:  
name: Name  
email: \*\*\*\*  
license:  
name: “Licensing”  
url: \*\*\*\*\*

plugins:

- serverless-aws-documentation
- serverless-offline
- serverless-export-outputs

# - serverless-reqvalidator-plugin

# - serverless-api-gateway-cloudwatch-settings

resources:

Outputs:  
apiGatewayRestApiId:  
Value:  
Ref: ApiGatewayRestApi  
Export:  
Name: SharedApiGateway-RestApiId  
apiGatewayRestApiRootResourceId:  
Value:  
Fn::GetAtt:  
- ApiGatewayRestApi  
- RootResourceId  
Export:  
Name: SharedApiGateway-RootResourceId  
apiGatewayRestApiV1ResourceId:  
Value:  
Ref: ApiGatewayResourceV1  
Export:  
Name: SharedApiGateway-V1ResourceId  
ApiGatewayApiKey:  
Value:  
Ref: ApiGatewayApiKey1  
Export:  
Name: SharedApiGateway-RestApiKey  
sharedAuthorizerARN:  
Value: { “Fn::GetAtt”: [“SharedAuthorizerLambdaFunction”, “Arn”] }  
Export:  
Name: SharedApiGateway-Authorizer-Lamba-Function

I also have the other service.yaml file inside the folder called health\_check\_full, I am sharing that code below  
service: api-1  
provider:  
name: aws  
runtime: nodejs12.x  
stage: PreProd  
region: us-east-1  
versionFunctions: false  
environment:  
STAGE: PreProd

# SharedApiGateway-Authorizer:

# “Fn::ImportValue”: SharedApiGateway-Authorizer

apiGateway:  
restApiId:  
“Fn::ImportValue”: SharedApiGateway-RestApiId  
restApiRootResourceId:  
“Fn::ImportValue”: SharedApiGateway-RootResourceId  
restApiResources:  
“v1”:  
“Fn::ImportValue”: SharedApiGateway-V1ResourceId  
stackTags:  
Billing: “**"  
Support: \*\*\*\*\*  
Author: \*\*\*\*\*  
Owner: \*\*\*\*\*  
Project: \*\*\*\*\*  
Application: api  
Enviroment: Preproduction  
tags:  
Billing: "**”  
Support: \*\*\*\*  
Author: \*\*\*\*\*\*  
Owner: \*\*\*\*  
Project: Project  
Application: api  
Enviroment: Preproduction  
deploymentBucket: BucketName  
functions:  
healthCheckFull:  
handler: health\_check\_full.handler  
role: arn:aws:iam::\*\*\*\*  
vpc:  
securityGroupIds:  
- sg-\*\*\*\*\*  
subnetIds:  
- subnet-\*\*\*\*\*  
- subnet-\*\*\*\*\*  
description: deploying from serverless  
tags:  
Name: API-PREPROD-HEALTH-CHECK-FULL-LAMBDA  
events:  
- http:  
path: v1/healthcheckfull  
method: get  
private: true  
cors: true  
integration: lambda  
authorizer:  
type: CUSTOM  
authorizerId:  
Ref: Authorizer  
documentation:  
summary: “HealthCheckFull API returns status Okay to everyone if infrastructure is available”  
description: “HealthCheckFull API”  
custom:  
documentation:  
models:  
- name: “ErrorResponse”  
description: “This is an error”  
contentType: “application/json”  
schema: ${file(…/documentation\_models/ErrorResponse.json)}

plugins:

- serverless-aws-documentation
- serverless-offline

# - serverless-reqvalidator-plugin

# - serverless-api-gateway-cloudwatch-settings

resources:  
Resources:  
Authorizer:  
Type: AWS::ApiGateway::Authorizer  
Properties:  
Name: Authorizer  
Type: REQUEST  
AuthorizerUri:  
Fn::Join:  
[  
“”,  
[  
“arn:aws:apigateway:”,  
“${self:provider.region}”,  
“:lambda:path/”,  
“2015-03-31/functions/”,  
“Fn::ImportValue”: SharedApiGateway-Authorizer-Lamba-Function,  
“/invocations”,  
],  
]  
RestApiId:  
#Ref: ApiGatewayRestApi  
“Fn::ImportValue”: SharedApiGateway-RestApiId  
Outputs:  
AuthorizerRef:  
Value:  
Ref: Authorizer  
Export:  
Name: Authorizer
