Deploy React Apps to AWS: Part 1 - Setting up the AWS CLI
November 16, 2019
The AWS CLI is essential to working with AWS services like S3, CloudFront, Lambda, etc. Sure, you can configure resources using the AWS Console, but that can be incredibly time-consuming and doesn’t scale.
For example, I’ve been using AWS to host my React apps. The CLI is essential to deploying my /build
directory
whenever I have updated code. And When I start a new project, creating new resources in the AWS Console is annoying and
takes a while - plus I always forget something. So I’ve started using CloudFormation to provision AWS resources and
CircleCI for a CI/CD pipeline, both of which require using the AWS CLI.
Create an AWS account
If you haven’t already, create an AWS account.
Create an IAM User
In your account’s AWS Console, navigate to the IAM module.
In the “Users” section, open the form to add a new IAM user.
Enter a user name and grant programmatic access, which will grant access keys to the user to authorize actions taken via the AWS CLI. Proceed to the next step.
Give the user blanket admin access.
Click next until the review step and submit the form by clicking “Create User”.
On the success page, be sure to download the CSV with your new user’s AWS Access Key and Secret Access Key.
Install and Configure the AWS CLI
Install the AWS CLI on your machine.
Once installed, run the command to quickly configure your AWS CLI.
> aws configure
You’ll be prompted in the terminal to enter the AccessKey
and SecretAccessKey
you downloaded to CSV.
Also provide your default AWS Region.
AWS Access Key ID [None]: <AccessKey>
AWS Secret Access Key [None]: <SecretAccessKey>
Default region name [None]: <Region> // e.g. us-east-1
Default output format [None]: json
To verify that your CLI credentials are properly configured, run the following command, which will output your credentials.
> cat ~/.aws/credentials
[default]
aws_access_key_id=<AccessKey>
aws_secret_access_key=<SecretAccessKey>
And that’s it!
Stay tuned for future installments of this series.
- ← How to write a coding tutorial
- Deploy React Apps to AWS: Part 2 - Create an S3 Bucket and Host a React App Manually →
Hi, I'm Ryan. I live in Denver and work remotely as a JavaScript/React/Node Developer. I'm always having fun building side projects and sometimes write JavaScript-related tutorials that help folks build things, too.