@studion/infra-code-blocks 0.6.3 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -57,6 +57,12 @@ export type DatabaseArgs = {
|
|
|
57
57
|
* DB parameters to this instance.
|
|
58
58
|
*/
|
|
59
59
|
parameterGroupName?: pulumi.Input<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Specifies whether or not to create this database from a snapshot.
|
|
62
|
+
* This correlates to the snapshot ID you'd find in the RDS console,
|
|
63
|
+
* e.g: rds:production-2015-06-26-06-05.
|
|
64
|
+
*/
|
|
65
|
+
snapshotIdentifier?: pulumi.Input<string>;
|
|
60
66
|
/**
|
|
61
67
|
* A map of tags to assign to the resource.
|
|
62
68
|
*/
|
|
@@ -71,11 +77,13 @@ export declare class Database extends pulumi.ComponentResource {
|
|
|
71
77
|
dbSubnetGroup: aws.rds.SubnetGroup;
|
|
72
78
|
dbSecurityGroup: aws.ec2.SecurityGroup;
|
|
73
79
|
password: Password;
|
|
80
|
+
encryptedSnapshotCopy?: aws.rds.SnapshotCopy;
|
|
74
81
|
monitoringRole?: aws.iam.Role;
|
|
75
82
|
constructor(name: string, args: DatabaseArgs, opts?: pulumi.ComponentResourceOptions);
|
|
76
83
|
private createSubnetGroup;
|
|
77
84
|
private createSecurityGroup;
|
|
78
85
|
private createEncryptionKey;
|
|
79
86
|
private createMonitoringRole;
|
|
87
|
+
private createEncryptedSnapshotCopy;
|
|
80
88
|
private createDatabaseInstance;
|
|
81
89
|
}
|
|
@@ -19,7 +19,7 @@ class Database extends pulumi.ComponentResource {
|
|
|
19
19
|
super('studion:Database', name, {}, opts);
|
|
20
20
|
this.name = name;
|
|
21
21
|
const argsWithDefaults = Object.assign({}, defaults, args);
|
|
22
|
-
const { vpcId, isolatedSubnetIds, vpcCidrBlock, enableMonitoring } = argsWithDefaults;
|
|
22
|
+
const { vpcId, isolatedSubnetIds, vpcCidrBlock, enableMonitoring, snapshotIdentifier, } = argsWithDefaults;
|
|
23
23
|
this.dbSubnetGroup = this.createSubnetGroup({ isolatedSubnetIds });
|
|
24
24
|
this.dbSecurityGroup = this.createSecurityGroup({ vpcId, vpcCidrBlock });
|
|
25
25
|
this.kms = this.createEncryptionKey();
|
|
@@ -27,6 +27,10 @@ class Database extends pulumi.ComponentResource {
|
|
|
27
27
|
if (enableMonitoring) {
|
|
28
28
|
this.monitoringRole = this.createMonitoringRole();
|
|
29
29
|
}
|
|
30
|
+
if (snapshotIdentifier) {
|
|
31
|
+
this.encryptedSnapshotCopy =
|
|
32
|
+
this.createEncryptedSnapshotCopy(snapshotIdentifier);
|
|
33
|
+
}
|
|
30
34
|
this.instance = this.createDatabaseInstance(args);
|
|
31
35
|
this.registerOutputs();
|
|
32
36
|
}
|
|
@@ -85,7 +89,16 @@ class Database extends pulumi.ComponentResource {
|
|
|
85
89
|
});
|
|
86
90
|
return monitoringRole;
|
|
87
91
|
}
|
|
92
|
+
createEncryptedSnapshotCopy(snapshotIdentifier) {
|
|
93
|
+
const encryptedSnapshotCopy = new aws.rds.SnapshotCopy(`${this.name}-encrypted-snapshot-copy`, {
|
|
94
|
+
sourceDbSnapshotIdentifier: snapshotIdentifier,
|
|
95
|
+
targetDbSnapshotIdentifier: `${snapshotIdentifier}-${Date.now()}`,
|
|
96
|
+
kmsKeyId: this.kms.arn,
|
|
97
|
+
}, { parent: this });
|
|
98
|
+
return encryptedSnapshotCopy;
|
|
99
|
+
}
|
|
88
100
|
createDatabaseInstance(args) {
|
|
101
|
+
var _a;
|
|
89
102
|
const argsWithDefaults = Object.assign({}, defaults, args);
|
|
90
103
|
const stack = pulumi.getStack();
|
|
91
104
|
const monitoringOptions = argsWithDefaults.enableMonitoring && this.monitoringRole
|
|
@@ -96,7 +109,7 @@ class Database extends pulumi.ComponentResource {
|
|
|
96
109
|
performanceInsightsRetentionPeriod: 7,
|
|
97
110
|
}
|
|
98
111
|
: {};
|
|
99
|
-
const instance = new aws.rds.Instance(`${this.name}-rds`, Object.assign(Object.assign({ identifierPrefix: `${this.name}-`, engine: 'postgres', engineVersion: '15.5', allocatedStorage: argsWithDefaults.allocatedStorage, maxAllocatedStorage: argsWithDefaults.maxAllocatedStorage, instanceClass: argsWithDefaults.instanceClass, dbName: argsWithDefaults.dbName, username: argsWithDefaults.username, password: this.password.value, dbSubnetGroupName: this.dbSubnetGroup.name, vpcSecurityGroupIds: [this.dbSecurityGroup.id], storageEncrypted: true, kmsKeyId: this.kms.arn, multiAz: argsWithDefaults.multiAz, publiclyAccessible: false, skipFinalSnapshot: argsWithDefaults.skipFinalSnapshot, applyImmediately: argsWithDefaults.applyImmediately, autoMinorVersionUpgrade: true, maintenanceWindow: 'Mon:07:00-Mon:07:30', finalSnapshotIdentifier: `${this.name}-final-snapshot-${stack}`, backupWindow: '06:00-06:30', backupRetentionPeriod: 14, caCertIdentifier: 'rds-ca-rsa2048-g1', parameterGroupName: argsWithDefaults.parameterGroupName }, monitoringOptions), { tags: Object.assign(Object.assign({}, constants_1.commonTags), argsWithDefaults.tags) }), { parent: this, dependsOn: [this.password] });
|
|
112
|
+
const instance = new aws.rds.Instance(`${this.name}-rds`, Object.assign(Object.assign({ identifierPrefix: `${this.name}-`, engine: 'postgres', engineVersion: '15.5', allocatedStorage: argsWithDefaults.allocatedStorage, maxAllocatedStorage: argsWithDefaults.maxAllocatedStorage, instanceClass: argsWithDefaults.instanceClass, dbName: argsWithDefaults.dbName, username: argsWithDefaults.username, password: this.password.value, dbSubnetGroupName: this.dbSubnetGroup.name, vpcSecurityGroupIds: [this.dbSecurityGroup.id], storageEncrypted: true, kmsKeyId: this.kms.arn, multiAz: argsWithDefaults.multiAz, publiclyAccessible: false, skipFinalSnapshot: argsWithDefaults.skipFinalSnapshot, applyImmediately: argsWithDefaults.applyImmediately, autoMinorVersionUpgrade: true, maintenanceWindow: 'Mon:07:00-Mon:07:30', finalSnapshotIdentifier: `${this.name}-final-snapshot-${stack}`, backupWindow: '06:00-06:30', backupRetentionPeriod: 14, caCertIdentifier: 'rds-ca-rsa2048-g1', parameterGroupName: argsWithDefaults.parameterGroupName }, monitoringOptions), { snapshotIdentifier: (_a = this.encryptedSnapshotCopy) === null || _a === void 0 ? void 0 : _a.targetDbSnapshotIdentifier, tags: Object.assign(Object.assign({}, constants_1.commonTags), argsWithDefaults.tags) }), { parent: this, dependsOn: [this.password] });
|
|
100
113
|
return instance;
|
|
101
114
|
}
|
|
102
115
|
}
|