This is how I do it.
Explore the docs »
Report Bug
.
Request Feature
This Terraform module creates an AWS API Gateway REST API with comprehensive configuration options including CloudWatch logging, custom domains, method settings, and OpenAPI specification support.
This module uses the REST API Gateway (v1) instead of HTTP API Gateway because it offers greater flexibility, security features like WAF integration, and advanced customization options. While slightly more expensive, REST API Gateway provides the production-grade controls needed for modern APIs.
module "api_gateway" {
source = "bendoerr-terraform-modules/api-gateway/aws"
context = module.context
name = "example-api"
description = "Example API Gateway"
# OpenAPI specification
openapi_config = jsonencode({
openapi = "3.0.1"
info = {
title = "Example API"
version = "1.0"
}
# ... rest of OpenAPI spec ...
})
# API Gateway configuration
stage_name = "v1"
stage_description = "Version 1"
# Enable access logs with CloudWatch
access_log_enabled = true
log_retention_days = 14
# Method settings - single path approach (legacy)
method_settings_enabled = true
logging_level = "INFO"
metrics_enabled = true
# OR
# Method settings - multiple paths approach (recommended)
method_settings = {
"*/*" = {
logging_level = "INFO"
metrics_enabled = true
}
"api/v1/users/GET" = {
logging_level = "ERROR"
throttling_rate_limit = 100
}
}
}
Name | Version |
---|---|
terraform | >= 1.0.0 |
aws | ~> 5.0 |
Name | Version |
---|---|
aws | 5.64.0 |
Name | Source | Version |
---|---|---|
label | bendoerr-terraform-modules/label/null | 0.4.2 |
Name | Type |
---|---|
aws_caller_identity.this | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
context | Shared context from the 'bendoerr-terraform-modules/terraform-null-context' module. | object({ |
n/a | yes |
name | A descriptive but short name used for labels by the 'bendoerr-terraform-modules/terraform-null-label' module. | string |
"thing" |
no |
Name | Description |
---|---|
caller_identity | This can be removed if it is not needed |
id | The normalized ID from the 'bendoerr-terraform-modules/terraform-null-label' module. |
name | The provided name given to the module. |
tags | The normalized tags from the 'bendoerr-terraform-modules/terraform-null-label' module. |
See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- If you have suggestions for adding or removing projects, feel free to open an issue to discuss it, or directly create a pull request after you edit the README.md file with necessary changes.
- Please make sure you check your spelling and grammar.
- Create individual PR for each suggestion.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
- Benjamin R. Doerr - Terraformer - Benjamin R. Doerr - Built Ben's Terraform Modules
Only the latest tagged version is supported.
See SECURITY.md.