Skip to content

Commit e9629e1

Browse files
committed
fix(middleware-sdk-rds): support StartDBInstanceAutomatedBackupsReplication api
According to codegen, StartDBInstanceAutomatedBackupsReplication API should be supported with cross-region copy.
1 parent 54a709b commit e9629e1

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

packages/middleware-sdk-rds/src/index.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,29 @@ describe("middleware-sdk-rds", () => {
119119
expect(presignedUrl).toMatch(/X-Amz-Signature=000000/);
120120
});
121121

122+
it("should build StartDBInstanceAutomatedBackupsReplication cross origin presigned url correctly ", async () => {
123+
const params = {
124+
SourceDBInstanceArn: arn,
125+
KmsKeyId: "000-111",
126+
};
127+
await handler({ input: params });
128+
expect(nextHandler.mock.calls.length).toBe(1);
129+
const middlewareOutput = nextHandler.mock.calls[0][0];
130+
expect(middlewareOutput.input.SourceDBInstanceArn).toEqual(params.SourceDBInstanceArn);
131+
expect(middlewareOutput.input.KmsKeyId).toEqual(params.KmsKeyId);
132+
const presignedUrl = middlewareOutput.input.PreSignedUrl;
133+
expect(presignedUrl).toMatch(/https\:\/\/rds\.src\-region\.amazonaws\.com\/\?/);
134+
expect(presignedUrl).toMatch(/Action\=StartDBInstanceAutomatedBackupsReplication/);
135+
expect(presignedUrl).toMatch(/Version\=2014\-10\-31/);
136+
expect(presignedUrl).toMatch(/X\-Amz\-Security\-Token\=session/);
137+
expect(presignedUrl).toMatch(/X\-Amz\-Algorithm\=AWS4\-HMAC\-SHA256/);
138+
expect(presignedUrl).toMatch(/X\-Amz\-SignedHeaders\=host/);
139+
expect(presignedUrl).toMatch(/X\-Amz\-Credential\=/);
140+
expect(presignedUrl).toMatch(/X\-Amz\-Date\=/);
141+
expect(presignedUrl).toMatch(/X-Amz-Expires=([\d]+)/);
142+
expect(presignedUrl).toMatch(/X-Amz-Signature=000000/);
143+
});
144+
122145
it("should not generate PreSignedUrl if source identifier is not ARN", async () => {
123146
const params = {
124147
SourceDBClusterSnapshotIdentifier: sourceIdentifier,

packages/middleware-sdk-rds/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ const sourceIds: string[] = [
2222
"SourceDBInstanceIdentifier",
2323
"ReplicationSourceIdentifier",
2424
"SourceDBClusterSnapshotIdentifier",
25+
"SourceDBInstanceArn",
2526
];
2627

2728
const sourceIdToCommandKeyMap: { [key: string]: string } = {
2829
SourceDBSnapshotIdentifier: "CopyDBSnapshot",
2930
SourceDBInstanceIdentifier: "CreateDBInstanceReadReplica",
3031
ReplicationSourceIdentifier: "CreateDBCluster",
3132
SourceDBClusterSnapshotIdentifier: "CopyDBClusterSnapshot",
33+
SourceDBInstanceArn: "StartDBInstanceAutomatedBackupsReplication",
3234
};
3335

3436
const version = "2014-10-31";

0 commit comments

Comments
 (0)