AWS API Gateway V2 Authorizer

This page shows how to write Terraform and CloudFormation for API Gateway V2 Authorizer and write them securely.

aws_apigatewayv2_authorizer (Terraform)

The Authorizer in API Gateway V2 can be configured in Terraform with the resource name aws_apigatewayv2_authorizer. The following sections describe 3 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L2
resource "aws_apigatewayv2_authorizer" "jwt_authorizer" {
  api_id           = var.api_gateway_id
  name             = var.authorizer_name
  identity_sources = [var.jwt_token_source]
  authorizer_type  = "JWT"

main.tf#L1
resource "aws_apigatewayv2_authorizer" "this" {
  api_id           = var.api_id
  authorizer_type  = var.authorizer_type
  identity_sources = var.identity_sources
  name             = var.name

main.tf#L7
resource "aws_apigatewayv2_authorizer" "this" {
  api_id                     = var.api_id
  authorizer_credentials_arn = var.authorizer_credentials_arn
  authorizer_type            = var.authorizer_type
  authorizer_uri             = var.authorizer_uri
  identity_sources           = var.identity_sources

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages an Amazon API Gateway Version 2 authorizer. More information can be found in the Amazon API Gateway Developer Guide.

AWS::ApiGatewayV2::Authorizer (CloudFormation)

The Authorizer in ApiGatewayV2 can be configured in CloudFormation with the resource name AWS::ApiGatewayV2::Authorizer. The following sections describe 1 example of how to use the resource and its parameters.

Example Usage from GitHub

AWS_ApiGatewayV2_AuthorizerResource.schema.json#L15
      "default" : "AWS::ApiGatewayV2::Authorizer"
    },
    "Properties" : {
      "$ref" : "AWS_ApiGatewayV2_Authorizer.schema.json"
    }
  }

Parameters

Explanation in CloudFormation Registry

The AWS::ApiGatewayV2::Authorizer resource creates an authorizer for a WebSocket API or an HTTP API. To learn more, see Controlling and managing access to a WebSocket API in API Gateway and Controlling and managing access to an HTTP API in API Gateway in the API Gateway Developer Guide.

Frequently asked questions

What is AWS API Gateway V2 Authorizer?

AWS API Gateway V2 Authorizer is a resource for API Gateway V2 of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS API Gateway V2 Authorizer?

For Terraform, the vladcar/terraform-aws-http-api-gatewayV2-jwt-authorizer, danwiltshire/violet and niveklabs/aws source code examples are useful. See the Terraform Example section for further details.

For CloudFormation, the shiver-me-timbers/smt-cloudformation-parent source code example is useful. See the CloudFormation Example section for further details.