Pulumi AI Answers

How to deploy React app to AWS

Pulumi AI is an experimental experience that may produce inaccurate information.

Pulumi AI Answers

To deploy a react app to AWS, one option is to use the AWS Amplify App resource. This service takes your React application and deploys it to a AWS-managed hosting resource.

Below is a simple Pulumi TypeScript program to accomplish this types from the @pulumi/aws package.

import * as aws from "@pulumi/aws";

// After running "git push", AWS Amplify Console will start building and deploying app
let app = new aws.amplify.App("myapp", {
    repository: "",  // Specify your git repository here

    // Specify build settings with the amplify.yml file
    buildSpec: `version: 0.1
                - yarn install
                - yarn run build
            # IMPORTANT - Please verify your build output directory
            baseDirectory: /public
            - '**/*'
            - node_modules/**/*`

// Output the DNS of the app
export const url = app.defaultDomain;

Ensure that you replace “” with the URL of your own repository.

When this Pulumi program runs, it will provision an AWS Ampl App. The Amplify App will connect to the React app in your specified GitHub and start building and deploying your React app on each push to the repository.

The buildSpec attribute is where you provide build configurations. In the above code, it is set to build the project using yarn which is a common package manager for Node.js. You can adjust this if you’re using npm or a different build system.

Remember that this Pulumi program doesn’t handle the creation of AWS resources needed to serve the app such as an S3 bucket or CloudFront distribution. Those are automatically by AWS Amplify.

Once your Pulumi program has successfully run, your React app will be accessible at the output URL, available in the Pulumi console or via the command line.

Use the URL from this program’s output to interact with your deployed app. When you push changes to your Git repository, AWS will use the instructions in “amplify.yml” to rebuild and redeploy your app. So remember to push this Pulumi program and the amplify.yml file to your repository.

Note: This requires setting up the appropriate IAM permissions for the Amplify service to access your repository. For GitHub, that specifically involves creating a personal access token and providing it to AWS.

Learn more

Discover the getting started guides and learn about Pulumi concepts.

Explore the docs →

Pulumi AI

Generate Pulumi infrastructure-as-code programs in any language.

Try Pulumi AI →