# Bug in Api Gateway Authorizer schema for authorizer.type = CUSTOM?

**URL:** <https://forum.serverless.com/t/bug-in-api-gateway-authorizer-schema-for-authorizer-type-custom/13171>\
**Category:** Serverless Framework\
**Tags:** api-gateway\
**Created:** [November 20, 2020, 1:18pm UTC](https://forum.serverless.com/t/bug-in-api-gateway-authorizer-schema-for-authorizer-type-custom/13171 "2020-11-20T13:18:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hansolaf](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/hansolaf/32/4745_2.png) [@hansolaf](https://forum.serverless.com/u/hansolaf)\
**Post date:** [November 20, 2020, 1:18pm UTC](https://forum.serverless.com/t/bug-in-api-gateway-authorizer-schema-for-authorizer-type-custom/13171/1 "2020-11-20T13:18:28Z")

</div>

For a while we’ve used a setup where multiple serverless files use the same Api Gateway and share authorizers that are defined in a separate cloudformation stack. We’ve used authorizer type = “CUSTOM” and an authorizerId to point to an existing authorizer, but upon upgrading to serverless v2 I get an error saying: `Configuration warning at 'functions.get.events[0].http.authorizer.type': unsupported configuration format`

A typical template looks like this:

```auto
service: my-test-service
provider:
  name: aws
  region: eu-west-1
  stage: prod
  runtime: python3.7
  apiGateway:
    restApiId: fjei400f
    restApiRootResourceId: af4i4i

functions:
  get:
    handler: handler.handle_stuff
    events:
      - http:
          path: my-path
          method: get
          authorizer:
            type: CUSTOM
            authorizerId: aliwjefij3

```

But it works just as expected. Is there a bug in the schema definition for the api gateway authorizer setup?

Here is the corresponding Cloudformation docs that confirm that CUSTOM is the right type:

> **[AWS::ApiGateway::Method - AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-method.html#cfn-apigateway-method-authorizationtype)**

---

<div class="post-metadata">

**Author:** ![jayceesnow](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/jayceesnow/32/4837_2.png) [@jayceesnow](https://forum.serverless.com/u/jayceesnow)\
**Post date:** [December 6, 2020, 6:54pm UTC](https://forum.serverless.com/t/bug-in-api-gateway-authorizer-schema-for-authorizer-type-custom/13171/2 "2020-12-06T18:54:45Z")

</div>

Hi

I am having the same warning, did you find how to remove it?

---

<div class="post-metadata">

**Author:** ![bfieber](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/bfieber/32/653_2.png) [@bfieber](https://forum.serverless.com/u/bfieber)\
**Post date:** [December 7, 2020, 4:56pm UTC](https://forum.serverless.com/t/bug-in-api-gateway-authorizer-schema-for-authorizer-type-custom/13171/3 "2020-12-07T16:56:42Z")

</div>

`CUSTOM` doesn’t appear to be a valid authorizer type.  
From the [AWS API Gateway Authorizer Reference:](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-authorizer.html#cfn-apigateway-authorizer-type)

```auto
Type
  The type of authorizer. Valid values include:
    * TOKEN: A custom authorizer that uses a Lambda function.
    * COGNITO_USER_POOLS: An authorizer that uses Amazon Cognito user pools.
    * REQUEST: An authorizer that uses a Lambda function using incoming request parameters.
```

---

<div class="post-metadata">

**Author:** ![jayceesnow](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/jayceesnow/32/4837_2.png) [@jayceesnow](https://forum.serverless.com/u/jayceesnow)\
**Post date:** [December 7, 2020, 10:25pm UTC](https://forum.serverless.com/t/bug-in-api-gateway-authorizer-schema-for-authorizer-type-custom/13171/4 "2020-12-07T22:25:01Z")

</div>

> [@bfieber](#):
>
> AWS API Gateway Authorizer Reference:

the log error have this:

```auto
  An error occurred: ApiGatewayMethodPartclassSearchPost - Invalid AuthorizationType specified. Valid options are NONE,AWS_IAM,CUSTOM,COGNITO_USER_POOLS,AWS_CROSS_ACCOUNT_IAM,JWT (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: 2bc0e89f-26f9-4497-9207-2f8d33f735d1; Proxy: null).

```

---

<div class="post-metadata">

**Author:** ![hansolaf](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/hansolaf/32/4745_2.png) [@hansolaf](https://forum.serverless.com/u/hansolaf)\
**Post date:** [December 8, 2020, 11:25am UTC](https://forum.serverless.com/t/bug-in-api-gateway-authorizer-schema-for-authorizer-type-custom/13171/5 "2020-12-08T11:25:04Z")

</div>

@bfieber thanks for the reply! As far as I can understand those types go for the actual authorizer, where the config I mentioned is where you reference an authorizer to be used for a specific Method. See the link in the bottom of my post.

@jayceesnow Unfortunately I didn’t find a way passed this (other than turning of all validation using configValidationMode: error). Thanks anyway for confirming that I’m not the only one struggling with this. I guess the right way forward would be to make an issue / a PR in the serverless repo.

---

<div class="post-metadata">

**Author:** ![bfieber](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/bfieber/32/653_2.png) [@bfieber](https://forum.serverless.com/u/bfieber)\
**Post date:** [December 8, 2020, 3:42pm UTC](https://forum.serverless.com/t/bug-in-api-gateway-authorizer-schema-for-authorizer-type-custom/13171/6 "2020-12-08T15:42:50Z")

</div>

Looks like a potential bug in the SLS code.  
In [v2.5.0 and below](https://github.com/serverless/serverless/blob/v2.5.0/lib/plugins/aws/package/compile/events/apiGateway/index.js), it would pass the CUSTOM type along silently and AWS CFn would allow it.

[As of v2.6.0](https://github.com/serverless/serverless/blob/v2.6.0/lib/plugins/aws/package/compile/events/apiGateway/index.js) they added JSON-Schema validation of the type that doesn’t include `CUSTOM` as a valid option.

But looking at the docs you linked and the fact that it’s just a warning, it seems to be an incorrect warning.  
Does the service still deploy event with the warning?

---

<div class="post-metadata">

**Author:** ![jayceesnow](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/jayceesnow/32/4837_2.png) [@jayceesnow](https://forum.serverless.com/u/jayceesnow)\
**Post date:** [December 8, 2020, 4:56pm UTC](https://forum.serverless.com/t/bug-in-api-gateway-authorizer-schema-for-authorizer-type-custom/13171/7 "2020-12-08T16:56:25Z")

</div>

@bfieber yes, the service is deployed even with the warnging.
