Skip to content

Commit ccd839f

Browse files
authored
refactor: create placeholder stages
1 parent cc4def5 commit ccd839f

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

main.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,31 @@ resource "aws_api_gateway_rest_api" "api" {
99
tags = module.this.tags
1010
}
1111

12+
resource "aws_api_gateway_method" "placeholder" {
13+
for_each = toset(local.stages)
14+
rest_api_id = aws_api_gateway_rest_api.api[each.key].id
15+
resource_id = aws_api_gateway_rest_api.api[each.key].root_resource_id
16+
http_method = "GET"
17+
authorization = "NONE"
18+
}
19+
20+
resource "aws_api_gateway_integration" "placeholder" {
21+
for_each = toset(local.stages)
22+
rest_api_id = aws_api_gateway_rest_api.api[each.key].id
23+
resource_id = aws_api_gateway_rest_api.api[each.key].root_resource_id
24+
http_method = aws_api_gateway_method.placeholder[each.key].http_method
25+
type = "MOCK"
26+
}
27+
1228
resource "aws_api_gateway_deployment" "placeholder" {
1329
for_each = toset(local.stages)
1430
rest_api_id = aws_api_gateway_rest_api.api[each.key].id
1531

32+
depends_on = [
33+
aws_api_gateway_method.placeholder,
34+
aws_api_gateway_integration.placeholder
35+
]
36+
1637
lifecycle {
1738
create_before_destroy = true
1839
}
@@ -49,6 +70,8 @@ resource "aws_api_gateway_usage_plan" "default" {
4970
}
5071
}
5172

73+
depends_on = [aws_api_gateway_stage.stage]
74+
5275
tags = module.this.tags
5376
}
5477

ssm.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
locals {
2-
ssm_prefix = "/${module.this.namespace}/${module.this.name}"
2+
ssm_prefix = var.ssm_prefix != null ? var.ssm_prefix : "/${module.this.namespace}/${module.this.name}"
33
}
44

55
resource "aws_ssm_parameter" "rest_api_id" {

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@ variable "stages" {
22
type = list(string)
33
description = "List of API stages to create"
44
default = ["staging", "prod"]
5+
}
6+
7+
variable "ssm_prefix" {
8+
type = string
9+
description = "SSM parameter prefix for storing API resource references"
10+
default = null
511
}

0 commit comments

Comments
 (0)