AWS S3 basics
1. What is AWS S3?
Section titled “1. What is AWS S3?”Amazon Simple Storage Service (S3) is an object storage service offering scalability, data availability, security, and performance.
- Core Features:
- Store any amount of data.
- Highly durable (11 9’s durability).
- Pay-as-you-go pricing.
- Integrations with other AWS services.
2. Key Concepts
Section titled “2. Key Concepts”- Buckets: Containers for storing objects.
- Unique name within a region.
- Permissions and versioning settings.
- Objects: Fundamental storage entities in S3.
- Consist of a key (name), value (data), and metadata.
- Regions: Physical locations for buckets.
- Storage Classes: Manage costs based on access patterns.
- Standard, Intelligent-Tiering, Glacier, etc.
- Lifecycle Management: Automatically transition objects between storage classes or delete them.
- Versioning: Maintain multiple versions of objects.
Objects
Section titled “Objects”Files in AWS S3 are stored as objects inside a bucket, each object has a unique key within a bucket, each object that it’s own metadata like size, creation date.
AWS S3 quickstart
Section titled “AWS S3 quickstart”Common operations
Section titled “Common operations”Create a Bucket
Section titled “Create a Bucket”let’s create a bucket to store images, for bucket name it is unique globally(Across all AWS not only in your account), for eg if we have bucket name catalog so we need to call it catalog-[unique-suffix] for example something like catalog-PlsTnCRr245454GWX
aws s3 mb s3://<bucket-name> --region <region>Replace <bucket-name> with your chosen bucket name, and name <region> with your AWS region.
Upload an Object
Section titled “Upload an Object”let assume we need to upload and image with path ./images/car-image.png. each uploaded file with be uniquely identified by key.
aws s3 cp ./images/car-image.png s3://<bucket-name>Again Replace <bucket-name> with your chosen bucket name.
Download an Object
Section titled “Download an Object”Now let’s download the uploaded image from the bucket and store it in downloads folder.
aws s3 cp s3://<bucket-name>/car-image.png ./downloadsList Buckets
Section titled “List Buckets”To list all available buckets we can use:
aws s3 lsList Objects in a Bucket
Section titled “List Objects in a Bucket”To list all objects within a bucket we use:
aws s3 ls s3://<bucket-name>You should see the uploaded image in the listed objects.
Delete an Object
Section titled “Delete an Object”Let’s delete the uploaded image, we need for that the object key(image name) and bucket name:
aws s3 rm s3://<bucket-name>/car-image.pngDelete a Bucket
Section titled “Delete a Bucket”Now let’s clean our work and remove the bucket we created. Note that we added the --force flag to force delete non-empty buckets, but please do not use this in production.
aws s3 rb s3://<bucket-name> --forceConclusion
Section titled “Conclusion”AWS S3 is one of the most important and widely used services, in this tutorial we have discoverd essential concepts and operations like creating buckets, uploading files, and deleting files. With this foundational knowledge, we are now equipped the basic knowledge to integrate S3 into our projects.