Skip to content

Commit c956521

Browse files
committed
pr feedback: best practice for stage / stage deployment in api gateway
1 parent a19f9c8 commit c956521

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

aws/terraform/modules/metaflow/modules/metadata-service/api-gateway.tf

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ resource "aws_api_gateway_method_response" "db" {
134134

135135
resource "aws_api_gateway_deployment" "this" {
136136
rest_api_id = aws_api_gateway_rest_api.this.id
137-
stage_name = local.api_gateway_stage_name
137+
138138
# explicit depends_on required to ensure module stands up on first `apply`
139139
# otherwise a second followup `apply` would be required
140140
# can read more here: https://stackoverflow.com/a/42783769
@@ -146,9 +146,19 @@ resource "aws_api_gateway_deployment" "this" {
146146
}
147147
}
148148

149+
resource "aws_api_gateway_stage" "this" {
150+
deployment_id = aws_api_gateway_deployment.this.id
151+
rest_api_id = aws_api_gateway_rest_api.this.id
152+
stage_name = local.api_gateway_stage_name
153+
154+
tags = var.standard_tags
155+
}
156+
149157
resource "aws_api_gateway_api_key" "this" {
150158
count = var.api_basic_auth ? 1 : 0
151159
name = local.api_gateway_key_name
160+
161+
tags = var.standard_tags
152162
}
153163

154164
resource "aws_api_gateway_usage_plan" "this" {
@@ -157,8 +167,10 @@ resource "aws_api_gateway_usage_plan" "this" {
157167

158168
api_stages {
159169
api_id = aws_api_gateway_rest_api.this.id
160-
stage = local.api_gateway_stage_name
170+
stage = aws_api_gateway_deployment.this.stage_name
161171
}
172+
173+
tags = var.standard_tags
162174
}
163175

164176
resource "aws_api_gateway_usage_plan_key" "this" {

0 commit comments

Comments
 (0)