Day 43: S3 Programmatic access with AWS-CLI ????

Day 43: S3 Programmatic access with AWS-CLI ????

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

Task-01

Launch an EC2 instance using the AWS Management Console and connect to it using Secure Shell (SSH).

  • Open the Amazon Management Console and sign in.
  • Use the console to access the EC2 service and start an instance.

No alt text provided for this image

  • Connect to the EC2 instance using SSH.

No alt text provided for this image
No alt text provided for this image

Use the AWS Management Console to create an S3 bucket and add a file to it.

  • Go to the S3 service in your Amazon Management Console after logging in.
  • Choose "Create bucket" from the menu.

No alt text provided for this image

  • Click "Create" after giving your bucket a distinct name and choosing the region you want it to be created in.

No alt text provided for this image
No alt text provided for this image

  • Click on 'Create Bucket'

No alt text provided for this image

  • To upload a file, click the "Upload" button.

No alt text provided for this image

  • Choose the file you wish to upload by clicking the "Add files" button in the "Upload" window.

No alt text provided for this image

  • Click "Next" after selecting your file.

No alt text provided for this image

  • You may see the file in your S3 bucket once the upload is finished.

No alt text provided for this image

Use the AWS Command Line Interface to access the file from the EC2 instance (AWS CLI).

  • Activate the AWS CLI.

No alt text provided for this image

  • Check aws-cli installed or not using checking aws version

No alt text provided for this image

  • After setting up the Amazon CLI, configure your account credentials by launching a terminal and using the command aws configure.
  • Type in your Secret Access Key and AWS Access Key ID.

No alt text provided for this image

  • List s3 buckets using the below command:

No alt text provided for this image

  • To copy the file from your S3 bucket to your EC2 instance, use the aws s3 cp command.

No alt text provided for this image

Task-02

Create a snapshot of the EC2 instance and use it to launch a new EC2 instance.

The EC2 instance that you wish to take a snapshot of should be selected.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

  • a snapshot was taken.

No alt text provided for this image

Launch a new EC2 instance using a snapshot.

Generate an image from the snapshot by clicking Actions on the right side of the screen.

No alt text provided for this image

Give the image a name and a description in the "Create Image from Snapshot" dialogue.

No alt text provided for this image

Click on "Create an image."

No alt text provided for this image

Visit the "AMIs" section of the EC2 Dashboard after the image has been produced.

check image is created.

No alt text provided for this image

Right-click on the freshly built AMI to select "Start Instance."

No alt text provided for this image

Choose the configuration choices for the new instance in the "Launch Instance" window.

Choose the VPC and subnet where you want the new instance to start.

You can change the storage volumes in the "Add Storage" section to suit your needs.

After looking over the instance's specifications, click "Launch instance" to start a fresh instance.

No alt text provided for this image

Connect to the instance using SSH:

No alt text provided for this image

here login as the user "ubuntu" rather than the user "root"

No alt text provided for this image

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

aws s3 cp?command to download the file from your S3 bucket to your EC2 instance.

aws s3 cp s3://BUCKET_NAME/PATH/TO/FILE /PATH/TO/LOCAL/FILE        

AWS CLI commands for S3:

Here are some 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 S3bucket.

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.


I sincerely appreciate your time.????

Hafiz Numan

OpenShift Certified | RHCSA | RHCE Certified | DevOps Engineer | FinTech | Linux | AWS | IAC | Terraform | Kubernetes | Prometheus | Grafana | ELK/EFK | Ansible | Shell Scripting | Microservices | Docker | Python | GIT

2 年

Informative article

要查看或添加评论,请登录

Vinay Kumar的更多文章

  • DevOps Project - 4 ????

    DevOps Project - 4 ????

    Project Description The project aims to deploy a web application using Docker Swarm, a container orchestration tool…

    7 条评论
  • DevOps Project 3 ????

    DevOps Project 3 ????

    Project Description The project involves hosting a static website using an AWS S3 bucket. Amazon S3 is an object…

    3 条评论
  • DevOps Project -2 ????

    DevOps Project -2 ????

    Project Description The project is about automating the deployment process of a web application using Jenkins and its…

  • Day 80: DevOps Project 1 ????

    Day 80: DevOps Project 1 ????

    Project Description The project aims to automate the building, testing, and deployment process of a web application…

    2 条评论
  • Day 73 - Setup Grafana on AWS EC2 Instance ????

    Day 73 - Setup Grafana on AWS EC2 Instance ????

    Task: Set up grafana in your local environment on AWS EC2. Go to the AWS console and Launch an EC2 instance To enable…

  • Day 72 - Grafana ????

    Day 72 - Grafana ????

    What is Grafana? No matter where your metrics are kept, Grafana is an open-source data visualization and monitoring…

    4 条评论
  • Day71 - Terraform Interview Questions ????

    Day71 - Terraform Interview Questions ????

    1. What is Terraform and how it is different from other IaaC tools? HashiCorp's Terraform is an Infrastructure as Code…

  • Day 70 - Terraform Modules ????

    Day 70 - Terraform Modules ????

    Modules are containers for multiple resources that are used together. A module consists of a collection of .

    4 条评论
  • Day 69 - Meta-Arguments in Terraform ???

    Day 69 - Meta-Arguments in Terraform ???

    When you define a resource block in Terraform, by default, this specifies one resource that will be created. To manage…

    4 条评论
  • Day 65 - Terraform Resources ????

    Day 65 - Terraform Resources ????

    Understanding Terraform Resources A resource in Terraform represents a component of your infrastructure, such as a…

    2 条评论

社区洞察

其他会员也浏览了