|
1 | 1 | import * as aws from '@pulumi/aws'; |
2 | 2 | import * as pulumi from '@pulumi/pulumi'; |
3 | | -import * as random from '@pulumi/random'; |
4 | 3 | import { Password } from './password'; |
5 | 4 | import { commonTags } from '../constants'; |
6 | 5 |
|
@@ -55,6 +54,11 @@ export type DatabaseArgs = { |
55 | 54 | * Set this to true to enable database monitoring. Defaults to false. |
56 | 55 | */ |
57 | 56 | enableMonitoring?: pulumi.Input<boolean>; |
| 57 | + /** |
| 58 | + * Set this to true to allow major version upgrades, for example when creating |
| 59 | + * db from the snapshot. Defaults to false. |
| 60 | + */ |
| 61 | + allowMajorVersionUpgrade?: pulumi.Input<boolean>; |
58 | 62 | /** |
59 | 63 | * The name of custom aws.rds.ParameterGroup. Setting this param will apply custom |
60 | 64 | * DB parameters to this instance. |
@@ -82,6 +86,7 @@ const defaults = { |
82 | 86 | maxAllocatedStorage: 100, |
83 | 87 | instanceClass: 'db.t4g.micro', |
84 | 88 | enableMonitoring: false, |
| 89 | + allowMajorVersionUpgrade: false, |
85 | 90 | }; |
86 | 91 |
|
87 | 92 | export class Database extends pulumi.ComponentResource { |
@@ -216,20 +221,11 @@ export class Database extends pulumi.ComponentResource { |
216 | 221 | private createEncryptedSnapshotCopy( |
217 | 222 | snapshotIdentifier: NonNullable<DatabaseArgs['snapshotIdentifier']>, |
218 | 223 | ) { |
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 | | - |
228 | 224 | const encryptedSnapshotCopy = new aws.rds.SnapshotCopy( |
229 | 225 | `${this.name}-encrypted-snapshot-copy`, |
230 | 226 | { |
231 | 227 | sourceDbSnapshotIdentifier: snapshotIdentifier, |
232 | | - targetDbSnapshotIdentifier, |
| 228 | + targetDbSnapshotIdentifier: `${snapshotIdentifier}-encrypted-copy`, |
233 | 229 | kmsKeyId: this.kms.arn, |
234 | 230 | }, |
235 | 231 | { parent: this }, |
@@ -278,7 +274,7 @@ export class Database extends pulumi.ComponentResource { |
278 | 274 | backupRetentionPeriod: 14, |
279 | 275 | caCertIdentifier: 'rds-ca-rsa2048-g1', |
280 | 276 | parameterGroupName: argsWithDefaults.parameterGroupName, |
281 | | - allowMajorVersionUpgrade: Boolean(argsWithDefaults.snapshotIdentifier), |
| 277 | + allowMajorVersionUpgrade: argsWithDefaults.allowMajorVersionUpgrade, |
282 | 278 | snapshotIdentifier: |
283 | 279 | this.encryptedSnapshotCopy?.targetDbSnapshotIdentifier, |
284 | 280 | ...monitoringOptions, |
|
0 commit comments