@studion/infra-code-blocks 0.5.1 → 0.5.3
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
|
@@ -12,7 +12,7 @@ Studion Platform common infra components.
|
|
|
12
12
|
## Prerequisites
|
|
13
13
|
|
|
14
14
|
- Working [Pulumi](https://www.pulumi.com/docs/clouds/aws/get-started/begin/#pulumi-aws-before-you-begin) project
|
|
15
|
-
- AWS account with
|
|
15
|
+
- AWS account with necessary permissions for each Studion component
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
@@ -48,7 +48,7 @@ const project = new studion.Project('demo-project', {
|
|
|
48
48
|
export const projectName = project.name;
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
- Deploy
|
|
51
|
+
- Deploy Pulumi stack
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
54
|
$ pulumi up
|
|
@@ -71,7 +71,7 @@ $ pulumi up
|
|
|
71
71
|
Project component makes it really easy to spin up project infrastructure,
|
|
72
72
|
hiding infrastructure complexity.
|
|
73
73
|
<br>
|
|
74
|
-
The component creates its own VPC
|
|
74
|
+
The component creates its own VPC used for resources within the project.
|
|
75
75
|
|
|
76
76
|
```ts
|
|
77
77
|
new Project(name: string, args: ProjectArgs, opts?: pulumi.CustomResourceOptions);
|
|
@@ -102,7 +102,7 @@ type ProjectArgs = {
|
|
|
102
102
|
| Argument | Description |
|
|
103
103
|
| :--------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
104
104
|
| services \* | Service list. |
|
|
105
|
-
| enableSSMConnect |
|
|
105
|
+
| enableSSMConnect | Set up ec2 instance and SSM in order to connect to the database in the private subnet. Please refer to the [SSM Connect](#ssm-connect) section for more info. |
|
|
106
106
|
| numberOfAvailabilityZones | Default is 2 which is recommended. If building a dev server, we can reduce to 1 availability zone to reduce hosting cost. |
|
|
107
107
|
|
|
108
108
|
```ts
|
|
@@ -257,7 +257,7 @@ type EcsServiceOptions = {
|
|
|
257
257
|
|
|
258
258
|
Often, web server depends on other services such as database, Redis, etc.
|
|
259
259
|
For that purpose, environment factory can be used. The factory function
|
|
260
|
-
|
|
260
|
+
receives services bag as argument.
|
|
261
261
|
|
|
262
262
|
```ts
|
|
263
263
|
const project = new studion.Project('demo-project', {
|
|
@@ -287,7 +287,7 @@ const project = new studion.Project('demo-project', {
|
|
|
287
287
|
});
|
|
288
288
|
```
|
|
289
289
|
|
|
290
|
-
In order to pass sensitive information to the container use `secrets` instead of `environment`. AWS will fetch values from
|
|
290
|
+
In order to pass sensitive information to the container, use `secrets` instead of `environment`. AWS will fetch values from
|
|
291
291
|
Secret Manager based on arn that is provided for the `valueFrom` field.
|
|
292
292
|
|
|
293
293
|
```ts
|
|
@@ -379,7 +379,7 @@ type DatabaseArgs = {
|
|
|
379
379
|
};
|
|
380
380
|
```
|
|
381
381
|
|
|
382
|
-
If the password is not specified it will be autogenerated.
|
|
382
|
+
If the password is not specified, it will be autogenerated.
|
|
383
383
|
The database password is stored as a secret inside AWS Secret Manager.
|
|
384
384
|
The secret will be available on the `Database` resource as `password.secret`.
|
|
385
385
|
|
|
@@ -407,8 +407,8 @@ new DatabaseReplica(name: string, args: DatabaseReplicaArgs, opts?: pulumi.Custo
|
|
|
407
407
|
```ts
|
|
408
408
|
type DatabaseReplicaArgs = {
|
|
409
409
|
replicateSourceDb: pulumi.Input<string>;
|
|
410
|
-
dbSubnetGroupName: pulumi.Input<string>;
|
|
411
410
|
dbSecurityGroupId: pulumi.Input<string>;
|
|
411
|
+
dbSubnetGroupName?: pulumi.Input<string>;
|
|
412
412
|
monitoringRole?: aws.iam.Role;
|
|
413
413
|
multiAz?: pulumi.Input<boolean>;
|
|
414
414
|
applyImmediately?: pulumi.Input<boolean>;
|
|
@@ -421,7 +421,15 @@ type DatabaseReplicaArgs = {
|
|
|
421
421
|
}>;
|
|
422
422
|
};
|
|
423
423
|
```
|
|
424
|
-
Database replica requires primary DB instance to exist.
|
|
424
|
+
Database replica requires primary DB instance to exist. If the replica is in the same
|
|
425
|
+
region as primary instance, we should not set `dbSubnetGroupNameParam`.
|
|
426
|
+
The `replicateSourceDb` param is referenced like this:
|
|
427
|
+
```javascript
|
|
428
|
+
const primaryDb = new studion.Database(...);
|
|
429
|
+
const replica = new studion.DatabaseReplica('replica', {
|
|
430
|
+
replicateSourceDb: primaryDb.instance.identifier
|
|
431
|
+
});
|
|
432
|
+
```
|
|
425
433
|
|
|
426
434
|
### Redis
|
|
427
435
|
|
|
@@ -510,7 +518,7 @@ Features:
|
|
|
510
518
|
- creates TLS certificate for the specified domain
|
|
511
519
|
- redirects HTTP traffic to HTTPS
|
|
512
520
|
- creates CloudWatch log group
|
|
513
|
-
- comes with predefined
|
|
521
|
+
- comes with predefined CPU and memory options: `small`, `medium`, `large`, `xlarge`
|
|
514
522
|
|
|
515
523
|
<br>
|
|
516
524
|
|
|
@@ -565,7 +573,7 @@ Features:
|
|
|
565
573
|
- creates TLS certificate for the specified domain
|
|
566
574
|
- redirects HTTP traffic to HTTPS
|
|
567
575
|
- creates CloudWatch log group
|
|
568
|
-
- comes with predefined
|
|
576
|
+
- comes with predefined CPU and memory options: `small`, `medium`, `large`, `xlarge`
|
|
569
577
|
- CDN in front of the application load balancer for static resource caching
|
|
570
578
|
|
|
571
579
|
<br>
|
|
@@ -616,7 +624,7 @@ Features:
|
|
|
616
624
|
- persistent storage
|
|
617
625
|
- service auto-discovery
|
|
618
626
|
- creates CloudWatch log group
|
|
619
|
-
- comes with predefined
|
|
627
|
+
- comes with predefined CPU and memory options: `small`, `medium`, `large`, `xlarge`
|
|
620
628
|
|
|
621
629
|
<br>
|
|
622
630
|
|
|
@@ -648,7 +656,7 @@ export type MongoArgs = {
|
|
|
648
656
|
```
|
|
649
657
|
|
|
650
658
|
If the password is not specified it will be autogenerated.
|
|
651
|
-
The
|
|
659
|
+
The Mongo password is stored as a secret inside AWS Secret Manager.
|
|
652
660
|
The secret will be available on the `Mongo` resource as `password.secret`.
|
|
653
661
|
|
|
654
662
|
### Ecs Service
|
|
@@ -658,7 +666,7 @@ AWS ECS Fargate.
|
|
|
658
666
|
Features:
|
|
659
667
|
|
|
660
668
|
- memory and CPU autoscaling
|
|
661
|
-
- service auto
|
|
669
|
+
- service auto-discovery
|
|
662
670
|
- persistent storage
|
|
663
671
|
- CloudWatch logs
|
|
664
672
|
- comes with predefined cpu and memory options: `small`, `medium`, `large`, `xlarge`
|
|
@@ -739,7 +747,7 @@ Where `CLUSTER_NAME` is the name of the ECS cluster and `TASK_FAMILY_NAME` is th
|
|
|
739
747
|
|
|
740
748
|
## SSM Connect
|
|
741
749
|
|
|
742
|
-
The [Database](#database) component deploys a database instance inside
|
|
750
|
+
The [Database](#database) component deploys a database instance inside an isolated subnet,
|
|
743
751
|
and it's not publicly accessible from outside of VPC.
|
|
744
752
|
<br>
|
|
745
753
|
In order to connect to the database we need to deploy the ec2 instance which will be used
|
|
@@ -788,7 +796,7 @@ Now you can use your favorite database client to connect to the database.
|
|
|
788
796
|

|
|
789
797
|
|
|
790
798
|
It is important that for the host you set `localhost` and for the port you set `5555`
|
|
791
|
-
because we are port
|
|
799
|
+
because we are port-forwarding traffic from
|
|
792
800
|
localhost:5555 to DATABASE_ADDRESS:DATABASE_PORT.
|
|
793
801
|
For the user, password, and database field, set values which are set in the `Project`.
|
|
794
802
|
|
|
@@ -10,7 +10,7 @@ export type DatabaseReplicaArgs = {
|
|
|
10
10
|
* * If primary DB is instance of studion:Database, it can be accessed as
|
|
11
11
|
* `db.dbSubnetGroup.name`.
|
|
12
12
|
*/
|
|
13
|
-
dbSubnetGroupName
|
|
13
|
+
dbSubnetGroupName?: pulumi.Input<string>;
|
|
14
14
|
/**
|
|
15
15
|
* DB security group ID. Should be the same as primary instance.
|
|
16
16
|
* If primary DB is instance of studion:Database, it can be accessed as
|
|
@@ -7,7 +7,6 @@ const constants_1 = require("../constants");
|
|
|
7
7
|
const defaults = {
|
|
8
8
|
multiAz: false,
|
|
9
9
|
applyImmediately: false,
|
|
10
|
-
skipFinalSnapshot: false,
|
|
11
10
|
allocatedStorage: 20,
|
|
12
11
|
maxAllocatedStorage: 100,
|
|
13
12
|
instanceClass: 'db.t4g.micro',
|
|
@@ -33,7 +32,7 @@ class DatabaseReplica extends pulumi.ComponentResource {
|
|
|
33
32
|
performanceInsightsRetentionPeriod: 7,
|
|
34
33
|
}
|
|
35
34
|
: {};
|
|
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 });
|
|
35
|
+
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, skipFinalSnapshot: true }, monitoringOptions), { tags: Object.assign(Object.assign({}, constants_1.commonTags), argsWithDefaults.tags) }), { parent: this });
|
|
37
36
|
return instance;
|
|
38
37
|
}
|
|
39
38
|
}
|