diff --git a/private/model/api/customization_passes.go b/private/model/api/customization_passes.go index 8f7c3308845..b490610f388 100644 --- a/private/model/api/customization_passes.go +++ b/private/model/api/customization_passes.go @@ -313,13 +313,15 @@ func mergeServicesCustomizations(a *API) error { return nil } -// rdsCustomizations are customization for the service/rds. This adds non-modeled fields used for presigning. +// rdsCustomizations are customization for the service/rds. This adds +// non-modeled fields used for presigning. func rdsCustomizations(a *API) error { inputs := []string{ "CopyDBSnapshotInput", "CreateDBInstanceReadReplicaInput", "CopyDBClusterSnapshotInput", "CreateDBClusterInput", + "StartDBInstanceAutomatedBackupsReplicationInput", } for _, input := range inputs { if ref, ok := a.Shapes[input]; ok { diff --git a/service/rds/customizations.go b/service/rds/customizations.go index cee03588640..d6d2e5f6021 100644 --- a/service/rds/customizations.go +++ b/service/rds/customizations.go @@ -15,6 +15,7 @@ func init() { opCreateDBInstanceReadReplica, opCopyDBClusterSnapshot, opCreateDBCluster, + opStartDBInstanceAutomatedBackupsReplication, } initRequest = func(r *request.Request) { for _, operation := range ops { @@ -27,10 +28,11 @@ func init() { func fillPresignedURL(r *request.Request) { fns := map[string]func(r *request.Request){ - opCopyDBSnapshot: copyDBSnapshotPresign, - opCreateDBInstanceReadReplica: createDBInstanceReadReplicaPresign, - opCopyDBClusterSnapshot: copyDBClusterSnapshotPresign, - opCreateDBCluster: createDBClusterPresign, + opCopyDBSnapshot: copyDBSnapshotPresign, + opCreateDBInstanceReadReplica: createDBInstanceReadReplicaPresign, + opCopyDBClusterSnapshot: copyDBClusterSnapshotPresign, + opCreateDBCluster: createDBClusterPresign, + opStartDBInstanceAutomatedBackupsReplication: startDBInstanceAutomatedBackupsReplicationPresign, } if !r.ParamsFilled() { return @@ -109,6 +111,23 @@ func createDBClusterPresign(r *request.Request) { originParams.PreSignedUrl = presignURL(r, originParams.SourceRegion, newParams) } +func startDBInstanceAutomatedBackupsReplicationPresign(r *request.Request) { + originParams := r.Params.(*StartDBInstanceAutomatedBackupsReplicationInput) + + if originParams.SourceRegion == nil || originParams.PreSignedUrl != nil || originParams.DestinationRegion != nil { + return + } + + originParams.DestinationRegion = r.Config.Region + // preSignedUrl is not required for instances in the same region. + if *originParams.SourceRegion == *originParams.DestinationRegion { + return + } + + newParams := awsutil.CopyOf(r.Params).(*StartDBInstanceAutomatedBackupsReplicationInput) + originParams.PreSignedUrl = presignURL(r, originParams.SourceRegion, newParams) +} + // presignURL will presign the request by using SoureRegion to sign with. SourceRegion is not // sent to the service, and is only used to not have the SDKs parsing ARNs. func presignURL(r *request.Request, sourceRegion *string, newParams interface{}) *string { diff --git a/service/rds/customizations_test.go b/service/rds/customizations_test.go index f23983a29fc..ba3d89d5d9f 100644 --- a/service/rds/customizations_test.go +++ b/service/rds/customizations_test.go @@ -91,6 +91,18 @@ func TestPresignCrossRegionRequest(t *testing.T) { Assert: assertAsRegexMatch(fmt.Sprintf(regexPattern, opCreateDBCluster, targetRegion)), }, + opStartDBInstanceAutomatedBackupsReplication: { + Req: func() *request.Request { + req, _ := svc.StartDBInstanceAutomatedBackupsReplicationRequest( + &StartDBInstanceAutomatedBackupsReplicationInput{ + SourceRegion: aws.String("us-west-1"), + SourceDBInstanceArn: aws.String("bar"), + }) + return req + }(), + Assert: assertAsRegexMatch(fmt.Sprintf(regexPattern, + opStartDBInstanceAutomatedBackupsReplication, targetRegion)), + }, opCopyDBSnapshot + " same region": { Req: func() *request.Request { req, _ := svc.CopyDBSnapshotRequest(&CopyDBSnapshotInput{ @@ -137,6 +149,17 @@ func TestPresignCrossRegionRequest(t *testing.T) { }(), Assert: assertAsEmpty(), }, + opStartDBInstanceAutomatedBackupsReplication + " same region": { + Req: func() *request.Request { + req, _ := svc.StartDBInstanceAutomatedBackupsReplicationRequest( + &StartDBInstanceAutomatedBackupsReplicationInput{ + SourceRegion: aws.String("us-west-2"), + SourceDBInstanceArn: aws.String("bar"), + }) + return req + }(), + Assert: assertAsEmpty(), + }, opCopyDBSnapshot + " presignURL set": { Req: func() *request.Request { req, _ := svc.CopyDBSnapshotRequest(&CopyDBSnapshotInput{ @@ -187,6 +210,19 @@ func TestPresignCrossRegionRequest(t *testing.T) { }(), Assert: assertAsEqual("mockPresignedURL"), }, + opStartDBInstanceAutomatedBackupsReplication + " presignURL set": { + Req: func() *request.Request { + req, _ := svc.StartDBInstanceAutomatedBackupsReplicationRequest( + &StartDBInstanceAutomatedBackupsReplicationInput{ + SourceRegion: aws.String("us-west-1"), + KmsKeyId: aws.String("foo"), + SourceDBInstanceArn: aws.String("bar"), + PreSignedUrl: aws.String("mockPresignedURL"), + }) + return req + }(), + Assert: assertAsEqual("mockPresignedURL"), + }, } for name, c := range cases {