AWS S3 in 3 Minutes
Tags: aws, s3, cloudskills
Published: 2021-01-25 22:21:59

## Overview

AWS [S3](https://aws.amazon.com/s3/) stands for Simple Storage Service, which makes storage in the cloud extremely simple. 
* Data storage is much [cheaper](https://aws.amazon.com/s3/pricing/) than traditional options. 
* Data is accessible from anywhere via the [Console](https://aws.amazon.com/console/), [CLI](https://aws.amazon.com/cli/), or [SDK](https://aws.amazon.com/tools/). 
* There is an incredible focus on [security](https://aws.amazon.com/s3/security/) and [compliance](https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-compliance.html).

## Features

The service is feature rich with everything you could possibly want from a top tier storage solution: 
* [99.999999999% Durability (11 9's)](https://aws.amazon.com/s3/faqs/)
* [99.9% Availability](https://aws.amazon.com/s3/sla)
* [Archival (Glacier)](https://aws.amazon.com/glacier/)
* [Auditing (CloudTrail)](https://docs.aws.amazon.com/AmazonS3/latest/dev/cloudtrail-logging.html)
* [Authentication w/ Bucket Policies](https://docs.aws.amazon.com/AmazonS3/latest/dev/using-iam-policies.html)
* [Authentication w/ IAM](https://docs.aws.amazon.com/AmazonS3/latest/dev/walkthrough1.html)
* [Batching](https://aws.amazon.com/s3/features/batch-operations/)
* [Encryption w/ Client Side](https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingClientSideEncryption.html)
* [Encryption w/ Server Side](https://docs.aws.amazon.com/AmazonS3/latest/dev/serv-side-encryption.html)
* [Infinitely Scalable](https://aws.amazon.com/s3/faqs/)
* [Inventory](https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-inventory.html)
* [Life Cycle Policies](https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html) 
* [Monitoring](https://docs.aws.amazon.com/AmazonS3/latest/dev/monitoring-overview.html)
* [MFA Delete](https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMFADelete.html)
* [Multipart Upload (Multithreaded Upload)](https://docs.aws.amazon.com/AmazonS3/latest/dev/mpuoverview.html)
* [Object Sharing](https://docs.aws.amazon.com/AmazonS3/latest/dev/ShareObjectPreSignedURL.html)
* [Object Locking](https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lock.html)
* [Queryable w/ S3 or Glacier Select](https://aws.amazon.com/blogs/aws/s3-glacier-select/)
* [Queryable w/ Athena](https://aws.amazon.com/blogs/aws/amazon-athena-interactive-sql-queries-for-data-in-amazon-s3/)
* [Replication](https://docs.aws.amazon.com/AmazonS3/latest/dev/replication.html)
* [Seamlessly Scalable](https://aws.amazon.com/s3/faqs/)
* [Static Website Hosting](https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html)
* [Storage Classes](https://aws.amazon.com/s3/storage-classes/) including ML based e.g. [Intelligent Tiering](https://aws.amazon.com/blogs/aws/new-automatic-cost-optimization-for-amazon-s3-via-intelligent-tiering/)
* [Triggers](https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html)
* [Versioning](https://docs.aws.amazon.com/AmazonS3/latest/dev/Versioning.html)

## Terminology

These terms are widely used when discussing S3:
* Arn: Amazon Resource Name; it's a unique id for AWS resources
* Bucket: root object container; name must be globally unique
* Key: object name including prefixes
* Prefix: nested object container; name does not have to be unique
* Object: data stored within a Bucket

## Open Guide (Basics, Tips, Gotchas)

https://github.com/open-guides/og-aws#s3 

## Examples

### Console

> the console is a great place to learn, but it's bad practice to make changes in the console in a production environment. :fire:


![Console 1](https://dev-to-uploads.s3.amazonaws.com/i/52zds11qmu5zt9wsxx1t.PNG)


![Console 2](https://dev-to-uploads.s3.amazonaws.com/i/nxculjq2sz8kr019cojb.PNG)


https://docs.aws.amazon.com/AmazonS3/latest/user-guide/what-is-s3.html

### CLI
     
     # lists buckets
     aws s3 ls 

     # lists objects
     aws s3 ls s3://my-bucket/     

     # upload file
     aws s3 cp file.txt s3://my-bucket/

     # download file
     aws s3 cp s3://my-bucket/file.txt .

     # removes file.txt from S3
     aws s3 rm s3://my-bucket/file.txt

https://docs.aws.amazon.com/cli/latest/userguide/cli-services-s3-commands.html

### SDK (Python)

      # initialize client
      s3 = boto3.client('s3')

      # list buckets
      buckets = s3.list_buckets()
      for b in buckets:
          print(f"Bucket: {b}")

      # list objects
      bucket = s3.Bucket("my-bucket")
      for obj in bucket.objects.all():
          print(f"Object: {obj.Key}")
 
      # upload file
      s3.upload_file("file.txt", "my-bucket", "file.txt")

      # download file
      s3.download_file("my-bucket", "file.txt", "file.txt")

      # remove file
      s3.delete_object("my-bucket", "file.txt")
     
https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-uploading-files.html