- Newest
- Most votes
- Most comments
I understand your frustration with AWS integrations. These challenges are common when working with API Gateway, Lambda, and Cognito integrations.
For API Gateway and Lambda integration issues:
- 404 errors often indicate route configuration problems. Your local route (e.g., /api/Supplier/GetTotal) needs to match exactly what's configured in API Gateway.
- After making changes to API Gateway, you need to deploy the API for changes to take effect.
- Lambda permissions are critical - API Gateway needs explicit permission to invoke your Lambda functions. This is often missed when setting up integrations through CloudFormation or OpenAPI specifications.
For Cognito integration issues:
- OAuth Scopes configuration can cause 4xx errors if misconfigured. Leave it blank for identity token authorization or configure it properly for access token authorization.
- 401 Unauthorized errors are common with Cognito integrations and often require specific troubleshooting.
- Pre-token generation Lambda triggers can cause HTTP 500 errors if they fail.
For debugging:
- Enable CloudWatch logging for your API Gateway to see detailed error information.
- Check for integration error messages by adding appropriate logging variables.
- Sometimes toggling between proxy/non-proxy integration settings can resolve issues.
While these services can be challenging to integrate, they do work reliably once properly configured. The initial setup complexity is the trade-off for the scalability and managed service benefits that AWS provides beyond EC2.
Sources
AWS Gateway: API does not respond in Postman | AWS re:Post
Api Gateway is not sending Cognito data to Lambda | AWS re:Post
Creating api gateway api from openapi specification with lambda integration does not create triggers | AWS re:Post
Troubleshooting issues with HTTP API Lambda integrations - Amazon API Gateway
Create and troubleshoot Cognito and API Gateway integrations | AWS re:Post
answered a year ago
Not to mention that the documentation is 50% headers with wordy but utterly useless content.
answered a year ago
hey there! sorry that you are having issues, let me help you with those by using AWS CloudFormation - an AWS service for Infrastructure as Code (IaC) where you can define your needed resources and deploy them easily without going through the Management Console.
here is the CF template which your can use to create an API Gateway with implemented Cognito Authorizer and one Lambda which is protected by the mentioned authorizer:
AWSTemplateFormatVersion: '2010-09-09' Transform: 'AWS::Serverless-2016-10-31' Description: > Example of CloudFormation Template Parameters: UserPoolArn: Type: String Description: User Pool ARN from the Auth stack Resources: RestApi: Type: AWS::Serverless::Api Properties: StageName: Prod Auth: DefaultAuthorizer: CognitoAuthorizer Authorizers: CognitoAuthorizer: UserPoolArn: !Ref UserPoolArn Identity: Header: Authorization AddDefaultAuthorizerToCorsPreflight: false Cors: AllowMethods: "'*'" AllowHeaders: "'*'" AllowOrigin: "'*'" # Lambda Functions YourLambda: Type: AWS::Serverless::Function Properties: Runtime: python3.12 Handler: lambda_handler.lambda_handler CodeUri: ./ Policies: - AWSLambdaBasicExecutionRole Events: GetEvents: Type: Api Properties: RestApiId: !Ref RestApi Path: /your-needed-route Method: get
for deploying this template, you will need AWS Serverless Application Model - https://aws.amazon.com/serverless/sam/. take a look into the documentation, i had no issues using it and learning it when i installed it for the first time. if you are interested in seeing how to define other resources inside the same template, i've created a project with multiple Lambdas covered by API Gateway + Cognito Authorizer and multiple other services like DynamoDB, CloudFront and S3 - https://github.com/mate329/eventspark/blob/master/aws/EventsStack/template.yaml.
let me know if you have any other questions and if i can help you in any other way :)
answered a year ago
Relevant content
asked 2 years ago
asked 3 years ago
asked 2 years ago
asked a year ago

Ok, but the docs don't match the options. For example, in this link https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-enable-cognito-user-pool.html it states:
...but no such "Authorization Scopes" field exists.