File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 11locals {
22 stages = var. stages
3+ endpoint_type = var. endpoint_type
4+ enable_metrics = var. enable_metrics
35}
46
57resource "aws_api_gateway_rest_api" "api" {
68 for_each = toset (local. stages )
79 name = " ${ module . this . id } -${ each . key } "
10+
11+ endpoint_configuration {
12+ types = [
13+ local . endpoint_type
14+ ]
15+ }
816
917 tags = module. this . tags
1018}
@@ -44,10 +52,22 @@ resource "aws_api_gateway_stage" "stage" {
4452 stage_name = each. key
4553 rest_api_id = aws_api_gateway_rest_api. api [each . key ]. id
4654 deployment_id = aws_api_gateway_deployment. placeholder [each . key ]. id
47-
55+
4856 tags = module. this . tags
4957}
5058
59+
60+ resource "aws_api_gateway_method_settings" "settings" {
61+ for_each = toset (local. stages )
62+ rest_api_id = aws_api_gateway_rest_api. api [each . key ]. id
63+ stage_name = aws_api_gateway_stage. stage [each . key ]. stage_name
64+ method_path = " */*"
65+
66+ settings {
67+ metrics_enabled = local. enable_metrics
68+ }
69+ }
70+
5171resource "aws_api_gateway_api_key" "default" {
5272 for_each = toset (local. stages )
5373 name = join (" -" , [
Original file line number Diff line number Diff line change @@ -8,4 +8,16 @@ variable "ssm_prefix" {
88 type = string
99 description = " SSM parameter prefix for storing API resource references"
1010 default = null
11+ }
12+
13+ variable "endpoint_type" {
14+ type = string
15+ description = " API Gateway endpoint type (e.g., 'REGIONAL', 'EDGE', 'PRIVATE')"
16+ default = " REGIONAL"
17+ }
18+
19+ variable "enable_metrics" {
20+ type = bool
21+ description = " Enable API Gateway metrics"
22+ default = true
1123}
You can’t perform that action at this time.
0 commit comments