Skip to content
This repository has been archived by the owner on Dec 19, 2017. It is now read-only.

Commit

Permalink
Support StorageType parameter in RDS requests
Browse files Browse the repository at this point in the history
This allows DB instances to be created with the "gp2" (general purpose
SSD) storage type.
  • Loading branch information
Phil Frost committed Jan 30, 2015
1 parent 09faed3 commit 3c7c5d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rds/rds.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func makeParams(action string) map[string]string {
type DBInstance struct {
Address string `xml:"Endpoint>Address"`
AllocatedStorage int `xml:"AllocatedStorage"`
StorageType string `xml:"StorageType"`
AvailabilityZone string `xml:"AvailabilityZone"`
BackupRetentionPeriod int `xml:"BackupRetentionPeriod"`
DBInstanceClass string `xml:"DBInstanceClass"`
Expand Down Expand Up @@ -170,6 +171,7 @@ type Parameter struct {
// The CreateDBInstance request parameters
type CreateDBInstance struct {
AllocatedStorage int
StorageType string
AvailabilityZone string
BackupRetentionPeriod int
DBInstanceClass string
Expand Down Expand Up @@ -203,6 +205,10 @@ func (rds *Rds) CreateDBInstance(options *CreateDBInstance) (resp *SimpleResp, e
params["AllocatedStorage"] = strconv.Itoa(options.AllocatedStorage)
}

if options.StorageType != "" {
params["StorageType"] = options.StorageType
}

if options.SetBackupRetentionPeriod {
params["BackupRetentionPeriod"] = strconv.Itoa(options.BackupRetentionPeriod)
}
Expand Down
3 changes: 3 additions & 0 deletions rds/rds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (s *S) Test_CreateDBInstance(c *C) {
EngineVersion: "",
DBName: "5.6.13",
AllocatedStorage: 10,
StorageType: "gp2",
MasterUsername: "foobar",
MasterUserPassword: "bazbarbaz",
DBInstanceClass: "db.m1.small",
Expand All @@ -58,6 +59,7 @@ func (s *S) Test_CreateDBInstance(c *C) {

c.Assert(req.Form["Action"], DeepEquals, []string{"CreateDBInstance"})
c.Assert(req.Form["Engine"], DeepEquals, []string{"mysql"})
c.Assert(req.Form["StorageType"], DeepEquals, []string{"gp2"})
c.Assert(req.Form["DBSecurityGroups.member.1"], DeepEquals, []string{"foo"})
c.Assert(err, IsNil)
c.Assert(resp.RequestId, Equals, "523e3218-afc7-11c3-90f5-f90431260ab4")
Expand Down Expand Up @@ -139,6 +141,7 @@ func (s *S) Test_DescribeDBInstances(c *C) {
c.Assert(resp.DBInstances[0].DBName, Equals, "mysampledb")
c.Assert(resp.DBInstances[0].DBSecurityGroupNames, DeepEquals, []string{"my-db-secgroup"})
c.Assert(resp.DBInstances[0].DBParameterGroupName, Equals, "default.mysql5.6")
c.Assert(resp.DBInstances[0].StorageType, Equals, "gp2")
c.Assert(resp.DBInstances[1].VpcSecurityGroupIds, DeepEquals, []string{"my-vpc-secgroup"})
}

Expand Down
1 change: 1 addition & 0 deletions rds/responses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var DescribeDBInstancesExample = `
<AutoMinorVersionUpgrade>true</AutoMinorVersionUpgrade>
<InstanceCreateTime>2014-01-29T22:58:24.231Z</InstanceCreateTime>
<AllocatedStorage>5</AllocatedStorage>
<StorageType>gp2</StorageType>
<MasterUsername>myawsuser</MasterUsername>
<DBInstanceClass>db.t1.micro</DBInstanceClass>
</DBInstance>
Expand Down

0 comments on commit 3c7c5d1

Please sign in to comment.