Define S3
Amazon S3 (Simple Storage Service) provides object storage, which is built for storing and recovering any amount of information or data from anywhere over the internet. It provides this storage through a web services interface. While designed for developers for easier web-scale computing, it provides 99.999999999 percent durability and 99.99 percent availability of objects. It can also store computer files up to 5 terabytes in size.
AWS S3 Benefits
Some of the benefits of AWS S3 are:
Durability:- S3 provides 99.999999999 percent durability.
Low cost:- S3 lets you store data in a range of “storage classes.” These classes are based on the frequency and immediacy you require in accessing files.
Scalability:- S3 charges you only for what resources you use, and there are no hidden fees or overage charges. You can scale your storage resources to easily meet your organization’s ever-changing demands.
Availability:- S3 offers 99.99 percent availability of objects
Security:- S3 offers an impressive range of access management tools and encryption features that provide top-notch security.
Flexibility:- S3 is ideal for a wide range of uses like data storage, data backup, software delivery, data archiving, disaster recovery, website hosting, mobile applications, IoT devices, and much more.
Simple data transfer:-You don’t have to be an IT genius to execute data transfers on S3. The service revolves around simplicity and ease of use.
These are compelling reasons to sign up for S3. Now, let’s move on and have a look at some of the major components of the AWS S3 storage service.
AWS Buckets and Objects
An object consists of data, key (assigned name), and metadata. A bucket is used to store objects. When data is added to a bucket, Amazon S3 creates a unique version ID and allocates it to the object.
Commonly used AWS CLI commands for Amazon S3
aws s3 ls
- This command lists all of the S3 buckets in your AWS account.aws s3 mb s3://bucket-name
- This command creates a new S3 bucket with the specified name.aws s3 rb s3://bucket-name
- This command deletes the specified S3 bucket.aws s3 cp file.txt s3://bucket-name
- This command uploads a file to an S3 bucket.aws s3 cp s3://bucket-name/file.txt .
- This command downloads a file from an S3 bucket to your local file system.aws s3 sync local-folder s3://bucket-name
- This command syncs the contents of a local folder with an S3 bucket.aws s3 ls s3://bucket-name
- This command lists the objects in an S3 bucket.aws s3 rm s3://bucket-name/file.txt
- This command deletes an object from an S3 bucket.aws s3 presign s3://bucket-name/file.txt
- This command generates a pre-signed URL for an S3 object, which can be used to grant temporary access to the object.aws s3api list-buckets
- This command retrieves a list of all S3 buckets in your AWS account, using the S3 API.
Task-01
Launch an EC2 instance using the AWS Management Console and connect to it using Secure Shell (SSH).
Create an S3 bucket and upload a file to it using the AWS Management Console.
Click on the "Create bucket" button
Step 1:- First we need to create S3 bucket
Step 2:- Now need to give the name and the name should be always unique
Wright, now we block all public access but depending upon requirements we can uncheck that and reset everything will be same and click on Create Bucket
Once it's created it will be looks like below
Step 3:- Now we need to upload file inside the bucket which we have created. Click on upload
Now click on Add files
We have uploaded the file and need to click on upload
Access the file from the EC2 instance using the AWS Command Line Interface (AWS CLI).
- We need to install AWS CLI on an Ubuntu machine by running the below command
sudo apt-get update
sudo apt-get install awscli -y
aws --version
- Then we need to run aws configure in the terminal
AWS Access Key ID [None]: We need to the acess Id which we have download
AWS Secret Access Key [None]: We need to give the password
Default region name [None]: need to give closest region name
Default output format [None]: json
- Now we need to test the CLI by running the below command
# This command should list the contents of your default s3 bucket
aws s3 ls
- you can use the aws s2 cp command to copy files from your S3 bucket to view your EC2 instance and view the content using the cat commands.
aws s3 cp <file-name> s3://<bucket-name>
Ex:- aws s3 cp
Task-02
Create a snapshot of the EC2 instance and use it to launch a new EC2 instance.
Download a file from the S3 bucket using the AWS CLI.
Verify that the contents of the file are the same on both EC2 instances.
Step 1:- Firstly we need to click Snapshots ->create snapshot
Need to select the instance and instance id click on Create snapshot
Once it's finished snapshot is created and using that we can launch EC2 instances as many as we can
Step 2:- Now we need to click on create an image from the snapshot
Now we need to click on launch instances from AMI
Step 3:- Once the server is up and running we need to go inside the server and need to verify the contents are the same or not
Thank you for reading!! I hope you find this article helpful!!
if any queries or corrections to be done to this blog please let me know.
Happy Learning!!
Saikat Mukherjee