- Newest
- Most votes
- Most comments
The issue you're experiencing is a common one when creating API Gateway APIs with Lambda integrations using OpenAPI specifications and CloudFormation. While your approach of using Fn::Transform to include the OpenAPI specification from an S3 bucket is correct, it doesn't automatically create the necessary permissions for API Gateway to invoke the Lambda functions.
To resolve this, you need to explicitly grant API Gateway permission to invoke your Lambda functions. This is typically done by adding resource-based policies to your Lambda functions. In your CloudFormation template, you can achieve this by adding AWS::Lambda::Permission resources for each Lambda function that your API Gateway needs to invoke.
Here's an example of how you might add this permission in your CloudFormation template:
LambdaPermission: Type: AWS::Lambda::Permission Properties: FunctionName: !Ref YourLambdaFunction Action: lambda:InvokeFunction Principal: apigateway.amazonaws.com SourceArn: !Sub "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${api}/*/*/*"
In this example, 'YourLambdaFunction' should be replaced with the logical ID of your Lambda function resource in the CloudFormation template, and 'api' should be the logical ID of your API Gateway resource.
You'll need to add a similar permission for each Lambda function that your API Gateway needs to invoke. This explicitly grants API Gateway the necessary permissions to trigger your Lambda functions, which is why manually saving the integration in the console (which automatically adds these permissions) resolves the issue.
By adding these permissions in your CloudFormation template, you ensure that the API Gateway triggers are properly set up for your Lambda functions when you deploy your stack, without needing manual intervention in the console.
Remember to test your updated template thoroughly to ensure all integrations are working as expected after deployment.
Sources
Troubleshooting issues with HTTP API Lambda integrations - Amazon API Gateway
Invoking a Lambda function using an Amazon API Gateway endpoint - AWS Lambda
Lambda integrations for REST APIs in API Gateway - Amazon API Gateway

I need to refine the permissions a bit, but the triggers are created now. So that is one step forward.