GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - siegerts/amplify-apprunner: React Frontend (with AWS Amplify Auth & Storage) that calls an Express API running on AWS App Runner deployed with AWS Copilot.

BranchesTags
Open more actions menu

Latest commit

 

History

18 Commits
18 Commits

Folders and files

NameName
Last commit message
Last commit date
amplify
amplify
 
 
backend
backend
 
 
public
public
 
 
src
src
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
amplify-ui-screenshot.png
amplify-ui-screenshot.png
 
 
package.json
package.json
 
 
yarn.lock
yarn.lock
 
 

Repository files navigation

amplify-apprunner

React frontend (with Amplify Auth & Storage) hosted on AWS Amplify that calls an Express API running on AWS App Runner.

Both projects live in the same repo:

  • The Amplify app is deployed via continuous CI/CD with GitHub on Amplify Hosting
  • The App Runner service is deployed via AWS Copilot + Docker.

The user's JWT from Amplify Auth is passed with the API request and verified in the service using aws-jwt-verify.

Amplify.configure({
  ...awsExports,
  ...{
    API: {
      endpoints: [
        {
          name: "apprunner-api",
          endpoint:
            process.env.REACT_APP_APPRUNNER_API || "http://localhost:8080",
          custom_header: async () => {
            return {
              Authorization: `${(await Auth.currentSession())
                .getAccessToken()
                .getJwtToken()}`,
            };
          },
        },
      ],
    },
  },
});

The API service returns a simple "promo" message for the UI.

This pattern can be extended to access additional resources or private services via the App Runner service.

Deployment

Frontend

The frontend can be deployed using Amplify Hosting continuous CI/CD from the repository. Use the API endpoint created to populate the Environment Variable REACT_APP_APPRUNNER_API in the Amplify Hosting console for the application.

API Service

Environment Variables

Update the COGNITO_USERPOOL_ID and COGNITO_CLIENT_ID environment variables in backend/copilot/api/manifest.yml. These values should coincide with the AWS Cognito Auth resources created by Amplify, and redeploy.

variables: # Pass environment variables as key value pairs.
  # LOG_LEVEL: info
  # Add in here or in AWS Console
  COGNITO_USERPOOL_ID: <value>
  COGNITO_CLIENT_ID: <value>

AWS Copilot

Once AWS Copilot is installed:

Change into the backend directory and deploy:

cd backend

copilot deploy

Once deployed, the service will be visible in the App Runner console.

About

React Frontend (with AWS Amplify Auth & Storage) that calls an Express API running on AWS App Runner deployed with AWS Copilot.

Topics

amplify-authamplify-storageawsaws-amplifyaws-apprunneraws-cognitoaws-copilotreactreactjsstatic-site

Resources

Readme
Activity

Stars

2 stars

Watchers

2 watching

Forks

2 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.