Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom API Gateway Authorizer using terraform

Am trying to deploy a API Gateway REST API which uses a custom authorizer using terraform.

The custom authorizer uses an existing lambda function.

resource "aws_api_gateway_authorizer" "accountprofileauth" {
  name                   = "auth"
  rest_api_id            = "${aws_api_gateway_rest_api.accountprofileapi.id}"
  authorizer_uri         = "arn:aws:lambda:us-east-2:XXXX:function:dev-authorizer"
  identity_source        = "method.request.header.Authorization"
  type                   = "REQUEST"
}

When i did terraform apply, i got the below error

* aws_api_gateway_authorizer.accountprofileauth: Error creating API Gateway Authorizer: BadRequestException: Invalid Authorizer URI: arn:aws:lambda:us-east-2:XXXX:function:dev-authorizer. Authorizer URI should be a valid API Gateway ARN that represents a Lambda function invocation.
    status code: 400, request id: XXXX

The lambda function exists and it works fine. The same arn works fine when i deploy using serverless.

Do you know the format/provide an example of valid arn?

Thanks.

like image 679
vasu Avatar asked Jul 17 '18 15:07

vasu


People also ask

Which types of custom authorizers are supported by API gateway?

There are two types of Lambda authorizers: A token-based Lambda authorizer (also called a TOKEN authorizer) receives the caller's identity in a bearer token, such as a JSON Web Token (JWT) or an OAuth token.


1 Answers

I found the actual format to be

arn:aws:apigateway:us-east-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-2:XXXX:function:dev-authorizer/invocations

Looks like the date is kinda hard coded. I was confused by that :)

like image 185
vasu Avatar answered Sep 28 '22 09:09

vasu