Creating an RDS instance

The RDS database instance can be created using the create_db_instance() function. It requires the parameters that define the instance such as instance identifier, master user name, master user password, instance class, type of database engine such as Oracle, MySQL, and so on, and the storage to be allocated to the instance.

The following Python code demonstrates the creation of a MySQL database instance with the name packtpub with 5 GB in size:

#!/usr/bin/env python

import boto3
rds = boto3.client('rds')
try:
response = rds.create_db_instance(
DBInstanceIdentifier='packtpub',
MasterUsername='dbadmin',
MasterUserPassword='password',
DBInstanceClass='db.t2.micro',
Engine='mysql',
AllocatedStorage=5)
print response
except Exception as error:
print error

We create the object of type rds and invoke the create_db_instance() function. If the function fails, it raises an exception.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.163.31