Overview
AWS S3 stands for Simple Storage Service, which makes storage in the cloud extremely simple.
- Data storage is much cheaper than traditional options.
- Data is accessible from anywhere via the Console, CLI, or SDK.
- There is an incredible focus on security and compliance.
Features
The service is feature rich with everything you could possibly want from a top tier storage solution:
- 99.999999999% Durability (11 9's)
- 99.9% Availability
- Archival (Glacier)
- Auditing (CloudTrail)
- Authentication w/ Bucket Policies
- Authentication w/ IAM
- Batching
- Encryption w/ Client Side
- Encryption w/ Server Side
- Infinitely Scalable
- Inventory
- Life Cycle Policies
- Monitoring
- MFA Delete
- Multipart Upload (Multithreaded Upload)
- Object Sharing
- Object Locking
- Queryable w/ S3 or Glacier Select
- Queryable w/ Athena
- Replication
- Seamlessly Scalable
- Static Website Hosting
- Storage Classes including ML based e.g. Intelligent Tiering
- Triggers
- Versioning
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. 🔥
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
Top comments (0)