You must be logged in to view saved presets
This template sets up an API Gateway with a REST API, deploys it to development and production stages, and configures a usage plan with quota and throttle settings.
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_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" "development" {
deployment_id = aws_api_gateway_deployment.example.id
rest_api_id = aws_api_gateway_rest_api.example.id
stage_name = "development"
}
resource "aws_api_gateway_stage" "production" {
deployment_id = aws_api_gateway_deployment.example.id
rest_api_id = aws_api_gateway_rest_api.example.id
stage_name = "production"
}
resource "aws_api_gateway_usage_plan" "example" {
api_stages {
api_id = aws_api_gateway_rest_api.example.id
stage = aws_api_gateway_stage.development.stage_name
}
api_stages {
api_id = aws_api_gateway_rest_api.example.id
stage = aws_api_gateway_stage.production.stage_name
}
description = "my description"
name = "my-usage-plan"
product_code = "MYCODE"
quota_settings {
limit = 20
offset = 2
period = "WEEK"
}
throttle_settings {
burst_limit = 5
rate_limit = 10
}
}