Today In this tutorial we are going to see How to work with s3 bucket from local system or ec2 instance. in this tutorial we are going to cover the following topics
- How to setup aws sdk on window machin
- How to setup access key and secrete key on windows machine
- How to Create the bucket
- How to List the all existing bucket
- How to Delete the existing bucket
Install Aws Sdk on local/ec2 machine
To work with AWS services first you need to install the AWS sdk on your local or ec2 machine.
To download and install app sdk you can use the following link https://aws.amazon.com/getting-started/tools-sdks/
We are going to set up using AWS CLI so go to the above link and click on command line Tools and then click on AWS Cli and set install on local system
Or you can refer to the following link: How to Installing, updating, and uninstalling the AWS CLI version 2
After installation, you can use the following command
aws --version
The above command will show you the version of the installed aws SDK
After installation of the AWS sdk, you need to configure the access key and secrete key. You will get this key from the IAM section or you can ask to account admin he will provide you the key.
How to configure access key and secrete key
To configure the access key and secrete key use the following step
Step1: Open the command prompt
Step2: Type the following command
aws configure
Once execute you need to enter the access key and secrete key
And Congratulation you have successful complete the AWS sdk setup.
How to create bucket
To create a bucket you need to execute the following command but before executing the command you need to know that the bucket name should be unique. if a bucket name is existing then the command will throw an error
aws s3 mb s3://bucket-name
in the above command MB stand for make bucket
Now your bucket will be created by the name of bucket-name
How to list bucket
if you don’t have direct access to AWS console but you have the developed access then you can list the all buckets from your local system using the following command
aws s3 ls
Following will the output for the above coomand
2021-08-30 17:26:08 my-bucket1
2021-08-30 18:45:47 my-bucket2
How to remove bucket
To remove the bucket use the following command. The command will permanently delete the bucket so use the command carefully.
aws s3 rb s3://bucket-name
rb stands for remove bucket. bucket-name will be your bucket name which you are willing to remove