Giter VIP home page Giter VIP logo

aws-samples / aws-amplify-stepfunctions-example Goto Github PK

View Code? Open in Web Editor NEW
17.0 4.0 2.0 3.75 MB

Learn how to extend AWS Amplify resources with CDK v2 with this example that deploys a Step Functions workflow triggered via an Amplify-managed AppSync API

Home Page: https://aws.amazon.com/blogs/mobile/integrate-aws-step-functions-with-aws-amplify-using-amplify-custom-resources/

License: MIT No Attribution

HTML 2.49% JavaScript 24.83% TypeScript 72.67%
aws-amplify cdk step-functions

aws-amplify-stepfunctions-example's Introduction

aws-amplify-stepfunctions-example

Note

This sample was originally published on the AWS Front-End Web & Mobile blog in the post Integrate AWS Step Functions with AWS Amplify using Amplify custom resources. The original version used the AWS Amplify CLI to create the custom resource. The current version uses Amplify Gen 2 instead.

In this sample, we'll demonstrate how to integrate custom resources with AWS Amplify Gen 2 using the AWS Cloud Development Kit (CDK). We'll create a Step Functions workflow as an Amplify custom resource and connect it to an existing Amplify-managed GraphQL API.

What you will learn

  • How to create a Step Functions workflow as an Amplify custom resource using the AWS CDK.
  • How to connect our custom resource to an existing Amplify-managed GraphQL API.

What you will build

The proposed solution consists of the following elements:

  • Our sample web application is a customer feedback form built using Vite and Amplify UI.
  • Submitting the feedback form will trigger a Step Functions express workflow created as an Amplify custom resource via an AWS AppSync API managed by Amplify.
  • The Step Function workflow will detect the sentiment of the submitted feedback using Amazon Comprehendโ€™s DetectSentiment API.
  • Next, the workflow will store the feedback and detected sentiment in an Amplify-managed Amazon DynamoDB table.
  • If a non-positive sentiment is detected, the workflow will trigger a notification to a customer support email address using the Amazon Simple Notification Service (Amazon SNS).
  • Depending on the result of the sentiment analysis, our web application will display different confirmation messages to the customer.

The Step Functions workflow looks like this:

From the perspective of the user of our web application, the result will look like this:

Deploy the sample

To deploy the sample, you need to have Node.js 18.x or later installed on your machine.

Clone the repository and navigate to the aws-amplify-stepfunctions-example directory:

git clone https://github.com/aws-samples/aws-amplify-stepfunctions-example.git
cd aws-amplify-stepfunctions-example

Install the dependencies:

npm ci

Fill in your email address in the amplify/backent.ts file to receive the notification emails:

new CustomResources(
    backend.createStack('customResources'),
    'customResources',
    {
        data: {
            apiId: backend.data.apiId,
        },
        notification: {
-             emailAddress: "[email protected]" // Fill in your email address
        }
    }
);

Deploy the sample:

npx ampx sandbox

After the deployment is complete, you can start the development server:

npm run dev

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

aws-amplify-stepfunctions-example's People

Contributors

amazon-auto avatar dependabot[bot] avatar devadyut avatar dreamorosi avatar pbv0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

aws-amplify-stepfunctions-example's Issues

Migration to AWS Amplify Gen 2

Migration to AWS Amplify Gen 2

  • Migrate 'amplify add api' to use Gen 2 backend in-build data
  • Migrate 'amplify add custom' to use Gen 2 Custom CDK Construct
  • Pass GraphQL API ID from Step 1 to be a dependency for Step 2 and simplify the code
  • Change frontend code to call amplify-data client to trigger AppSync API using mutations.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.