Day 43: S3 Programmatic access with AWS-CLI ๐ป ๐ - 90DaysOfDevOps
S3
Amazon Simple Storage Service (Amazon S3) is an object storage service that provides a secure and scalable way to store and access data on the cloud. It is designed for storing any kind of data, such as text files, images, videos, backups, and more. Read more here
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.
Access the file from the EC2 instance using the AWS Command Line Interface (AWS CLI).
Steps -
Go to EC2 and launch a new Ubuntu machine.
SSH to the server
Update the Ubuntu machine with the command -
sudo apt update
Install AWS CLI using the command -
sudo apt install awscli -y
Validate the AWS CLI using the command -
aws --version
- Create a new user for AWS CLI from IAM with AmazonS3FullAccess and create access keys -
- Configure AWS CLI using the command -
aws configure
and use the access key that we generated -
- Now, let's create a new S3 bucket from the Console. Go to S3 > Create bucket > Give name and create.
- Upload some data in the bucket -
Now, SSH to the Ubuntu machine and access the data from CLI -
Run the command
aws s3 ls
to list all buckets andaws s3 ls s3://bucket-name
to access data inside a bucket.
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.
Steps -
- Go to EC2 > Snapshot > Create Snapshot.
- Once the snapshot is created, create an image (AMI) from the snapshot.
- Access the AMI and create a new EC2 instance from AMI.
Connect to both old and new EC2 machines and validate if we can see the same data in S3 buckets.
Run the command
aws s3 cp s3://day43-task-bucket/test_file.txt .
to download a file from the bucket to the local machine.
Delete all Volumes/Snapshots/EC2/Buckets once you are done with the practice.
Thank you :)