create_db_instance ( $db_instance_identifier, $allocated_storage, $db_instance_class, $engine, $master_username, $master_user_password, $opt )
Creates a new DB instance.
Access
Parameters
Parameter |
Type |
Required |
Description |
$db_instance_identifier
|
string
|
Required
|
The DB Instance identifier. This parameter is stored as a lowercase string. Constraints:
- Must contain from 1 to 63 alphanumeric characters or hyphens (1 to 15 for SQL Server).
- First character must be a letter.
- Cannot end with a hyphen or contain two consecutive hyphens.
Example: mydbinstance |
$allocated_storage
|
integer
|
Required
|
The amount of storage (in gigabytes) to be initially allocated for the database instance. MySQL Constraints: Must be an integer from 5 to 1024. Type: Integer Oracle Constraints: Must be an integer from 10 to 1024. SQL Server Constraints: Must be an integer from 200 to 1024 (Standard Edition and Enterprise Edition) or from 30 to 1024 (Express Edition and Web Edition) |
$db_instance_class
|
string
|
Required
|
The compute and memory capacity of the DB Instance. Valid Values: db.t1.micro | db.m1.small | db.m1.medium | db.m1.large | db.m1.xlarge | db.m2.xlarge |db.m2.2xlarge | db.m2.4xlarge |
$engine
|
string
|
Required
|
The name of the database engine to be used for this instance. Valid Values: MySQL | oracle-se1 | oracle-se | oracle-ee | sqlserver-ee | sqlserver-se | sqlserver-ex | sqlserver-web |
$master_username
|
string
|
Required
|
The name of master user for the client DB Instance. MySQL Constraints:
- Must be 1 to 16 alphanumeric characters.
- First character must be a letter.
- Cannot be a reserved word for the chosen database engine.
Type: String Oracle Constraints:
- Must be 1 to 30 alphanumeric characters.
- First character must be a letter.
- Cannot be a reserved word for the chosen database engine.
SQL Server Constraints:
- Must be 1 to 128 alphanumeric characters.
- First character must be a letter.
- Cannot be a reserved word for the chosen database engine.
|
$master_user_password
|
string
|
Required
|
The password for the master database user. Can be any printable ASCII character except “/”, “", or “@”. Type: String MySQL Constraints: Must contain from 8 to 41 alphanumeric characters. Oracle Constraints: Must contain from 8 to 30 alphanumeric characters. SQL Server Constraints: Must contain from 8 to 128 alphanumeric characters. |
$opt
|
array
|
Optional
|
An associative array of parameters that can have the following keys:
DBName - string - Optional - The meaning of this parameter differs according to the database engine you use. MySQL The name of the database to create when the DB Instance is created. If this parameter is not specified, no database is created in the DB Instance. Constraints:- Must contain 1 to 64 alphanumeric characters
- Cannot be a word reserved by the specified database engine
Type: String Oracle The Oracle System ID (SID) of the created DB Instance. Default: ORCL Constraints:- Cannot be longer than 8 characters
SQL Server Not applicable. Must be null.DBSecurityGroups - string|array - Optional - A list of DB Security Groups to associate with this DB Instance. Default: The default DB Security Group for the database engine. Pass a string for a single value, or an indexed array for multiple values.VpcSecurityGroupIds - string|array - Optional - A list of EC2 VPC Security Groups to associate with this DB Instance. Default: The default EC2 VPC Security Group for the DB Subnet group’s VPC. Pass a string for a single value, or an indexed array for multiple values.AvailabilityZone - string - Optional - The EC2 Availability Zone that the database instance will be created in. Default: A random, system-chosen Availability Zone in the endpoint’s region. Example: us-east-1d Constraint: The AvailabilityZone parameter cannot be specified if the MultiAZ parameter is set to true . The specified Availability Zone must be in the same region as the current endpoint.DBSubnetGroupName - string - Optional - A DB Subnet Group to associate with this DB Instance. If there is no DB Subnet Group, then it is a non-VPC DB instance.PreferredMaintenanceWindow - string - Optional - The weekly time range (in UTC) during which system maintenance can occur. Format: ddd:hh24:mi-ddd:hh24:mi Default: A 30-minute window selected at random from an 8-hour block of time per region, occurring on a random day of the week. The following list shows the time blocks for each region from which the default maintenance windows are assigned.- US-East (Northern Virginia) Region: 03:00-11:00 UTC
- US-West (Northern California) Region: 06:00-14:00 UTC
- EU (Ireland) Region: 22:00-06:00 UTC
- Asia Pacific (Singapore) Region: 14:00-22:00 UTC
- Asia Pacific (Tokyo) Region: 17:00-03:00 UTC
Valid Days: Mon, Tue, Wed, Thu, Fri, Sat, Sun Constraints: Minimum 30-minute window.DBParameterGroupName - string - Optional - The name of the DB Parameter Group to associate with this DB instance. If this argument is omitted, the default DBParameterGroup for the specified engine will be used. Constraints:- Must be 1 to 255 alphanumeric characters
- First character must be a letter
- Cannot end with a hyphen or contain two consecutive hyphens
BackupRetentionPeriod - integer - Optional - The number of days for which automated backups are retained. Setting this parameter to a positive number enables backups. Setting this parameter to 0 disables automated backups. Default: 1 Constraints:- Must be a value from 0 to 8
- Cannot be set to 0 if the DB Instance is a master instance with read replicas
PreferredBackupWindow - string - Optional - The daily time range during which automated backups are created if automated backups are enabled, using the BackupRetentionPeriod parameter. Default: A 30-minute window selected at random from an 8-hour block of time per region. The following list shows the time blocks for each region from which the default backup windows are assigned.- US-East (Northern Virginia) Region: 03:00-11:00 UTC
- US-West (Northern California) Region: 06:00-14:00 UTC
- EU (Ireland) Region: 22:00-06:00 UTC
- Asia Pacific (Singapore) Region: 14:00-22:00 UTC
- Asia Pacific (Tokyo) Region: 17:00-03:00 UTC
Constraints: Must be in the format hh24:mi-hh24:mi . Times should be Universal Time Coordinated (UTC). Must not conflict with the preferred maintenance window. Must be at least 30 minutes.Port - integer - Optional - The port number on which the database accepts connections. MySQL Default: 3306 Valid Values: 1150-65535 Type: Integer Oracle Default: 1521 Valid Values: 1150-65535 SQL Server Default: 1433 Valid Values: 1150-65535 except for 1434 and 3389 .MultiAZ - boolean - Optional - Specifies if the DB Instance is a Multi-AZ deployment. You cannot set the AvailabilityZone parameter if the MultiAZ parameter is set to true.EngineVersion - string - Optional - The version number of the database engine to use. MySQL Example: 5.1.42 Type: String Oracle Example: 11.2.0.2.v2 Type: String SQL Server Example: 10.50.2789.0.v1 AutoMinorVersionUpgrade - boolean - Optional - Indicates that minor engine upgrades will be applied automatically to the DB Instance during the maintenance window. Default: true LicenseModel - string - Optional - License model information for this DB Instance. Valid values: license-included | bring-your-own-license | general-public-license Iops - integer - Optional - The amount of Provisioned IOPS (input/output operations per second) to be initially allocated for the DB Instance. Constraints: Must be an integer greater than 1000.OptionGroupName - string - Optional - Indicates that the DB Instance should be associated with the specified option group.CharacterSetName - string - Optional - For supported engines, indicates that the DB Instance should be associated with the specified CharacterSet.PubliclyAccessible - boolean - Optional - curlopts - array - Optional - A set of values to pass directly into curl_setopt() , where the key is a pre-defined CURLOPT_* constant.returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests. |
Returns
Examples
Create a MySQL database instance.
// Instantiate the class
$rds = new AmazonRDS();
$response = $rds->create_db_instance('myInstance', 5, 'db.m1.small', 'MySQL', 'dbUser', 'dbPassword', array(
'DBName' => 'myDatabase',
'DBSecurityGroups' => 'default',
'PreferredMaintenanceWindow' => 'Sun:05:00-Sun:09:00',
'BackupRetentionPeriod' => 1,
'PreferredBackupWindow' => '03:00-05:00',
'MultiAZ' => true,
'AutoMinorVersionUpgrade' => true
));
// Success?
var_dump($response->isOK());
Result:
bool(true)
Create an Oracle database instance.
// Instantiate the class
$rds = new AmazonRDS();
$response = $rds->create_db_instance('myInstance-oracle', 10, 'db.m1.small', 'oracle-se1', 'dbUser', 'dbPassword', array(
'DBName' => 'oracledb',
'DBSecurityGroups' => 'default',
'BackupRetentionPeriod' => 1,
'PreferredBackupWindow' => '03:00-05:00',
'Port' => 1521,
'LicenseModel' => 'bring-your-own-license'
));
// Success?
var_dump($response->isOK());
Result:
bool(true)
Related Methods
Source
Method defined in services/rds.class.php | Toggle source view (30 lines) | View on GitHub
public function create_db_instance($db_instance_identifier, $allocated_storage, $db_instance_class, $engine, $master_username, $master_user_password, $opt = null)
{
if (!$opt) $opt = array();
$opt['DBInstanceIdentifier'] = $db_instance_identifier;
$opt['AllocatedStorage'] = $allocated_storage;
$opt['DBInstanceClass'] = $db_instance_class;
$opt['Engine'] = $engine;
$opt['MasterUsername'] = $master_username;
$opt['MasterUserPassword'] = $master_user_password;
// Optional list (non-map)
if (isset($opt['DBSecurityGroups']))
{
$opt = array_merge($opt, CFComplexType::map(array(
'DBSecurityGroups' => (is_array($opt['DBSecurityGroups']) ? $opt['DBSecurityGroups'] : array($opt['DBSecurityGroups']))
), 'member'));
unset($opt['DBSecurityGroups']);
}
// Optional list (non-map)
if (isset($opt['VpcSecurityGroupIds']))
{
$opt = array_merge($opt, CFComplexType::map(array(
'VpcSecurityGroupIds' => (is_array($opt['VpcSecurityGroupIds']) ? $opt['VpcSecurityGroupIds'] : array($opt['VpcSecurityGroupIds']))
), 'member'));
unset($opt['VpcSecurityGroupIds']);
}
return $this->authenticate('CreateDBInstance', $opt);
}