How Do You Install Boto 3 on a RHEL Server in AWS?

Problem scenario
You have an EC-2 instance running RedHat Enterprise Linux.  You want to use the Python SDK for AWS called Boto.  What should you do?

Install pip.  See this link if you do not know how. 

1.  Run this command:  sudo pip install boto3

2.  You are done.  The rest is optional.

3.  You may want to install and configure the AWS CLI.  But this is optional if you place the AWS access ID and secret access key in the Python programs themselves.  For directions on installing and configuring the AWS CLI, see this posting

4.  Here is a sample program if you do not have AWS CLI installed and configured. This program merely lists S3 buckets that have been created. It is not destructive.

# Usage instructions
# 1. replace "aaa111" with the aws_access_key_id of your account
# 2. replace "bbb222" with the aws_secret_access_key of your account
# If you are not sure how to find these credentials do the following:
#  To find the AWS Access Key ID and AWS Secret Access Key, in the AWS console, click on your name in the upper right hand corner.
# Then click on "My Security Credentials."  Click "Create New Access Key"  Click "Show Access Key."
#  To run it, call it and run it with a command like this: "python"

import boto3 
s3 = boto3.resource('s3', aws_access_key_id='aaa111', aws_secret_access_key='bbb222')
 for bucket in s3.buckets.all():

5.  As a reference, you may go to this external link to learn more about Boto's features.

Leave a comment

Your email address will not be published. Required fields are marked *