Skip to content

Commit

Permalink
i162 - cleanup resource
Browse files Browse the repository at this point in the history
  • Loading branch information
tungbq committed Jul 1, 2023
1 parent 4649782 commit bd9b6ab
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions tutorial/serverless-basic-application/api-gateway.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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

0 comments on commit bd9b6ab

Please sign in to comment.