Skip to content

Instantly share code, notes, and snippets.

@paulgear
Created January 20, 2022 03:36
Show Gist options
  • Save paulgear/7bce944430fe48011a3e3aa598915bfe to your computer and use it in GitHub Desktop.
Save paulgear/7bce944430fe48011a3e3aa598915bfe to your computer and use it in GitHub Desktop.
Example for aws_api_gateway_rest_api bug
data "aws_iam_policy_document" "lambda_authorizer_assume_role" {
statement {
actions = ["sts:AssumeRole"]
effect = "Allow"
principals {
type = "Service"
identifiers = [
"apigateway.amazonaws.com",
"lambda.amazonaws.com",
]
}
}
}
resource "aws_iam_role" "api_gateway" {
assume_role_policy = data.aws_iam_policy_document.lambda_authorizer_assume_role.json
description = "Allow API Gateway to call lambda authorizer"
managed_policy_arns = ["arn:aws:iam::aws:policy/service-role/AWSLambdaRole"]
name = "lambda-auth0-authorizer"
}
resource "aws_api_gateway_rest_api" "this" {
name = "this-api-gateway"
endpoint_configuration {
types = ["REGIONAL"]
}
body = file("${path.module}/api.json")
disable_execute_api_endpoint = true
policy = file("${path.module}/default_policy.json")
}
resource "aws_api_gateway_deployment" "this" {
rest_api_id = aws_api_gateway_rest_api.this.id
triggers = {
body_checksum = sha256(aws_api_gateway_rest_api.this.body)
}
lifecycle {
create_before_destroy = true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment