From 7e6ed3640b8166cf51fcf59b56a60ffdf72ea089 Mon Sep 17 00:00:00 2001 From: ichekrygin Date: Thu, 29 Nov 2018 23:38:25 -0800 Subject: [PATCH] Add support for `subnetGroupName` in RDS to facilitate deployment into VPC's other than default. > A DB subnet group to associate with the DB instance. If you update this value, the new subnet group must be a subnet group in a new VPC. Signed-off-by: ichekrygin --- .../database/v1alpha1/rdsinstance_types.go | 27 +++++++------------ .../v1alpha1/rdsinstance_types_test.go | 5 ++++ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/pkg/apis/aws/database/v1alpha1/rdsinstance_types.go b/pkg/apis/aws/database/v1alpha1/rdsinstance_types.go index 83c01b0..9f01561 100644 --- a/pkg/apis/aws/database/v1alpha1/rdsinstance_types.go +++ b/pkg/apis/aws/database/v1alpha1/rdsinstance_types.go @@ -34,6 +34,11 @@ type RDSInstanceSpec struct { Class string `json:"class"` // like "db.t2.micro" Size int64 `json:"size"` // size in gb + // Specifies a DB subnet group for the DB instance. The new DB instance is created + // in the VPC associated with the DB subnet group. If no DB subnet group is + // specified, then the new DB instance is not created in a VPC. + SubnetGroupName string `json:"subnetGroupName,omitempty"` + // VPC Security groups that will allow the RDS instance to be accessed over the network. // You can consider the following groups: // 1) A default group that allows all communication amongst instances in that group @@ -131,6 +136,11 @@ func NewRDSInstanceSpec(properties map[string]string) *RDSInstanceSpec { spec.SecurityGroups = append(spec.SecurityGroups, strings.Split(val, ",")...) } + val, ok = properties["subnetGroupName"] + if ok { + spec.SubnetGroupName = val + } + return spec } @@ -195,20 +205,3 @@ func (r *RDSInstance) SetBound(state bool) { r.Status.Phase = corev1alpha1.BindingStateUnbound } } - -// ValidVersionValues returns the valid set of engine version values. -func ValidVersionValues() map[string]string { - return map[string]string{ - "5.7": "5.7.21", // default value for 5.7 - "5.7.21": "5.7.21", - "5.7.19": "5.7.19", - "5.7.16": "5.7.16", - "5.6": "5.6.39", // default value for 5.6 - "5.6.39": "5.6.39", - "5.6.37": "5.6.37", - "5.6.35": "5.6.35", - "5.6.34": "5.6.34", - "5.6.29": "5.6.29", - "5.6.27": "5.6.27", - } -} diff --git a/pkg/apis/aws/database/v1alpha1/rdsinstance_types_test.go b/pkg/apis/aws/database/v1alpha1/rdsinstance_types_test.go index 44ab72f..76f899b 100644 --- a/pkg/apis/aws/database/v1alpha1/rdsinstance_types_test.go +++ b/pkg/apis/aws/database/v1alpha1/rdsinstance_types_test.go @@ -87,6 +87,11 @@ func TestNewRDSInstanceSpec(t *testing.T) { m["securityGroups"] = val exp.SecurityGroups = []string{"one", "two", "tree"} g.Expect(NewRDSInstanceSpec(m)).To(Equal(exp)) + + val = "test-subnetgroup" + m["subnetGroupName"] = val + exp.SubnetGroupName = val + g.Expect(NewRDSInstanceSpec(m)).To(Equal(exp)) } func TestIsAvailable(t *testing.T) {