@studion/infra-code-blocks 0.4.4 → 0.5.1
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.
package/README.md
CHANGED
|
@@ -58,12 +58,13 @@ $ pulumi up
|
|
|
58
58
|
|
|
59
59
|
1. [Project](#project)
|
|
60
60
|
2. [Database](#database)
|
|
61
|
-
3. [
|
|
62
|
-
4. [
|
|
63
|
-
5. [
|
|
64
|
-
6. [
|
|
65
|
-
7. [
|
|
66
|
-
8. [
|
|
61
|
+
3. [Database Replica](#database-replica)
|
|
62
|
+
4. [Redis](#redis)
|
|
63
|
+
5. [StaticSite](#static-site)
|
|
64
|
+
6. [WebServer](#web-server)
|
|
65
|
+
7. [Nuxt SSR](#nuxt-ssr-preset)
|
|
66
|
+
8. [Mongo](#mongo)
|
|
67
|
+
9. [EcsService](#ecs-service)
|
|
67
68
|
|
|
68
69
|
### Project
|
|
69
70
|
|
|
@@ -118,6 +119,7 @@ type DatabaseServiceOptions = {
|
|
|
118
119
|
maxAllocatedStorage?: pulumi.Input<number>;
|
|
119
120
|
instanceClass?: pulumi.Input<string>;
|
|
120
121
|
enableMonitoring?: pulumi.Input<boolean>;
|
|
122
|
+
parameterGroupName?: pulumi.Input<string>;
|
|
121
123
|
tags?: pulumi.Input<{
|
|
122
124
|
[key: string]: pulumi.Input<string>;
|
|
123
125
|
}>;
|
|
@@ -370,6 +372,7 @@ type DatabaseArgs = {
|
|
|
370
372
|
maxAllocatedStorage?: pulumi.Input<number>;
|
|
371
373
|
instanceClass?: pulumi.Input<string>;
|
|
372
374
|
enableMonitoring?: pulumi.Input<boolean>;
|
|
375
|
+
parameterGroupName?: pulumi.Input<string>;
|
|
373
376
|
tags?: pulumi.Input<{
|
|
374
377
|
[key: string]: pulumi.Input<string>;
|
|
375
378
|
}>;
|
|
@@ -380,6 +383,46 @@ If the password is not specified it will be autogenerated.
|
|
|
380
383
|
The database password is stored as a secret inside AWS Secret Manager.
|
|
381
384
|
The secret will be available on the `Database` resource as `password.secret`.
|
|
382
385
|
|
|
386
|
+
### Database Replica
|
|
387
|
+
|
|
388
|
+
AWS RDS Postgres instance.
|
|
389
|
+
|
|
390
|
+
Features:
|
|
391
|
+
|
|
392
|
+
- enabled encryption with a symmetric encryption key
|
|
393
|
+
- deployed inside an isolated subnet
|
|
394
|
+
|
|
395
|
+
<br>
|
|
396
|
+
|
|
397
|
+
```ts
|
|
398
|
+
new DatabaseReplica(name: string, args: DatabaseReplicaArgs, opts?: pulumi.CustomResourceOptions);
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
| Argument | Description |
|
|
402
|
+
| :------- | :--------------------------------------------: |
|
|
403
|
+
| name \* | The unique name of the resource. |
|
|
404
|
+
| args \* | The arguments to resource properties. |
|
|
405
|
+
| opts | Bag of options to control resource's behavior. |
|
|
406
|
+
|
|
407
|
+
```ts
|
|
408
|
+
type DatabaseReplicaArgs = {
|
|
409
|
+
replicateSourceDb: pulumi.Input<string>;
|
|
410
|
+
dbSubnetGroupName: pulumi.Input<string>;
|
|
411
|
+
dbSecurityGroupId: pulumi.Input<string>;
|
|
412
|
+
monitoringRole?: aws.iam.Role;
|
|
413
|
+
multiAz?: pulumi.Input<boolean>;
|
|
414
|
+
applyImmediately?: pulumi.Input<boolean>;
|
|
415
|
+
allocatedStorage?: pulumi.Input<number>;
|
|
416
|
+
maxAllocatedStorage?: pulumi.Input<number>;
|
|
417
|
+
instanceClass?: pulumi.Input<string>;
|
|
418
|
+
parameterGroupName?: pulumi.Input<string>;
|
|
419
|
+
tags?: pulumi.Input<{
|
|
420
|
+
[key: string]: pulumi.Input<string>;
|
|
421
|
+
}>;
|
|
422
|
+
};
|
|
423
|
+
```
|
|
424
|
+
Database replica requires primary DB instance to exist.
|
|
425
|
+
|
|
383
426
|
### Redis
|
|
384
427
|
|
|
385
428
|
[Upstash](https://upstash.com) Redis instance.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as aws from '@pulumi/aws';
|
|
2
|
+
import * as pulumi from '@pulumi/pulumi';
|
|
3
|
+
export type DatabaseReplicaArgs = {
|
|
4
|
+
/**
|
|
5
|
+
* ARN of the primary DB that we want to replicate.
|
|
6
|
+
*/
|
|
7
|
+
replicateSourceDb: pulumi.Input<string>;
|
|
8
|
+
/**
|
|
9
|
+
* DB subnet group name. Should be the same as primary instance.
|
|
10
|
+
* * If primary DB is instance of studion:Database, it can be accessed as
|
|
11
|
+
* `db.dbSubnetGroup.name`.
|
|
12
|
+
*/
|
|
13
|
+
dbSubnetGroupName: pulumi.Input<string>;
|
|
14
|
+
/**
|
|
15
|
+
* DB security group ID. Should be the same as primary instance.
|
|
16
|
+
* If primary DB is instance of studion:Database, it can be accessed as
|
|
17
|
+
* `db.dbSecurityGroup.id`.
|
|
18
|
+
*/
|
|
19
|
+
dbSecurityGroupId: pulumi.Input<string>;
|
|
20
|
+
/**
|
|
21
|
+
* IAM Monitoring role. Should be the same as primary instance.
|
|
22
|
+
*/
|
|
23
|
+
monitoringRole?: aws.iam.Role;
|
|
24
|
+
/**
|
|
25
|
+
* Specifies if the RDS instance is multi-AZ. Defaults to false.
|
|
26
|
+
*/
|
|
27
|
+
multiAz?: pulumi.Input<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* Specifies whether any database modifications are applied immediately,
|
|
30
|
+
* or during the next maintenance window. Default is false.
|
|
31
|
+
*/
|
|
32
|
+
applyImmediately?: pulumi.Input<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* The allocated storage in gibibytes. Defaults to 20GB.
|
|
35
|
+
*/
|
|
36
|
+
allocatedStorage?: pulumi.Input<number>;
|
|
37
|
+
/**
|
|
38
|
+
* The upper limit to which Amazon RDS can automatically scale
|
|
39
|
+
* the storage of the DB instance. Defaults to 100GB.
|
|
40
|
+
*/
|
|
41
|
+
maxAllocatedStorage?: pulumi.Input<number>;
|
|
42
|
+
/**
|
|
43
|
+
* The instance type of the RDS instance. Defaults to 'db.t4g.micro'.
|
|
44
|
+
*/
|
|
45
|
+
instanceClass?: pulumi.Input<string>;
|
|
46
|
+
/**
|
|
47
|
+
* The name of custom aws.rds.ParameterGroup. Setting this param will apply custom
|
|
48
|
+
* DB parameters to this instance.
|
|
49
|
+
*/
|
|
50
|
+
parameterGroupName?: pulumi.Input<string>;
|
|
51
|
+
/**
|
|
52
|
+
* A map of tags to assign to the resource.
|
|
53
|
+
*/
|
|
54
|
+
tags?: pulumi.Input<{
|
|
55
|
+
[key: string]: pulumi.Input<string>;
|
|
56
|
+
}>;
|
|
57
|
+
};
|
|
58
|
+
export declare class DatabaseReplica extends pulumi.ComponentResource {
|
|
59
|
+
name: string;
|
|
60
|
+
instance: aws.rds.Instance;
|
|
61
|
+
monitoringRole?: aws.iam.Role;
|
|
62
|
+
constructor(name: string, args: DatabaseReplicaArgs, opts?: pulumi.ComponentResourceOptions);
|
|
63
|
+
private createDatabaseInstance;
|
|
64
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatabaseReplica = void 0;
|
|
4
|
+
const aws = require("@pulumi/aws");
|
|
5
|
+
const pulumi = require("@pulumi/pulumi");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
7
|
+
const defaults = {
|
|
8
|
+
multiAz: false,
|
|
9
|
+
applyImmediately: false,
|
|
10
|
+
skipFinalSnapshot: false,
|
|
11
|
+
allocatedStorage: 20,
|
|
12
|
+
maxAllocatedStorage: 100,
|
|
13
|
+
instanceClass: 'db.t4g.micro',
|
|
14
|
+
enableMonitoring: false,
|
|
15
|
+
};
|
|
16
|
+
class DatabaseReplica extends pulumi.ComponentResource {
|
|
17
|
+
constructor(name, args, opts = {}) {
|
|
18
|
+
super('studion:DatabaseReplica', name, {}, opts);
|
|
19
|
+
this.name = name;
|
|
20
|
+
const argsWithDefaults = Object.assign({}, defaults, args);
|
|
21
|
+
this.monitoringRole = argsWithDefaults.monitoringRole;
|
|
22
|
+
this.instance = this.createDatabaseInstance(args);
|
|
23
|
+
this.registerOutputs();
|
|
24
|
+
}
|
|
25
|
+
createDatabaseInstance(args) {
|
|
26
|
+
const argsWithDefaults = Object.assign({}, defaults, args);
|
|
27
|
+
const stack = pulumi.getStack();
|
|
28
|
+
const monitoringOptions = argsWithDefaults.enableMonitoring && this.monitoringRole
|
|
29
|
+
? {
|
|
30
|
+
monitoringInterval: 60,
|
|
31
|
+
monitoringRoleArn: this.monitoringRole.arn,
|
|
32
|
+
performanceInsightsEnabled: true,
|
|
33
|
+
performanceInsightsRetentionPeriod: 7,
|
|
34
|
+
}
|
|
35
|
+
: {};
|
|
36
|
+
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, dbSubnetGroupName: argsWithDefaults.dbSubnetGroupName, vpcSecurityGroupIds: [argsWithDefaults.dbSecurityGroupId], storageEncrypted: true, multiAz: argsWithDefaults.multiAz, publiclyAccessible: false, applyImmediately: argsWithDefaults.applyImmediately, autoMinorVersionUpgrade: true, maintenanceWindow: 'Mon:07:00-Mon:07:30', replicateSourceDb: argsWithDefaults.replicateSourceDb, parameterGroupName: argsWithDefaults.parameterGroupName }, monitoringOptions), { tags: Object.assign(Object.assign({}, constants_1.commonTags), argsWithDefaults.tags) }), { parent: this });
|
|
37
|
+
return instance;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.DatabaseReplica = DatabaseReplica;
|
|
@@ -52,6 +52,11 @@ export type DatabaseArgs = {
|
|
|
52
52
|
* Set this to true to enable database monitoring. Defaults to false.
|
|
53
53
|
*/
|
|
54
54
|
enableMonitoring?: pulumi.Input<boolean>;
|
|
55
|
+
/**
|
|
56
|
+
* The name of custom aws.rds.ParameterGroup. Setting this param will apply custom
|
|
57
|
+
* DB parameters to this instance.
|
|
58
|
+
*/
|
|
59
|
+
parameterGroupName?: pulumi.Input<string>;
|
|
55
60
|
/**
|
|
56
61
|
* A map of tags to assign to the resource.
|
|
57
62
|
*/
|
|
@@ -96,7 +96,7 @@ class Database extends pulumi.ComponentResource {
|
|
|
96
96
|
performanceInsightsRetentionPeriod: 7,
|
|
97
97
|
}
|
|
98
98
|
: {};
|
|
99
|
-
const instance = new aws.rds.Instance(`${this.name}-rds`, Object.assign(Object.assign({ identifierPrefix: `${this.name}-`, engine: 'postgres', engineVersion: '15.
|
|
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, parameterGroupName: argsWithDefaults.parameterGroupName }, monitoringOptions), { tags: Object.assign(Object.assign({}, constants_1.commonTags), argsWithDefaults.tags) }), { parent: this, dependsOn: [this.password] });
|
|
100
100
|
return instance;
|
|
101
101
|
}
|
|
102
102
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './components/web-server';
|
|
|
2
2
|
export * from './components/mongo';
|
|
3
3
|
export * from './components/static-site';
|
|
4
4
|
export * from './components/database';
|
|
5
|
+
export * from './components/database-replica';
|
|
5
6
|
export * from './components/redis';
|
|
6
7
|
export * from './components/project';
|
|
7
8
|
export * from './components/ec2-ssm-connect';
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ __exportStar(require("./components/web-server"), exports);
|
|
|
18
18
|
__exportStar(require("./components/mongo"), exports);
|
|
19
19
|
__exportStar(require("./components/static-site"), exports);
|
|
20
20
|
__exportStar(require("./components/database"), exports);
|
|
21
|
+
__exportStar(require("./components/database-replica"), exports);
|
|
21
22
|
__exportStar(require("./components/redis"), exports);
|
|
22
23
|
__exportStar(require("./components/project"), exports);
|
|
23
24
|
__exportStar(require("./components/ec2-ssm-connect"), exports);
|