Creating an RDS instance

An RDS instance can easily be created using the Amazon.RDS package. This package provides several classes for manipulating Amazon RDS instances. The first step in creating an RDS instance is to create an object of type AmazonRDSClient. You can then create a request object of type CreateDBInstanceRequest and pass the database instance specific parameters to its constructor. These parameters include the database instance identifier, storage size, type of database, database vendor, master user name, and master user password. Once a request object is created, it can then be passed to the CreateDBInstance() function, which creates the database instance. If this function fails, an exception of the type AmazonRDSException is thrown.

The following program demonstrates how to create a MySQL RDS instance:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Amazon;
using Amazon.RDS;
using Amazon.RDS.Model;
using Amazon.Runtime;
using System.Collections.Specialized;
using System.Configuration;

namespace pactpubAWS
{
class RDSDemo
{
static IAmazonRDS client;
static void Main(string[] args)
{
try
{
client = new AmazonRDSClient();
CreateDBInstanceRequest request = new CreateDBInstanceRequest("packtpub", 5, "db.m1.small", "mysql", "dbadmin", "password");
client.CreateDBInstance(request);
}
catch (AmazonRDSException exception)
{
Console.WriteLine("Error!");
Console.WriteLine(exception.ErrorCode);
Console.ReadKey();
}
}
}
}

Now that the database instance is created, let's see how we can list the available instances running in your AWS profile.

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

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