Skip to content

New pattern submission - Cognito-Appsync-Bedrock #2741

Open
@proton0210

Description

@proton0210

This sample pattern demonstrates how to build a secure, generative AI-powered GraphQL API. It shows how to authenticate users with Amazon Cognito, use AWS AppSync to define the GraphQL interface, and then process requests by invoking an Amazon Bedrock foundation model via an AWS Lambda resolver.

The core of this pattern allows authenticated users to send a prompt through an AppSync mutation. This mutation triggers a Node.js AWS Lambda function, which acts as the resolver. The Lambda function, utilizing the AWS SDK for JavaScript (v3), then sends the prompt to a configured Amazon Bedrock model (defaulting to Anthropic Claude 3 Sonnet). The model's response is then relayed back through AppSync to the end-user. Key aspects include secure authentication, scalable GraphQL endpoint, and direct integration with powerful generative AI models.

This pattern deploys an Amazon Cognito User Pool and User Pool Client, an AWS AppSync GraphQL API, an AWS Lambda function (Node.js 20.x runtime), and the necessary IAM roles and permissions for these services to interact securely. The entire infrastructure is provisioned using the AWS Cloud Development Kit (CDK).

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

GitHub PR for template: 2740

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions