Skip to content

Commit 3936fa6

Browse files
committed
Add constant random prefix for SnapshotCopy
1 parent 54c6ead commit 3936fa6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/components/database.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as aws from '@pulumi/aws';
22
import * as pulumi from '@pulumi/pulumi';
3+
import * as random from '@pulumi/random';
34
import { Password } from './password';
45
import { commonTags } from '../constants';
56

@@ -215,11 +216,20 @@ export class Database extends pulumi.ComponentResource {
215216
private createEncryptedSnapshotCopy(
216217
snapshotIdentifier: NonNullable<DatabaseArgs['snapshotIdentifier']>,
217218
) {
219+
const targetDbSnapshotIdentifier = new random.RandomString(
220+
`${this.name}-snapshot-copy-identifier-sufix`,
221+
{
222+
length: 10,
223+
special: false,
224+
},
225+
{ parent: this },
226+
).result.apply(sufix => `${snapshotIdentifier}-${sufix}`);
227+
218228
const encryptedSnapshotCopy = new aws.rds.SnapshotCopy(
219229
`${this.name}-encrypted-snapshot-copy`,
220230
{
221231
sourceDbSnapshotIdentifier: snapshotIdentifier,
222-
targetDbSnapshotIdentifier: `${snapshotIdentifier}-${Date.now()}`,
232+
targetDbSnapshotIdentifier,
223233
kmsKeyId: this.kms.arn,
224234
},
225235
{ parent: this },

0 commit comments

Comments
 (0)