Errors when integrating with API GW
royassis opened this issue · 2 comments
Description
This Terraform project contains terraform-aws-modules/lambda/aws modules and resources of a Private Rest API Gateway.
After applying using Terraform Cloud, the API-GW endpoints return:
{
"message": "Internal server error"
}
This happens only when I change the code in the source_path of the module.
And it affects only the current deployment of the apigw stage. When running the lambda from the test console of API Gateway it works, so does testing the lambda from the lambda console.
Creating a new deployment fixes it.
When looking at the previous lambda version the Resource-based policy statements looks ok.
- [ x]
✋ I have searched the open/closed issues and my issue is not listed.
⚠️ Note
Before you submit an issue, please perform the following first:
- Remove the local
.terraform
directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!):rm -rf .terraform/
- Re-initialize the project root to pull down modules:
terraform init
- Re-attempt your terraform plan or apply and check if the issue still persists
Versions
- Module version [Required]:
4.7.2 - Terraform version:
1.3.7 - Provider version(s):
Terraform v1.3.4
on windows_386
- provider registry.terraform.io/hashicorp/aws v4.30.0
- provider registry.terraform.io/hashicorp/external v2.2.3
- provider registry.terraform.io/hashicorp/local v2.3.0
- provider registry.terraform.io/hashicorp/null v3.2.1
Your version of Terraform is out of date! The latest version
is 1.3.7. You can update by downloading from https://www.terraform.io/downloads.html
Reproduction Code [Required]
Steps to reproduce the behavior:
locals {
source_arn = "arn:aws:execute-api:<region>:<accountid>:<restapiid>/*/*/*"
}
locals {
allowed_triggers = {
APIGatewayAny = {
service = "apigateway"
source_arn = local.source_arn
}
}
}
module "lambda_function_GetApigwResources" {
source = "terraform-aws-modules/lambda/aws"
function_name = "GetApigwResources"
handler = "app.handler"
runtime = "python3.9"
timeout = 10
store_on_s3 = true
s3_bucket = <bucketname>
s3_prefix = "lambda-builds/"
attach_policy_statements = true
policy_statements = {
apigateway = {
effect = "Allow",
actions = ["apigateway:Get*"],
resources = ["*"]
}
}
role_path = "/tf-managed/"
policy_path = "/tf-managed/"
source_path = "../src/lambda_code/describe_apigw_resources/app.py"
tags = {
"map-migrated" = var.map-migrated
}
# create_current_version_allowed_triggers = true
publish = true
allowed_triggers = local.allowed_triggers
}
Expected behavior
API GW returns a valid response.
Actual behavior
API GW return s
{
"message": "Internal server error"
}
Terminal Output Screenshot(s)
Additional context
The error is not related to the module itself. Please check logs in CloudWatch or in the Lambda console.
I'm going to lock this issue because it has been closed for 30 days