Skip to content

Commit db4b303

Browse files
authored
feat: make endpoint type and metrics configurable
* feat: make endpoint type configurable, default REGIONAL * feat: add configuration for enabling metrics
1 parent ccd839f commit db4b303

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

main.tf

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
locals {
22
stages = var.stages
3+
endpoint_type = var.endpoint_type
4+
enable_metrics = var.enable_metrics
35
}
46

57
resource "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+
5171
resource "aws_api_gateway_api_key" "default" {
5272
for_each = toset(local.stages)
5373
name = join("-", [

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)