You must be logged in to view saved presets
Configures a complete API Gateway setup including REST API, deployment, stage, and method settings for logging and metrics.
resource "aws_api_gateway_deployment" "example" {
lifecycle {
create_before_destroy = true
}
rest_api_id = aws_api_gateway_rest_api.example.id
triggers = {
redeployment = sha1(jsonencode(aws_api_gateway_rest_api.example.body))
}
}
resource "aws_api_gateway_method_settings" "all" {
method_path = "*/*"
rest_api_id = aws_api_gateway_rest_api.example.id
settings {
logging_level = "ERROR"
metrics_enabled = true
}
stage_name = aws_api_gateway_stage.example.stage_name
}
resource "aws_api_gateway_method_settings" "path_specific" {
method_path = "path1/GET"
rest_api_id = aws_api_gateway_rest_api.example.id
settings {
logging_level = "INFO"
metrics_enabled = true
}
stage_name = aws_api_gateway_stage.example.stage_name
}
resource "aws_api_gateway_rest_api" "example" {
body = jsonencode({
openapi = "3.0.1"
info = {
title = "example"
version = "1.0"
}
paths = {
"/path1" = {
get = {
x-amazon-apigateway-integration = {
httpMethod = "GET"
payloadFormatVersion = "1.0"
type = "HTTP_PROXY"
uri = "https://ip-ranges.amazonaws.com/ip-ranges.json"
}
}
}
}
})
name = "example"
}
resource "aws_api_gateway_stage" "example" {
deployment_id = aws_api_gateway_deployment.example.id
rest_api_id = aws_api_gateway_rest_api.example.id
stage_name = "example"
}