Skip to content

Commit

Permalink
Update RDS blueprint examples to use DBSubnetGroup (#1958)
Browse files Browse the repository at this point in the history
* Update RDS postgres app implementation, execute postgres command from Deployment

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Fix Lint Remove unnecessary trailing new line

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Initialize testWorkloadName field

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Move BastionWorkload function to be used as utility

* Minor refactor

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Remove export of BastionWorkload() utility function

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Add app name in error messages

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Minor refactor

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Minor refactor

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Update RDS Aurora app implementation, execute mysql query from Deployment

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Remove unused methods from rds aurora app

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Minor refactor

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Add helper methods to add DBSubnetGroup

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* add callers to create and delete dbsubnetGroups in rds postgres app test

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* add callers to create and delete dbsubnetGroups in rds aurora app test

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Refactor code

* Refactor code

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* remove duplicate import

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* minor refactor

* correct indentation

* Fix error

* Minor refactor

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Minor refactor

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Update RDS Aurora app implementation, execute mysql query from Deployment

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Remove unused methods from rds aurora app

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Minor refactor

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* minor refactor

* Minor refactor

* Modify Create RDS Snapshot function to add dbSubnetGroup as outputArtifact

* Modify RestoreRDSSnapshot and ExportRDSLocation function to accept dbSubnetGroup as optional argument

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Add provision to enable/disable public access for RDS instances created during test

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Pass VpcId while creating security group

* Modify Create RDS Snapshot function to add dbSubnetGroup as outputArtifact

* Modify RestoreRDSSnapshot and ExportRDSLocation function to accept dbSubnetGroup as optional argument

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Use securityGroup ID instead of security group name to authorizeSecurityGroupIngress

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Modify Create RDS Snapshot function to add dbSubnetGroup as outputArtifact

* Modify RestoreRDSSnapshot and ExportRDSLocation function to accept dbSubnetGroup as optional argument

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Minor Fix

* Modify Create RDS Snapshot function to add dbSubnetGroup as outputArtifact

* Modify RestoreRDSSnapshot and ExportRDSLocation function to accept dbSubnetGroup as optional argument

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Modify RDS postgres blueprint to use DBsubnetGroup

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Modify RDS postgres dump blueprint to use DBsubnetGroup

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Modify RDS postgres snap blueprint to use DBsubnetGroup

* Modify RDS Aurora snap blueprint example to use DBsubnetGroup

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Fix lint

---------

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>
  • Loading branch information
akankshakumari393 committed Mar 30, 2023
1 parent 7cde857 commit 4e69773
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions examples/aws-rds/aurora-mysql/rds-aurora-snap-blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ actions:
instanceID: "{{ .Phases.createSnapshot.Output.instanceID }}"
securityGroupID: "{{ .Phases.createSnapshot.Output.securityGroupID }}"
allocatedStorage: "{{ .Phases.createSnapshot.Output.allocatedStorage }}"
dbSubnetGroup: "{{ .Phases.createSnapshot.Output.dbSubnetGroup }}"
phases:
- func: CreateRDSSnapshot
name: createSnapshot
Expand All @@ -28,6 +29,7 @@ actions:
snapshotID: "{{ .ArtifactsIn.backupInfo.KeyValue.snapshotID }}"
securityGroupID: "{{ .ArtifactsIn.backupInfo.KeyValue.securityGroupID }}"
dbEngine: "aurora-mysql"
dbSubnetGroup: "{{ .ArtifactsIn.backupInfo.KeyValue.dbSubnetGroup }}"
delete:
inputArtifactNames:
- backupInfo
Expand Down
6 changes: 5 additions & 1 deletion examples/aws-rds/postgresql/rds-postgres-blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ actions:
keyValue:
id: '{{ .Object.metadata.namespace }}-{{ toDate "2006-01-02T15:04:05.999999999Z07:00" .Time | date "2006-01-02T15-04-05" }}'
sgid: "{{ .Phases.backupSnapshots.Output.securityGroupID }}"
dbSubnetGroup: "{{ .Phases.backupSnapshots.Output.dbSubnetGroup }}"
phases:
- func: KubeTask
name: backupSnapshots
Expand Down Expand Up @@ -42,6 +43,9 @@ actions:
vpcsgid=$(aws rds describe-db-instances --db-instance-identifier="{{ index .Object.data "postgres.instanceid" }}" --region "{{ .Profile.Location.Region }}" --query 'DBInstances[].VpcSecurityGroups[].VpcSecurityGroupId' --output text)
kando output securityGroupID $vpcsgid
dbSubnetGroup=$(aws rds describe-db-instances --db-instance-identifier="{{ index .Object.data "postgres.instanceid" }}" --region "{{ .Profile.Location.Region }}" --query 'DBInstances[0].DBSubnetGroup.DBSubnetGroupName' --output text)
kando output dbSubnetGroup $dbSubnetGroup
restore:
inputArtifactNames:
- snapshot
Expand Down Expand Up @@ -77,7 +81,7 @@ actions:
aws rds wait db-instance-deleted --region "{{ .Profile.Location.Region }}" --db-instance-identifier="{{ index .Object.data "postgres.instanceid" }}"
# Restore instance from snapshot
aws rds restore-db-instance-from-db-snapshot --db-instance-identifier="{{ index .Object.data "postgres.instanceid" }}" --db-snapshot-identifier="{{ .ArtifactsIn.snapshot.KeyValue.id }}" --vpc-security-group-ids "{{ .ArtifactsIn.snapshot.KeyValue.sgid }}" --region "{{ .Profile.Location.Region }}"
aws rds restore-db-instance-from-db-snapshot --db-instance-identifier="{{ index .Object.data "postgres.instanceid" }}" --db-snapshot-identifier="{{ .ArtifactsIn.snapshot.KeyValue.id }}" --vpc-security-group-ids "{{ .ArtifactsIn.snapshot.KeyValue.sgid }}" --region "{{ .Profile.Location.Region }}" --db-subnet-group-name "{{ .ArtifactsIn.snapshot.KeyValue.dbSubnetGroup }}"
aws rds wait db-instance-available --region "{{ .Profile.Location.Region }}" --db-instance-identifier="{{ index .Object.data "postgres.instanceid" }}"
delete:
inputArtifactNames:
Expand Down
4 changes: 3 additions & 1 deletion examples/aws-rds/postgresql/rds-postgres-dump-blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ actions:
instanceID: "{{ .Phases.createSnapshot.Output.instanceID }}"
securityGroupID: "{{ .Phases.createSnapshot.Output.securityGroupID }}"
backupID: "{{ .Phases.exportSnapshot.Output.backupID }}"
dbSubnetGroup: "{{ .Phases.createSnapshot.Output.dbSubnetGroup }}"
phases:
- func: CreateRDSSnapshot
name: createSnapshot
Expand All @@ -33,6 +34,7 @@ actions:
databases: '{{ index .Object.data "postgres.databases" }}'
snapshotID: "{{ .Phases.createSnapshot.Output.snapshotID }}"
backupArtifactPrefix: test-postgresql-instance/postgres
dbSubnetGroup: "{{ .Phases.createSnapshot.Output.dbSubnetGroup }}"
- func: DeleteRDSSnapshot
name: deleteSnapshot
args:
Expand All @@ -57,7 +59,7 @@ actions:
username: '{{ index .Phases.restoreSnapshots.Secrets.dbsecret.Data "username" | toString }}'
password: '{{ index .Phases.restoreSnapshots.Secrets.dbsecret.Data "password" | toString }}'
dbEngine: "PostgreSQL"

dbSubnetGroup: "{{ .ArtifactsIn.backupInfo.KeyValue.dbSubnetGroup }}"
delete:
phases:
- func: KubeTask
Expand Down
2 changes: 2 additions & 0 deletions examples/aws-rds/postgresql/rds-postgres-snap-blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ actions:
instanceID: "{{ .Phases.createSnapshot.Output.instanceID }}"
securityGroupID: "{{ .Phases.createSnapshot.Output.securityGroupID }}"
allocatedStorage: "{{ .Phases.createSnapshot.Output.allocatedStorage }}"
dbSubnetGroup: "{{ .Phases.createSnapshot.Output.dbSubnetGroup }}"
phases:
- func: CreateRDSSnapshot
name: createSnapshot
Expand All @@ -26,6 +27,7 @@ actions:
instanceID: "{{ .ArtifactsIn.backupInfo.KeyValue.instanceID }}"
snapshotID: "{{ .ArtifactsIn.backupInfo.KeyValue.snapshotID }}"
securityGroupID: "{{ .ArtifactsIn.backupInfo.KeyValue.securityGroupID }}"
dbSubnetGroup: "{{ .ArtifactsIn.backupInfo.KeyValue.dbSubnetGroup }}"
delete:
inputArtifactNames:
- backupInfo
Expand Down
1 change: 0 additions & 1 deletion pkg/app/rds_aurora_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ func (a *RDSAuroraMySQLDB) Install(ctx context.Context, namespace string) error
return errors.Wrap(err, "Error waiting for DB cluster to be available")
}

// create db instance in the cluster
_, err = rdsCli.CreateDBInstance(ctx, nil, AuroraDBInstanceClass, fmt.Sprintf("%s-instance-1", a.id), string(function.DBEngineAuroraMySQL), "", "", nil, awssdk.Bool(a.publicAccess), awssdk.String(a.id), a.dbSubnetGroup)
if err != nil {
return errors.Wrap(err, "Error creating an instance in Aurora DB cluster")
Expand Down

0 comments on commit 4e69773

Please sign in to comment.