Skip to content

bendoerr-terraform-modules/terraform-aws-apigateway

Repository files navigation


Logo

Ben's Terraform Module Template Repo

This is how I do it.

Explore the docs »

Report Bug . Request Feature

GitHub contributors GitHub issues GitHub pull requests GitHub workflow: Terratest GitHub workflow: Linting GitHub tag (with filter) OSSF-Scorecard Score GitHub License

About The Project

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.

Why REST API Gateway (v1) Instead of HTTP API Gateway?

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.

Usage

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
    }
  }
}

Requirements

Name Version
terraform >= 1.0.0
aws ~> 5.0

Providers

Name Version
aws 5.64.0

Modules

Name Source Version
label bendoerr-terraform-modules/label/null 0.4.2

Resources

Name Type
aws_caller_identity.this data source

Inputs

Name Description Type Default Required
context Shared context from the 'bendoerr-terraform-modules/terraform-null-context' module.
object({
attributes = list(string)
dns_namespace = string
environment = string
instance = string
instance_short = string
namespace = string
region = string
region_short = string
role = string
role_short = string
project = string
tags = map(string)
})
n/a yes
name A descriptive but short name used for labels by the 'bendoerr-terraform-modules/terraform-null-label' module. string "thing" no

Outputs

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.

Roadmap

GitHub issues

See the open issues for a list of proposed features (and known issues).

Contributing

GitHub pull requests

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.

Creating A Pull Request

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

GitHub License

Distributed under the MIT License. See LICENSE for more information.

Authors

GitHub contributors

  • Benjamin R. Doerr - Terraformer - Benjamin R. Doerr - Built Ben's Terraform Modules

Supported Versions

Only the latest tagged version is supported.

Reporting a Vulnerability

See SECURITY.md.

Acknowledgements

About

Ben's Terraform AWS API Gateway Module

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •