Deploying React With AWS Amplify Console
Tags: aws, ci, cd, amplify
Published: 2019-06-25 19:05:09

---
title: Deploying React With AWS Amplify Console
published: true
description: 
tags: AWS, CI, CD, Amplify
---

###TLDR:
- Setting up AWS Amplify Console/Deploy is really familiar if you've used other CI/CD tools
- It doesn't just build your application but also deploys to a managed CloudFront distribution
- The build config might confuse you slightly if you're coming from something like CircleCI
Intro:
AWS Amplify is a new offering from AWS. It consists of two parts, a framework for creating applications that connects your app with AWS services and a CI/CD tool for deploying any application.

Today we will be talking about the deployment service of AWS Amplify.

I stumbled upon AWS Amplify when researching the best way to do cache invalidation on CloudFront distributions.

It turns out that AWS Amplify does instant invalidations on every deploy! (Click here to read more about it)

I'm going to walk you through setting up AWS Amplify with Github and deploying a Client Side Rendered React App.

Let's go 🚀

###Breakdown of Steps:
1. Integrate Github 😸
2. Connect Repo 🔌
3. Setup Build Config 🔨
4. Build Config Gotchas ⚠️
5. URL Redirects ↩️
Done! ✨ 🎉

###Integrate Github 😸
Time Taken: 3 Minutes

Like a lot of CI/CD tools, you connect AWS Amplify with Github (or other version control tools) and on each commit to the repo causes the build process to start.

![](https://thepracticaldev.s3.amazonaws.com/i/4zmc43s6p9n6yi32znn4.png)

###Connect Repo 🔌
Time Taken: 1 minute

Once you've set up your version control with AWS Amplify, you need to pick your repo and select a branch.

###Setup Build Config 🔨
Time Taken: 5 - 10 minutes

![](https://thepracticaldev.s3.amazonaws.com/i/m9vfjetpwmi8d2g9qunq.png)

This is where the magic begins. If you've used other CI/CD tools than you are familiar with this process.

AWS Amplify will attempt to create a build config automatically, which you can download and place into your repo or edit on the console.

If you have config files for other CI tools, AWS Amplify can also copy these automatically (This is a good and a bad thing)

###Build Config Gotchas ⚠️
There are a few gotchas that caused my initial builds to fail. I've gone through the pain, so you don't have to:

- `sudo` Does not work - This is similar to other CI/CD tools
- The automatic config might pull things from configs from other CI tools like I said earlier this is a good and a bad thing. I had a lot of commands that were needed for CircleCI to build and deploy but not needed for AWS Amplify - Double check the automatic config.
- Build output directory - The warning is there and yet I ignored it. - -Make sure to change baseDirectory to your build processes output folder (Probably /build)

###URL Redirects ↩️
If you're running a SPA (Create React App etc), then you will need to set up URL redirects.

In the app project within the console, there will be settings in the left-hand side one of them will be for "Redirects and rewrites"

Here's the basic one for SPA's:

![](https://thepracticaldev.s3.amazonaws.com/i/lrww6ds4bgjrxww26csa.png)

###Done! ✨ 🎉
You should be done!

AWS Amplify will deploy your app to CloudFront and give you a URL as well.

Need to do more or having issues? Check out the links below

###More Reading:

[Welcome Guide](https://docs.aws.amazon.com/amplify/latest/userguide/welcome.html)

[URL Redirects](https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html)

[Custom Domains](https://docs.aws.amazon.com/amplify/latest/userguide/custom-domains.html)

---

This post was originally posted on [https://blog.dannyaziz.com](https://blog.dannyaziz.com)