AWS CLI Usage
Abhay Kumar Pinku
1 min read
Table of contents
Operation on S3 Bucket:
Create a S3 bucket:
aws s3 mb s3://abhay10371 --region us-east-1
List bucket content:
aws s3 ls s3://abhay10371
Upload a file from local system to AWS S3 bucket:
aws s3 cp file.txt s3://abhay10371
Download a file from AWS S3 bucket to local system:
aws s3 cp s3://abhay10371/file.txt .
Remove a file from AWS S3 bucket:
aws s3 rm s3://abhay10371/file.txt
Remove an empty S3 bucket:
aws s3 rb s3://abhay10371
Remove a non-empty S3 bucket:
aws s3 rb s3://abhay10371 --force
Remove a non-empty S3 bucket with versioning enabled:
sudo dnf install python-pip3 pip3 install boto3 vim del_bucket.py ============================================================= #!/usr/bin/env python import boto3 s3 = boto3.resource('s3') bucket = s3.Bucket('bucket_name') bucket.object_versions.all().delete() ============================================================= python del_bucket.py # Remove the bucket contenets including delete marker. aws s3 rb s3://bucket_name # Finally remove the bucket.
0
Subscribe to my newsletter
Read articles from Abhay Kumar Pinku directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Abhay Kumar Pinku
Abhay Kumar Pinku
I am Abhay Kumar Pinku. I did my graduation in Electronics and Communication Engineering stream from DSEC, Anna University. I am deeply engaged in DevOps practices for seamless software development and deployment.