This template configures an AWS API Gateway with an authorizer using Cognito User Pools.

Terraform Template

data "aws_api_gateway_rest_api" "selected" {
  name = "var.api_gateway_name"
}

data "aws_cognito_user_pools" "selected" {
  name = "var.cognito_user_pool_name"
}

resource "aws_api_gateway_authorizer" "cognito" {
  name = "cognito"
  provider_arns = data.aws_cognito_user_pools.selected.arns
  rest_api_id = data.aws_api_gateway_rest_api.selected.id
  type = "COGNITO_USER_POOLS"
  provider = ""
}