From bd9b6ab4f2a042d73d26bbffac1742de55d086ec Mon Sep 17 00:00:00 2001 From: Tung Bui Date: Sat, 1 Jul 2023 13:33:15 +0700 Subject: [PATCH] i162 - cleanup resource --- .../api-gateway.tf | 34 +++++++------------ 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/tutorial/serverless-basic-application/api-gateway.tf b/tutorial/serverless-basic-application/api-gateway.tf index 6a443b6..e0e3514 100644 --- a/tutorial/serverless-basic-application/api-gateway.tf +++ b/tutorial/serverless-basic-application/api-gateway.tf @@ -1,20 +1,10 @@ -# Flow: New API -> Resource -> Method -> Interation -> Deployment +# Flow: +# New API -> Resource -> Method -> Interation -> Deployment resource "aws_api_gateway_rest_api" "lambda" { name = "serverless_lambda_gw" } -# Stage -resource "aws_api_gateway_stage" "lambda" { - rest_api_id = aws_api_gateway_rest_api.lambda.id - deployment_id = aws_api_gateway_deployment.example.id - - stage_name = "serverless_lambda_stage" - - # Temporarity disable logging. TODO: work on it later - # access_log_settings { ... } -} - # Resource resource "aws_api_gateway_resource" "resource" { path_part = "resource" @@ -45,7 +35,6 @@ resource "aws_api_gateway_deployment" "example" { rest_api_id = aws_api_gateway_rest_api.lambda.id triggers = { - # redeployment = sha1(jsonencode(aws_api_gateway_rest_api.lambda.body)) redeployment = sha1(jsonencode([ aws_api_gateway_resource.resource.id, aws_api_gateway_method.method.id, @@ -58,14 +47,15 @@ resource "aws_api_gateway_deployment" "example" { } } -# Logging -# Temporarity disable logging. TODO: work on it later - -resource "aws_lambda_permission" "api_gw" { - statement_id = "AllowExecutionFromAPIGateway" - action = "lambda:InvokeFunction" - function_name = aws_lambda_function.hello_world.function_name - principal = "apigateway.amazonaws.com" +# Stage +resource "aws_api_gateway_stage" "lambda" { + rest_api_id = aws_api_gateway_rest_api.lambda.id + deployment_id = aws_api_gateway_deployment.example.id + stage_name = "serverless_lambda_stage" - source_arn = "${aws_api_gateway_rest_api.lambda.execution_arn}/*/*" + # Temporarity disable logging. TODO: work on it later + # access_log_settings { ... } } + +# Logging +# Temporarity disable logging. TODO: work on it later