Yost's Posts
JavaScript tutorials + other stuff

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.
Image

In the “Users” section, open the form to add a new IAM user. Image

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. Image

Give the user blanket admin access. Image

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. Image

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.


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.