Upload to AWS s3 Bucket 🪣

Ah, connecting to an S3 bucket using the AWS CLI is a pretty straightforward process, and it’s great for managing your files without needing to go through the AWS Management Console. To connect to your s3://my-shareable bucket, you’ll need to have the AWS Command Line Interface (CLI) installed and configured on your machine first. Here’s a casual walk-through:

Step 1: Install AWS CLI

If you haven’t got the AWS CLI installed yet, you’ll want to grab that from the AWS website. There are versions for Windows, macOS, and Linux, so pick the one that matches your operating system.

Step 2: Configure AWS CLI

Once installed, you need to configure it with your AWS credentials. You can do this by running the following command in your terminal or command prompt:

aws configure

You’ll be prompted to enter your AWS Access Key ID, Secret Access Key, region, and output format. If you’re not sure about your access keys, you’ll need to create them in the IAM (Identity and Access Management) section of the AWS Management Console.

For the region, since you’re in Thornton, Colorado, you might want to use us-west-2 (Oregon) or us-east-2 (Ohio) depending on which one gives you better performance. But, you can choose any region that supports S3 and is closest to you or your users. The output format is typically set to json, but you can choose text or table if you prefer.

Step 3: Connect to Your S3 Bucket

Now, to actually connect to your s3://my-shareable bucket, you’ll use the s3 commands. To list the contents of your bucket, you can run:

aws s3 ls s3://my-shareable

This command just lists all the objects in your bucket. To copy, upload, download, or manage files, you’ll use other s3 commands like cp, mv, rm, etc. Here are a few examples:

  • Upload a file to your bucket:
aws s3 cp your-local-file.txt s3://my-shareable/path/
  • Download a file from your bucket:
aws s3 cp s3://my-shareable/path/your-file.txt ./local-directory/
  • Delete a file from your bucket:
aws s3 rm s3://my-shareable/path/your-file.txt

Remember, every time you run these commands, AWS CLI will use the credentials you configured with aws configure. So, make sure those are kept up-to-date!