@studion/infra-code-blocks 0.0.6 → 0.0.7

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
@@ -30,7 +30,6 @@ import * as studion from '@studion/infra-code-blocks';
30
30
  import * as studion from '@studion/infra-code-blocks';
31
31
 
32
32
  const project = new studion.Project('demo-project', {
33
- environment: 'DEVELOPMENT',
34
33
  services: [
35
34
  {
36
35
  type: 'REDIS',
@@ -76,7 +75,6 @@ type ProjectArgs = {
76
75
  | StaticSiteService
77
76
  | WebServerService
78
77
  )[];
79
- environment: Environment;
80
78
  hostedZoneId?: pulumi.Input<string>;
81
79
  enableSSMConnect?: pulumi.Input<boolean>;
82
80
  };
@@ -85,7 +83,6 @@ type ProjectArgs = {
85
83
  | Argument | Description |
86
84
  | :--------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------: |
87
85
  | services \* | Service list. |
88
- | environment \* | Environment name. |
89
86
  | hostedZoneId | Route53 hosted zone ID responsible for managing records for the domain. |
90
87
  | enableSSMConnect | Setup 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. |
91
88
 
@@ -101,6 +98,9 @@ type DatabaseService = {
101
98
  allocatedStorage?: pulumi.Input<number>;
102
99
  maxAllocatedStorage?: pulumi.Input<number>;
103
100
  instanceClass?: pulumi.Input<string>;
101
+ tags?: pulumi.Input<{
102
+ [key: string]: pulumi.Input<string>;
103
+ }>;
104
104
  };
105
105
  ```
106
106
 
@@ -118,6 +118,9 @@ export type StaticSiteService = {
118
118
  type: 'STATIC_SITE';
119
119
  serviceName: string;
120
120
  domain: pulumi.Input<string>;
121
+ tags?: pulumi.Input<{
122
+ [key: string]: pulumi.Input<string>;
123
+ }>;
121
124
  };
122
125
  ```
123
126
 
@@ -140,6 +143,9 @@ export type WebServerService = {
140
143
  pulumi.Input<RoleInlinePolicy>[]
141
144
  >;
142
145
  taskRoleInlinePolicies?: pulumi.Input<pulumi.Input<RoleInlinePolicy>[]>;
146
+ tags?: pulumi.Input<{
147
+ [key: string]: pulumi.Input<string>;
148
+ }>;
143
149
  };
144
150
  ```
145
151
 
@@ -455,4 +461,4 @@ const project = new studion.Project('demo-project', {
455
461
  ## 🚧 TODO
456
462
 
457
463
  - [ ] Add worker service for executing tasks
458
- - [ ] Update docs, describe each service, describe required stack configs...
464
+ - [ ] Add MongoDB service
@@ -29,6 +29,7 @@ class Database extends pulumi.ComponentResource {
29
29
  ],
30
30
  }, { parent: this });
31
31
  this.kms = new aws.kms.Key(`${name}-rds-key`, {
32
+ description: `${name} RDS encryption key`,
32
33
  customerMasterKeySpec: 'SYMMETRIC_DEFAULT',
33
34
  isEnabled: true,
34
35
  keyUsage: 'ENCRYPT_DECRYPT',
@@ -6,7 +6,6 @@ import { Database, DatabaseArgs } from './database';
6
6
  import { WebServer, WebServerArgs } from './web-server';
7
7
  import { Redis, RedisArgs } from './redis';
8
8
  import { StaticSite, StaticSiteArgs } from './static-site';
9
- import { Environment } from '../constants';
10
9
  import { Ec2SSMConnect } from './ec2-ssm-connect';
11
10
  export type Service = Database | Redis | StaticSite | WebServer;
12
11
  export type Services = Record<string, Service>;
@@ -18,21 +17,19 @@ type ServiceArgs = {
18
17
  };
19
18
  export type DatabaseService = {
20
19
  type: 'DATABASE';
21
- } & ServiceArgs & Omit<DatabaseArgs, 'vpc' | 'tags'>;
20
+ } & ServiceArgs & Omit<DatabaseArgs, 'vpc'>;
22
21
  export type RedisService = {
23
22
  type: 'REDIS';
24
23
  } & ServiceArgs & Pick<RedisArgs, 'dbName' | 'region'>;
25
24
  export type StaticSiteService = {
26
25
  type: 'STATIC_SITE';
27
- } & ServiceArgs & Omit<StaticSiteArgs, 'hostedZoneId' | 'tags'>;
26
+ } & ServiceArgs & Omit<StaticSiteArgs, 'hostedZoneId'>;
28
27
  export type WebServerService = {
29
28
  type: 'WEB_SERVER';
30
29
  environment?: aws.ecs.KeyValuePair[] | ((services: Services) => aws.ecs.KeyValuePair[]);
31
- } & ServiceArgs & Omit<WebServerArgs, 'cluster' | 'vpc' | 'hostedZoneId' | 'environment' | 'tags'>;
32
- export type Environment = (typeof Environment)[keyof typeof Environment];
30
+ } & ServiceArgs & Omit<WebServerArgs, 'cluster' | 'vpc' | 'hostedZoneId' | 'environment'>;
33
31
  export type ProjectArgs = {
34
32
  services: (DatabaseService | RedisService | StaticSiteService | WebServerService)[];
35
- environment: Environment;
36
33
  hostedZoneId?: pulumi.Input<string>;
37
34
  enableSSMConnect?: pulumi.Input<boolean>;
38
35
  };
@@ -41,7 +38,6 @@ export declare class MissingHostedZoneId extends Error {
41
38
  }
42
39
  export declare class Project extends pulumi.ComponentResource {
43
40
  name: string;
44
- environment: Environment;
45
41
  vpc: awsx.ec2.Vpc;
46
42
  cluster?: aws.ecs.Cluster;
47
43
  hostedZoneId?: pulumi.Input<string>;
@@ -33,10 +33,9 @@ class Project extends pulumi.ComponentResource {
33
33
  constructor(name, args, opts = {}) {
34
34
  super('studion:Project', name, {}, opts);
35
35
  this.services = {};
36
- const { services, environment, hostedZoneId } = args;
36
+ const { services, hostedZoneId } = args;
37
37
  this.name = name;
38
38
  this.hostedZoneId = hostedZoneId;
39
- this.environment = environment;
40
39
  this.vpc = this.createVpc();
41
40
  this.createServices(services);
42
41
  if (args.enableSSMConnect) {
@@ -44,9 +43,6 @@ class Project extends pulumi.ComponentResource {
44
43
  this.ec2SSMConnect = new ec2_ssm_connect_1.Ec2SSMConnect(`${name}-ssm-connect`, {
45
44
  vpc: this.vpc,
46
45
  sshPublicKey: sshConfig.require('publicKey'),
47
- tags: {
48
- Env: this.environment,
49
- },
50
46
  });
51
47
  }
52
48
  this.registerOutputs();
@@ -56,9 +52,6 @@ class Project extends pulumi.ComponentResource {
56
52
  numberOfAvailabilityZones: 2,
57
53
  enableDnsHostnames: true,
58
54
  enableDnsSupport: true,
59
- tags: {
60
- Env: this.environment,
61
- },
62
55
  }, { parent: this });
63
56
  return vpc;
64
57
  }
@@ -90,16 +83,11 @@ class Project extends pulumi.ComponentResource {
90
83
  createWebServerPrerequisites() {
91
84
  this.cluster = new aws.ecs.Cluster(`${this.name}-cluster`, {
92
85
  name: this.name,
93
- tags: {
94
- Env: this.environment,
95
- },
96
86
  }, { parent: this });
97
87
  }
98
88
  createDatabaseService(options) {
99
89
  const { serviceName, type } = options, databaseOptions = __rest(options, ["serviceName", "type"]);
100
- const service = new database_1.Database(serviceName, Object.assign(Object.assign({}, databaseOptions), { vpc: this.vpc, tags: {
101
- Env: this.environment,
102
- } }), { parent: this });
90
+ const service = new database_1.Database(serviceName, Object.assign(Object.assign({}, databaseOptions), { vpc: this.vpc }), { parent: this });
103
91
  this.services[serviceName] = service;
104
92
  }
105
93
  createRedisService(options) {
@@ -116,9 +104,7 @@ class Project extends pulumi.ComponentResource {
116
104
  const { serviceName } = options, staticSiteOptions = __rest(options, ["serviceName"]);
117
105
  if (!this.hostedZoneId)
118
106
  throw new MissingHostedZoneId(options.type);
119
- const service = new static_site_1.StaticSite(serviceName, Object.assign(Object.assign({}, staticSiteOptions), { hostedZoneId: this.hostedZoneId, tags: {
120
- Env: this.environment,
121
- } }), { parent: this });
107
+ const service = new static_site_1.StaticSite(serviceName, Object.assign(Object.assign({}, staticSiteOptions), { hostedZoneId: this.hostedZoneId }), { parent: this });
122
108
  this.services[serviceName] = service;
123
109
  }
124
110
  createWebServerService(options) {
@@ -130,9 +116,7 @@ class Project extends pulumi.ComponentResource {
130
116
  const parsedEnv = typeof environment === 'function'
131
117
  ? environment(this.services)
132
118
  : environment;
133
- const service = new web_server_1.WebServer(serviceName, Object.assign(Object.assign({}, ecsOptions), { cluster: this.cluster, vpc: this.vpc, hostedZoneId: this.hostedZoneId, environment: parsedEnv, tags: {
134
- Env: this.environment,
135
- } }), { parent: this });
119
+ const service = new web_server_1.WebServer(serviceName, Object.assign(Object.assign({}, ecsOptions), { cluster: this.cluster, vpc: this.vpc, hostedZoneId: this.hostedZoneId, environment: parsedEnv }), { parent: this });
136
120
  this.services[options.serviceName] = service;
137
121
  }
138
122
  }
@@ -16,7 +16,3 @@ export declare const PredefinedSize: {
16
16
  readonly memory: number;
17
17
  };
18
18
  };
19
- export declare const Environment: {
20
- readonly DEVELOPMENT: "DEVELOPMENT";
21
- readonly PRODUCTION: "PRODUCTION";
22
- };
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Environment = exports.PredefinedSize = void 0;
3
+ exports.PredefinedSize = void 0;
4
4
  const CPU_1_VCPU = 1024;
5
5
  const MEMORY_1GB = 1024;
6
6
  exports.PredefinedSize = {
@@ -21,7 +21,3 @@ exports.PredefinedSize = {
21
21
  memory: MEMORY_1GB * 4, // 4 GB memory
22
22
  },
23
23
  };
24
- exports.Environment = {
25
- DEVELOPMENT: 'DEVELOPMENT',
26
- PRODUCTION: 'PRODUCTION',
27
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studion/infra-code-blocks",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Studion common infra components",
5
5
  "keywords": [
6
6
  "infrastructure",