TABLE OF CONTENTS
S3
Amazon Simple Storage Service (AWS S3) is a scalable, high-speed, low-cost, and fully managed object storage service provided by Amazon Web Services (AWS). S3 provides customers with secure and durable storage of their data in the form of objects, which are organized into buckets and can be accessed through APIs and web-based interfaces.
S3 buckets can be used for a variety of purposes, including file storage, backup and archiving big data analytics, and content distribution.
The buckets are easily accessible from anywhere in the world, making it simple to store, access, and manage data on the cloud. S3 also provides a number of features that make it easy to manage and organize data, such as versioning, lifecycle policies, and access controls.
Task-01: Creating a S3 bucket
Launch an EC2 instance using the AWS Management Console and connect to it using Secure Shell (SSH).
Launch an EC2 instance by providing all the default configurations as we have seen in my previous blogs.
Connect to the server using SSH. Open Command Prompt in your local system and navigate to the private key ".pem" file location.
Copy the ssh command from the console and paste on CMD.
Now you are connected to the EC2 instance.
Create an S3 bucket and upload a file to it using the AWS Management Console.
Navigate to the S3 page in the AWS console and provide the bucket name and choose the region for it.
The S3 bucket is created now.
Now upload a file to the S3 bucket.
I have added my resume and a fileS3.txt to the bucket from my local system.
The file is now uploaded to the S3 bucket.
Access the file from the EC2 instance using the AWS Command Line Interface (AWS CLI).
Navigate to your instance and install AWS CLI.
Configure this with the IAM user having specific permission to have a connection between AWS CLI to the management console.
Provide the necessary Access key IDs to build the connection.
Now you can view the S3 bucket list and copy the file from S3 to EC2.
You can view the file content now in AWS CLI.
Task 2: Creating a EC2 snapshot and integrating to S3
Create a snapshot of the EC2 instance and use it to launch a new EC2 instance.
Navigate to the snapshot section in the AWS console.
Snapshot is now created.
Now create an image from the snapshot.
Navigate to AMIs section in EC2 dashboard and you can see the Machine image. Then create an instance from the image.
You can see the new instance now.
Download a file from the S3 bucket using the AWS CLI.
Now, connect the instance from AWS CLI to the AWS management console.
Verify that the contents of the file are the same on both EC2 instances.
Download the file from S3 on the new instance and verify the content is matched with the old instance.
Some important AWS S3 commands are:-
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.
Thanks for reading my article. Have a nice day.
WRITTEN BY Biswaraj Sahoo --AWS Community Builder | DevOps Engineer | Docker | Linux | Jenkins | AWS | Git | Terraform | Docker | kubernetes
Empowering communities via open source and education. Connect with me over linktree: linktr.ee/biswaraj333