Copying files to S3 with aws-cli

There would be times when you want to upload multiple files from your laptop to S3. This document describes the process for it.

Installing aws-cli on mac

brew install awscli

Configure AWS Credentials

aws configure:

- Enter your awsAccessKeyId
- Entery your awsSecretAccessKey

View S3 Buckets

  • aws s3 ls

View S3 Directory

  • aws s3 ls s3://bucket_name/dir1/

Copy files to S3

Copy all files from local_direcory to s3://bucket-name/dir1:

aws s3 cp local_directory s3://bucket-name/dir1 --recursive

Delete All Files in Directory

  • aws s3 rm s3://bucket_name/dir1/ –recursive

Setting Roles and Policies for EMR

In order to be able to access S3 files from the EMR cluster, attach the AmazonS3FullAccess Policy to the EMRDefaultRole.

Now the EMR cluster would have access to the S3 buckets.

REFERENCE : Creating Access Key & Secret Key

  1. You’ll need create a user with programmatic access by following the steps here (
  2. Next, you’ll create an IAM policy that defines what this user has access to in your AWS account. It’s important to only grant this user minimal access within your account. See this documentation for how to create IAM policies (
  3. Finally, you’ll create an access key and secret key for this user (

Note It’s important to regularly rotate your access and secret keys. See this documentation for more information (