Skip to Content
Hybrid Cloud for Developers
book

Hybrid Cloud for Developers

by Manoj Hirway
April 2018
Intermediate to advanced content levelIntermediate to advanced
280 pages
8h 37m
English
Packt Publishing
Content preview from Hybrid Cloud for Developers

Listing the database instances

An application can have many database instances. The describe_db_instances() function will fetch all the database instances into a Python list. This list can then be iterated to determine the database instance information of all the available instances.

The following Python code demonstrates how this is done:

#!/usr/bin/env pythonimport boto3rds = boto3.client('rds')try:        # Fetch the list of all database instances        dbs = rds.describe_db_instances()        for db in dbs['DBInstances']:                print ("MasterUser : %s Endpoint : %s:%s Status:%s") % (                db['MasterUsername'],                db['Endpoint']['Address'],                db['Endpoint']['Port'],                db['DBInstanceStatus'])except Exception as error:                print error

Let's now see how we can connect to the database ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hybrid Cloud for Architects

Hybrid Cloud for Architects

Alok Shrivastwa
OpenStack: Building a Cloud Environment

OpenStack: Building a Cloud Environment

Alok Shrivastwa, Sunil Sarat, Kevin Jackson, Cody Bunch, Egle Sigler, Tony Campbell

Publisher Resources

ISBN: 9781788830874Supplemental Content