Boto3 is an amazon AWS SKD (Software Development Kit ) for Python. Using boto3, it is possible to create , update and delete resources on AWS S3 and EC3 by writing the appropriate Python's Scripts. Here in this blogpost, I will be focusing Amazon Simple Storage Service S3 and show how to create and S3 Bucket. Boto3 is fully maintained and published by Amazon Web Services.
To learn more about Boto3 , please check the link here.
Bellow are the prerequisites
- Have an aws account
- Lunch an EC2 Instance and SSH into it.
- Install Python3
- Install pip
- Install Boto3
sudo amazon-linux-extras install python3.8
** Installing pip **
Once you ssh into your EC2 instance , run the command bellow
sudo yum -y install python-pip
There is no need to install aws cli here since it already comes preinstalled when using amazon linux 2 EC2 instance.
Once installed you can check the version by running the code bellow
pip install boto3
Once you have boto3 installed you can also check the version by running the command bellow
Once you have create the appropriate role and attached it to the instance , you should be able to make some call base on the permission that you passed to the instance via the AIM role
Create an IAM role and attach it to your ec2 instance. On that role you will specify the permission needed to complete your tasks which in here is to interact with aws S3 .I granted full access control to that role
Create a new role
- Select your instance
- Click on the drop down arrow and select security and then Modify the IAM Role and then chose the new IAM role you created
Here I have create an new role and granted it Full Access to S3 and now I should be able to get some response back from my aws resources.
Run the following command and to see the List all the buckets
you have in your account account
aws s3 ls
aws s3 mb s3://volt123zzzz
aws s3 rb s3://volt123zzzz
Once run. the newly created bucket (volt123zzzz) will be removed
In later posts, I will dive deep in and show more functionalities and of aws and boto2
Lets link up on twitter @asksouley