Skip to content

Instantly share code, notes, and snippets.

@jkentjnr
Created April 21, 2022 13:16
Show Gist options
  • Save jkentjnr/38b272f0f2d3ddffce9bae7a560c5e0d to your computer and use it in GitHub Desktop.
Save jkentjnr/38b272f0f2d3ddffce9bae7a560c5e0d to your computer and use it in GitHub Desktop.
resource "aws_api_gateway_method" "graphRoot" {
rest_api_id = aws_api_gateway_rest_api.api.id
resource_id = aws_api_gateway_resource.graphRoot.id
http_method = "POST"
authorization = "COGNITO_USER_POOLS"
authorizer_id = aws_api_gateway_authorizer.cognito.id
}
resource "aws_api_gateway_integration" "graphRoot" {
rest_api_id = aws_api_gateway_rest_api.api.id
resource_id = aws_api_gateway_method.graphRoot.resource_id
http_method = aws_api_gateway_method.graphRoot.http_method
integration_http_method = "POST"
type = "HTTP"
uri = aws_appsync_graphql_api.graph.uris["GRAPHQL"]
# Transforms the incoming XML request to JSON
request_templates = {
"application/json" = <<EOF
#set($transformAuthRegEx = 'Bearer ')
#set($transformAuth = "$input.params('Authorization')")
#set($context.requestOverride.header.Authorization = $transformAuth.replaceAll($transformAuthRegEx, ""))
$input.body
EOF
}
}
resource "aws_api_gateway_method_response" "graphRoot_response_200" {
rest_api_id = aws_api_gateway_rest_api.api.id
resource_id = aws_api_gateway_resource.graphRoot.id
http_method = aws_api_gateway_method.graphRoot.http_method
status_code = "200"
}
resource "aws_api_gateway_integration_response" "graphRoot_response_200" {
rest_api_id = aws_api_gateway_rest_api.api.id
resource_id = aws_api_gateway_resource.graphRoot.id
http_method = aws_api_gateway_method.graphRoot.http_method
status_code = aws_api_gateway_method_response.graphRoot_response_200.status_code
depends_on = [
aws_api_gateway_method_response.graphRoot_response_200
]
response_templates = {
"application/json" = <<EOF
$input.body
EOF
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment