Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
AWS for System Administrators

You're reading from   AWS for System Administrators Build, automate, and manage your infrastructure on the most popular cloud platform – AWS

Arrow left icon
Product type Paperback
Published in Feb 2021
Publisher Packt
ISBN-13 9781800201538
Length 388 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Prashant Lakhera Prashant Lakhera
Author Profile Icon Prashant Lakhera
Prashant Lakhera
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Section 1: AWS Services and Tools
2. Chapter 1: Setting Up the AWS Environment FREE CHAPTER 3. Chapter 2: Protecting Your AWS Account Using IAM 4. Section 2: Building the Infrastructure
5. Chapter 3: Creating a Data Center in the Cloud Using VPC 6. Chapter 4: Scalable Compute Capacity in the Cloud via EC2 7. Section 3: Adding Scalability and Elasticity to the Infrastructure
8. Chapter 5: Increasing an Application's Fault Tolerance with Elastic Load Balancing 9. Chapter 6: Increasing Application Performance Using AWS Auto Scaling 10. Chapter 7: Creating a Relational Database in the Cloud using AWS Relational Database Service (RDS) 11. Section 4: The Monitoring, Metrics, and Backup Layers
12. Chapter 8: Monitoring AWS Services Using CloudWatch and SNS 13. Chapter 9: Centralizing Logs for Analysis 14. Chapter 10: Centralizing Cloud Backup Solution 15. Chapter 11: AWS Disaster Recovery Solutions 16. Chapter 12: AWS Tips and Tricks 17. Other Books You May Enjoy

Introducing Python Boto3

Python Boto3 is the AWS SDK for Python. It is useful for end users to manage their AWS services—for example, IAM or Elastic Compute Cloud (EC2). Its features are as follows:

  • Feature-rich object-oriented API
  • Provides low-level access to various AWS services

Installing Python Boto3

Boto3 is written in Python. We can use the pip package installer for Python. This comes pre-installed with the OS in many OSes but is straightforward to install manually, with the following command:

sudo apt-get install python3-pip

Once we have pip installed in the system, the installation of AWS Boto3 is simple in Linux by running the following command:

pip3 install boto3

Before we begin using Boto3, we need to set up the authentication credentials, which Boto3 will use to connect to AWS. We already have these credentials configured as part of the AWS CLI setup, via the aws configure command.

Verifying the Boto3 setup

To verify the setup, please follow these steps:

  1. First get the Python command, to get the python shell run the following command:
    python3
    Python 3.6.9 (default, Oct  8 2020, 12:12:24)
    [GCC 8.4.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
  2. To use Boto3, we first need to import it, as follows:
    import boto3
  3. We need to tell Boto3 which service to use (for example: S3 in this case), as follows:
    s3 = boto3.resource("s3")
  4. Print all the bucket names, like this:
    for bucket in s3.buckets.all():
    ...     print(bucket.name)
    ... 
    my-test-s3-bucket-XXXXXX

Here, I have given you a brief introduction to Boto3. Boto3 is powerful, and in a future chapter, we will see how it will be helpful in automating recurring tasks.

You have been reading a chapter from
AWS for System Administrators
Published in: Feb 2021
Publisher: Packt
ISBN-13: 9781800201538
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image