Terraform scenarios to create AWS Lambda with API Gateway due to 'Invalid Authorizer' scenarios
I'm trying to set up an AWS Lambda function with an API Gateway using Terraform, but I'm working with an 'Invalid Authorizer' behavior when I attempt to invoke the API. My Lambda function is set up correctly, but the integration with the API Gateway seems to be misconfigured. Here's the relevant part of my Terraform code: ```hcl resource "aws_lambda_function" "my_lambda" { function_name = "myLambdaFunction" runtime = "nodejs14.x" handler = "index.handler" role = aws_iam_role.my_lambda_role.arn source_code_hash = filebase64sha256("function.zip") } resource "aws_api_gateway_rest_api" "my_api" { name = "MyAPI" } resource "aws_api_gateway_resource" "my_resource" { rest_api_id = aws_api_gateway_rest_api.my_api.id parent_id = aws_api_gateway_rest_api.my_api.root_resource_id path_part = "myresource" } resource "aws_api_gateway_method" "my_method" { rest_api_id = aws_api_gateway_rest_api.my_api.id resource_id = aws_api_gateway_resource.my_resource.id http_method = "GET" authorization = "AWS_IAM" } resource "aws_api_gateway_authorizer" "my_authorizer" { name = "MyAuthorizer" rest_api_id = aws_api_gateway_rest_api.my_api.id authorizer_uri = aws_lambda_function.my_lambda.invoke_arn authorizer_type = "REQUEST" } ``` I have confirmed that the Lambda function role has the necessary permissions and that the `invoke_arn` is correctly referencing the Lambda function. However, when I test the API Gateway endpoint, I receive the following behavior message: ``` Invalid Authorizer: Authorizer with name 'MyAuthorizer' is not valid. ``` I've also tried removing the authorizer configuration and testing the API without it, and that works fine. I suspect the scenario may be related to the way I'm referencing the Lambda function in the `aws_api_gateway_authorizer` resource. Any insights on how to properly set this up? I'm using Terraform version 1.0.0 and the AWS provider version 3.50.0.