Skip to content

Commit 3645a42

Browse files
committed
Added lambda permission for each http method
1 parent cf168b3 commit 3645a42

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

api_gateway.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ resource "aws_api_gateway_integration" "integration" {
2727
}
2828

2929
resource "aws_lambda_permission" "apigw_lambda" {
30-
statement_id = "AllowLambdaExecutionForAPIGateway-${var.api_name}"
30+
count = length(var.http_methods)
31+
statement_id = "AllowLambdaExecutionForAPIGateway-${var.api_name}-${var.http_methods[count.index]}"
3132
action = "lambda:InvokeFunction"
3233
function_name = aws_lambda_function.lambda.function_name
3334
principal = "apigateway.amazonaws.com"
3435

35-
source_arn = "arn:aws:execute-api:${var.region}:${local.account_id}:${aws_api_gateway_rest_api.api.id}/*/*"
36+
source_arn = "arn:aws:execute-api:${var.region}:${local.account_id}:${aws_api_gateway_rest_api.api.id}/*/${aws_api_gateway_method.method[count.index].http_method}${aws_api_gateway_resource.resource.path}"
3637
}
3738

3839
resource "aws_api_gateway_deployment" "deployment" {

0 commit comments

Comments
 (0)