Day 43: S3 Programmatic access with AWS-CLI ๐Ÿ’ป ๐Ÿ“

Day 43: S3 Programmatic access with AWS-CLI ๐Ÿ’ป ๐Ÿ“

day43 of 90daysofdevops

ยท

2 min read

Table of contents

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

    Connect to the EC2 instance using 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).

    Install and Configure the AWS CLI on the EC2 instance

      sudo apt-get update 
      sudo apt install awscli -y
      aws configure
    

    Use the following command to access the file from the s3 bucket.

      aws s3 cp s3://bucket-name/file-name .
    

    The file will be downloaded from the s3 bucket and stored in the current directory of the ec2 instance.

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.

    Select My AMI

  • Download a file from the S3 bucket using the AWS CLI.

      aws s3 cp s3://bucket-name/path/to/file local/path/to/save/file
    

    Replace the following placeholders with your actual information

  • 'bucket-name': The name of your s3 bucket.

  • 'path/to/file': The path and filename of the file you want to download from the bucket.

  • 'local/path/to/save/file': The path and filename where you want to save the downloaded file on your EC2 machine.

    Here's example command

      aws s3 cp s3://devopsbucket09/218308379-a2e841cf-6b77-4d02-bfbe-20d1bae09b20.png /home/user/downloads/218308379-a2e841cf-6b77-4d02-bfbe-20d1bae09b20.png
    

    In this example, the file '218308379-a2e841cf-6b77-4d02-bfbe-20d1bae09b20.png' from the 'devopsbucket09' S3 bucket is being downloaded and saved as '/home/user/downloads/218308379-a2e841cf-6b77-4d02-bfbe-20d1bae09b20.png

  • Verify that the contents of the file are the same on both EC2 instances.

Added Some Useful commands to complete the task. Click here for commands

Let me know if you have any questions or face any issues while doing the tasks.๐Ÿš€

Happy Learning :)

RITUL GUPTA

ย