Day 43: S3 Programmatic access with AWS-CLI 💻 📁

Day 43: S3 Programmatic access with AWS-CLI 💻 📁

Hi, I hope you had a great day yesterday. Today as part of the #90DaysofDevOps Challenge we will be exploring most commonly used service in AWS i.e S3.

s3

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).

Read more about S3 using aws-cli here

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.

Let’s begin with task 1

  1. Login to AWS Console and search for "EC2".

  2. Launch an instance with the following details:

    • Name: S3-AWS-CLI

    • Number of instance: 1

    • AMI: Ubuntu

    • Instance type: t2-micro

    • Network Settings: Allow HTTPS and HTTP traffic from the Internet

  1. Click "Launch Instance".

  2. Connect to the instance.

  3. Search for S3 in the AWS Console and create a bucket.

    Click on right corner Create bucket

    Now enter bucket name

    Now click on create bucket

  4. Upload a file to the bucket.

  5. Configure aws cli in created ec2 instance and Access the file from the EC2 instance using AWS CLI.

aws configure

AWS CLI Commands:

  • List S3 buckets: aws s3 ls

  • Create a file and upload it to S3:

        echo "This is for testing purposes" > sample.txt
        aws s3 cp sample.txt s3://<bucket-name>
    

  • Download a file from S3: aws s3 cp s3://<bucket-name>/<file-name> .

  • Sync local folder with S3 bucket: aws s3 sync . s3://<bucket-name>

  • List objects in an S3 bucket: aws s3 ls s3://<bucket-name>

  • Delete an object from S3: aws s3 rm s3://<bucket-name>/<file-name>

  • Create a new bucket: aws s3 mb s3://<bucket-name>

  • Delete a bucket: aws s3 rb s3://<bucket-name>

Let’s begin with task 2

Steps:

  1. Go to the instances page in the AWS Console and create a snapshot.

  2. Use the snapshot to launch a new EC2 instance.

  3. Connect to the new instance using SSH.

  4. Access the bucket list and download the content of the bucket.

Thankyou for reading !!!!!