@studion/infra-code-blocks 0.0.5 → 0.0.6
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 +57 -5
- package/dist/components/database.d.ts +6 -0
- package/dist/components/database.js +1 -0
- package/dist/components/ec2-ssm-connect.d.ts +3 -0
- package/dist/components/ec2-ssm-connect.js +1 -3
- package/dist/components/project.d.ts +3 -3
- package/dist/components/project.js +21 -4
- package/dist/components/static-site.d.ts +6 -0
- package/dist/components/static-site.js +2 -0
- package/dist/components/web-server.d.ts +6 -0
- package/dist/components/web-server.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -177,7 +177,15 @@ const project = new studion.Project('demo-project', {
|
|
|
177
177
|
|
|
178
178
|
### Database
|
|
179
179
|
|
|
180
|
-
RDS Postgres instance.
|
|
180
|
+
AWS RDS Postgres instance.
|
|
181
|
+
|
|
182
|
+
Features:
|
|
183
|
+
|
|
184
|
+
- enabled encryption with a symmetric encryption key
|
|
185
|
+
- deployed inside a private subnet
|
|
186
|
+
- backup enabled with retention period set to 14 days
|
|
187
|
+
|
|
188
|
+
<br>
|
|
181
189
|
|
|
182
190
|
```ts
|
|
183
191
|
new Database(name: string, args: DatabaseArgs, opts?: pulumi.CustomResourceOptions);
|
|
@@ -200,12 +208,31 @@ type DatabaseArgs = {
|
|
|
200
208
|
allocatedStorage?: pulumi.Input<number>;
|
|
201
209
|
maxAllocatedStorage?: pulumi.Input<number>;
|
|
202
210
|
instanceClass?: pulumi.Input<string>;
|
|
211
|
+
tags?: pulumi.Input<{
|
|
212
|
+
[key: string]: pulumi.Input<string>;
|
|
213
|
+
}>;
|
|
203
214
|
};
|
|
204
215
|
```
|
|
205
216
|
|
|
206
217
|
### Redis
|
|
207
218
|
|
|
208
|
-
Upstash Redis instance.
|
|
219
|
+
[Upstash](https://upstash.com) Redis instance.
|
|
220
|
+
|
|
221
|
+
**Prerequisites**
|
|
222
|
+
|
|
223
|
+
1. Stack Config
|
|
224
|
+
|
|
225
|
+
| Name | Description | Secret |
|
|
226
|
+
| :---------------- | :-----------------: | :----: |
|
|
227
|
+
| upstash:email \* | Upstash user email. | true |
|
|
228
|
+
| upstash:apiKey \* | Upstash API key. | true |
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
$ pulumi config set --secret upstash:email myemail@example.com
|
|
232
|
+
$ pulumi config set --secret upstash:apiKey my-api-key
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
<br>
|
|
209
236
|
|
|
210
237
|
```ts
|
|
211
238
|
new Redis(name: string, args: RedisArgs, opts: RedisOptions);
|
|
@@ -230,7 +257,16 @@ interface RedisOptions extends pulumi.ComponentResourceOptions {
|
|
|
230
257
|
|
|
231
258
|
### Static Site
|
|
232
259
|
|
|
233
|
-
|
|
260
|
+
AWS S3 + Cloudfront static site.
|
|
261
|
+
|
|
262
|
+
Features:
|
|
263
|
+
|
|
264
|
+
- creates TLS certificate for the specified domain
|
|
265
|
+
- redirects HTTP traffic to HTTPS
|
|
266
|
+
- enables http2 and http3 protocols
|
|
267
|
+
- uses North America and Europe edge locations
|
|
268
|
+
|
|
269
|
+
<br>
|
|
234
270
|
|
|
235
271
|
```ts
|
|
236
272
|
new StaticSite(name: string, args: StaticSiteArgs, opts?: pulumi.ComponentResourceOptions );
|
|
@@ -246,12 +282,25 @@ new StaticSite(name: string, args: StaticSiteArgs, opts?: pulumi.ComponentResour
|
|
|
246
282
|
type StaticSiteArgs = {
|
|
247
283
|
domain: pulumi.Input<string>;
|
|
248
284
|
hostedZoneId: pulumi.Input<string>;
|
|
285
|
+
tags?: pulumi.Input<{
|
|
286
|
+
[key: string]: pulumi.Input<string>;
|
|
287
|
+
}>;
|
|
249
288
|
};
|
|
250
289
|
```
|
|
251
290
|
|
|
252
291
|
### Web Server
|
|
253
292
|
|
|
254
|
-
|
|
293
|
+
AWS ECS Fargate web server.
|
|
294
|
+
|
|
295
|
+
Features:
|
|
296
|
+
|
|
297
|
+
- Memory and CPU autoscaling enabled
|
|
298
|
+
- creates TLS certificate for the specified domain
|
|
299
|
+
- redirects HTTP traffic to HTTPS
|
|
300
|
+
- creates CloudWatch log group
|
|
301
|
+
- comes with predefined cpu and memory options: `small`, `medium`, `large`, `xlarge`
|
|
302
|
+
|
|
303
|
+
<br>
|
|
255
304
|
|
|
256
305
|
```ts
|
|
257
306
|
new WebServer(name: string, args: WebServerArgs, opts?: pulumi.ComponentResourceOptions );
|
|
@@ -281,6 +330,9 @@ export type WebServerArgs = {
|
|
|
281
330
|
pulumi.Input<RoleInlinePolicy>[]
|
|
282
331
|
>;
|
|
283
332
|
taskRoleInlinePolicies?: pulumi.Input<pulumi.Input<RoleInlinePolicy>[]>;
|
|
333
|
+
tags?: pulumi.Input<{
|
|
334
|
+
[key: string]: pulumi.Input<string>;
|
|
335
|
+
}>;
|
|
284
336
|
};
|
|
285
337
|
```
|
|
286
338
|
|
|
@@ -310,7 +362,7 @@ aws ecs execute-command \
|
|
|
310
362
|
--interactive
|
|
311
363
|
```
|
|
312
364
|
|
|
313
|
-
Where
|
|
365
|
+
Where `CLUSTER_NAME` is the name of the ECS cluster and `TASK_FAMILY_NAME` is the name of the task family that task belongs to.
|
|
314
366
|
|
|
315
367
|
## SSM Connect
|
|
316
368
|
|
|
@@ -38,6 +38,12 @@ export type DatabaseArgs = {
|
|
|
38
38
|
* The instance type of the RDS instance.
|
|
39
39
|
*/
|
|
40
40
|
instanceClass?: pulumi.Input<string>;
|
|
41
|
+
/**
|
|
42
|
+
* A map of tags to assign to the resource.
|
|
43
|
+
*/
|
|
44
|
+
tags?: pulumi.Input<{
|
|
45
|
+
[key: string]: pulumi.Input<string>;
|
|
46
|
+
}>;
|
|
41
47
|
};
|
|
42
48
|
export declare class Database extends pulumi.ComponentResource {
|
|
43
49
|
instance: aws.rds.Instance;
|
|
@@ -4,6 +4,9 @@ import * as awsx from '@pulumi/awsx';
|
|
|
4
4
|
export type Ec2SSMConnectArgs = {
|
|
5
5
|
vpc: awsx.ec2.Vpc;
|
|
6
6
|
sshPublicKey: pulumi.Input<string>;
|
|
7
|
+
tags?: pulumi.Input<{
|
|
8
|
+
[key: string]: pulumi.Input<string>;
|
|
9
|
+
}>;
|
|
7
10
|
};
|
|
8
11
|
export declare class Ec2SSMConnect extends pulumi.ComponentResource {
|
|
9
12
|
ec2SecurityGroup: aws.ec2.SecurityGroup;
|
|
@@ -67,9 +67,7 @@ class Ec2SSMConnect extends pulumi.ComponentResource {
|
|
|
67
67
|
iamInstanceProfile: ssmProfile.name,
|
|
68
68
|
subnetId,
|
|
69
69
|
vpcSecurityGroupIds: [this.ec2SecurityGroup.id],
|
|
70
|
-
tags: {
|
|
71
|
-
Name: `${name}-ec2`,
|
|
72
|
-
},
|
|
70
|
+
tags: Object.assign({ Name: `${name}-ec2` }, args.tags),
|
|
73
71
|
}, { parent: this });
|
|
74
72
|
this.ssmVpcEndpoint = new aws.ec2.VpcEndpoint(`${name}-ssm-vpc-endpoint`, {
|
|
75
73
|
vpcId: args.vpc.vpcId,
|
|
@@ -18,17 +18,17 @@ type ServiceArgs = {
|
|
|
18
18
|
};
|
|
19
19
|
export type DatabaseService = {
|
|
20
20
|
type: 'DATABASE';
|
|
21
|
-
} & ServiceArgs & Omit<DatabaseArgs, 'vpc'>;
|
|
21
|
+
} & ServiceArgs & Omit<DatabaseArgs, 'vpc' | 'tags'>;
|
|
22
22
|
export type RedisService = {
|
|
23
23
|
type: 'REDIS';
|
|
24
24
|
} & ServiceArgs & Pick<RedisArgs, 'dbName' | 'region'>;
|
|
25
25
|
export type StaticSiteService = {
|
|
26
26
|
type: 'STATIC_SITE';
|
|
27
|
-
} & ServiceArgs & Omit<StaticSiteArgs, 'hostedZoneId'>;
|
|
27
|
+
} & ServiceArgs & Omit<StaticSiteArgs, 'hostedZoneId' | 'tags'>;
|
|
28
28
|
export type WebServerService = {
|
|
29
29
|
type: 'WEB_SERVER';
|
|
30
30
|
environment?: aws.ecs.KeyValuePair[] | ((services: Services) => aws.ecs.KeyValuePair[]);
|
|
31
|
-
} & ServiceArgs & Omit<WebServerArgs, 'cluster' | 'vpc' | 'hostedZoneId' | 'environment'>;
|
|
31
|
+
} & ServiceArgs & Omit<WebServerArgs, 'cluster' | 'vpc' | 'hostedZoneId' | 'environment' | 'tags'>;
|
|
32
32
|
export type Environment = (typeof Environment)[keyof typeof Environment];
|
|
33
33
|
export type ProjectArgs = {
|
|
34
34
|
services: (DatabaseService | RedisService | StaticSiteService | WebServerService)[];
|
|
@@ -44,6 +44,9 @@ class Project extends pulumi.ComponentResource {
|
|
|
44
44
|
this.ec2SSMConnect = new ec2_ssm_connect_1.Ec2SSMConnect(`${name}-ssm-connect`, {
|
|
45
45
|
vpc: this.vpc,
|
|
46
46
|
sshPublicKey: sshConfig.require('publicKey'),
|
|
47
|
+
tags: {
|
|
48
|
+
Env: this.environment,
|
|
49
|
+
},
|
|
47
50
|
});
|
|
48
51
|
}
|
|
49
52
|
this.registerOutputs();
|
|
@@ -53,6 +56,9 @@ class Project extends pulumi.ComponentResource {
|
|
|
53
56
|
numberOfAvailabilityZones: 2,
|
|
54
57
|
enableDnsHostnames: true,
|
|
55
58
|
enableDnsSupport: true,
|
|
59
|
+
tags: {
|
|
60
|
+
Env: this.environment,
|
|
61
|
+
},
|
|
56
62
|
}, { parent: this });
|
|
57
63
|
return vpc;
|
|
58
64
|
}
|
|
@@ -82,11 +88,18 @@ class Project extends pulumi.ComponentResource {
|
|
|
82
88
|
});
|
|
83
89
|
}
|
|
84
90
|
createWebServerPrerequisites() {
|
|
85
|
-
this.cluster = new aws.ecs.Cluster(`${this.name}-cluster`, {
|
|
91
|
+
this.cluster = new aws.ecs.Cluster(`${this.name}-cluster`, {
|
|
92
|
+
name: this.name,
|
|
93
|
+
tags: {
|
|
94
|
+
Env: this.environment,
|
|
95
|
+
},
|
|
96
|
+
}, { parent: this });
|
|
86
97
|
}
|
|
87
98
|
createDatabaseService(options) {
|
|
88
99
|
const { serviceName, type } = options, databaseOptions = __rest(options, ["serviceName", "type"]);
|
|
89
|
-
const service = new database_1.Database(serviceName, Object.assign(Object.assign({}, databaseOptions), { vpc: this.vpc
|
|
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
103
|
this.services[serviceName] = service;
|
|
91
104
|
}
|
|
92
105
|
createRedisService(options) {
|
|
@@ -103,7 +116,9 @@ class Project extends pulumi.ComponentResource {
|
|
|
103
116
|
const { serviceName } = options, staticSiteOptions = __rest(options, ["serviceName"]);
|
|
104
117
|
if (!this.hostedZoneId)
|
|
105
118
|
throw new MissingHostedZoneId(options.type);
|
|
106
|
-
const service = new static_site_1.StaticSite(serviceName, Object.assign(Object.assign({}, staticSiteOptions), { hostedZoneId: this.hostedZoneId
|
|
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
122
|
this.services[serviceName] = service;
|
|
108
123
|
}
|
|
109
124
|
createWebServerService(options) {
|
|
@@ -115,7 +130,9 @@ class Project extends pulumi.ComponentResource {
|
|
|
115
130
|
const parsedEnv = typeof environment === 'function'
|
|
116
131
|
? environment(this.services)
|
|
117
132
|
: environment;
|
|
118
|
-
const service = new web_server_1.WebServer(serviceName, Object.assign(Object.assign({}, ecsOptions), { cluster: this.cluster, vpc: this.vpc, hostedZoneId: this.hostedZoneId, environment: parsedEnv
|
|
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
136
|
this.services[options.serviceName] = service;
|
|
120
137
|
}
|
|
121
138
|
}
|
|
@@ -11,6 +11,12 @@ export type StaticSiteArgs = {
|
|
|
11
11
|
* The ID of the hosted zone.
|
|
12
12
|
*/
|
|
13
13
|
hostedZoneId: pulumi.Input<string>;
|
|
14
|
+
/**
|
|
15
|
+
* A map of tags to assign to the resource.
|
|
16
|
+
*/
|
|
17
|
+
tags?: pulumi.Input<{
|
|
18
|
+
[key: string]: pulumi.Input<string>;
|
|
19
|
+
}>;
|
|
14
20
|
};
|
|
15
21
|
export declare class StaticSite extends pulumi.ComponentResource {
|
|
16
22
|
certificate: AcmCertificate;
|
|
@@ -17,6 +17,7 @@ class StaticSite extends pulumi.ComponentResource {
|
|
|
17
17
|
indexDocument: 'index.html',
|
|
18
18
|
errorDocument: 'index.html',
|
|
19
19
|
},
|
|
20
|
+
tags: args.tags,
|
|
20
21
|
}, { parent: this });
|
|
21
22
|
const bucketPublicAccessBlock = new aws.s3.BucketPublicAccessBlock(`${name}-bucket-access-block`, {
|
|
22
23
|
bucket: bucket.id,
|
|
@@ -86,6 +87,7 @@ class StaticSite extends pulumi.ComponentResource {
|
|
|
86
87
|
restrictions: {
|
|
87
88
|
geoRestriction: { restrictionType: 'none' },
|
|
88
89
|
},
|
|
90
|
+
tags: args.tags,
|
|
89
91
|
}, { parent: this });
|
|
90
92
|
const cdnAliasRecord = new aws.route53.Record(`${name}-cdn-route53-record`, {
|
|
91
93
|
type: 'A',
|
|
@@ -70,6 +70,12 @@ export type WebServerArgs = {
|
|
|
70
70
|
healtCheckPath?: pulumi.Input<string>;
|
|
71
71
|
taskExecutionRoleInlinePolicies?: pulumi.Input<pulumi.Input<RoleInlinePolicy>[]>;
|
|
72
72
|
taskRoleInlinePolicies?: pulumi.Input<pulumi.Input<RoleInlinePolicy>[]>;
|
|
73
|
+
/**
|
|
74
|
+
* A map of tags to assign to the resource.
|
|
75
|
+
*/
|
|
76
|
+
tags?: pulumi.Input<{
|
|
77
|
+
[key: string]: pulumi.Input<string>;
|
|
78
|
+
}>;
|
|
73
79
|
};
|
|
74
80
|
export declare class WebServer extends pulumi.ComponentResource {
|
|
75
81
|
certificate: AcmCertificate;
|
|
@@ -138,7 +138,7 @@ class WebServer extends pulumi.ComponentResource {
|
|
|
138
138
|
inlinePolicies: argsWithDefaults.taskExecutionRoleInlinePolicies,
|
|
139
139
|
}, { parent: this });
|
|
140
140
|
const execCmdInlinePolicy = {
|
|
141
|
-
name:
|
|
141
|
+
name: `${name}-ecs-exec`,
|
|
142
142
|
policy: JSON.stringify({
|
|
143
143
|
Version: '2012-10-17',
|
|
144
144
|
Statement: [
|
|
@@ -219,6 +219,7 @@ class WebServer extends pulumi.ComponentResource {
|
|
|
219
219
|
},
|
|
220
220
|
]);
|
|
221
221
|
}),
|
|
222
|
+
tags: argsWithDefaults.tags,
|
|
222
223
|
}, { parent: this });
|
|
223
224
|
this.serviceSecurityGroup = new aws.ec2.SecurityGroup(`${name}-security-group`, {
|
|
224
225
|
vpcId: argsWithDefaults.vpc.vpcId,
|
|
@@ -258,6 +259,7 @@ class WebServer extends pulumi.ComponentResource {
|
|
|
258
259
|
subnets: argsWithDefaults.vpc.publicSubnetIds,
|
|
259
260
|
securityGroups: [this.serviceSecurityGroup.id],
|
|
260
261
|
},
|
|
262
|
+
tags: argsWithDefaults.tags,
|
|
261
263
|
}, {
|
|
262
264
|
parent: this,
|
|
263
265
|
dependsOn: [
|