@fy-stack/fullstack-construct 0.0.129 → 0.0.130
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.
|
@@ -6,18 +6,22 @@ import { DatabaseConstruct } from '@fy-stack/database-construct';
|
|
|
6
6
|
import { EventConstruct } from '@fy-stack/event-construct';
|
|
7
7
|
import { SecretsConstruct } from '@fy-stack/secret-construct';
|
|
8
8
|
import { StorageConstruct } from '@fy-stack/storage-construct';
|
|
9
|
+
import { TaskConstruct } from '@fy-stack/task-construct';
|
|
10
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
9
11
|
import { Construct } from 'constructs';
|
|
10
12
|
import { FullStackConstructProps } from './types';
|
|
11
13
|
/**
|
|
12
14
|
*
|
|
13
15
|
*/
|
|
14
16
|
export declare class FullStackConstruct extends Construct {
|
|
17
|
+
vpc: ec2.IVpc;
|
|
15
18
|
auth?: AuthConstruct;
|
|
16
19
|
storage?: StorageConstruct;
|
|
17
20
|
storagePolicy?: string;
|
|
18
21
|
database?: DatabaseConstruct;
|
|
19
22
|
event?: EventConstruct;
|
|
20
23
|
apps?: Record<string, AppConstruct>;
|
|
24
|
+
tasks?: Record<string, TaskConstruct>;
|
|
21
25
|
cdn?: CDNConstruct;
|
|
22
26
|
api?: ApiGatewayConstruct;
|
|
23
27
|
secret: SecretsConstruct;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fullstack-construct.d.ts","sourceRoot":"","sources":["../../src/lib/fullstack-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EACL,KAAK,YAAY,EAOlB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;A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,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACtC,GAAG,CAAC,EAAE,YAAY,CAAC;IACnB,GAAG,CAAC,EAAE,mBAAmB,CAAC;IAC1B,MAAM,EAAE,gBAAgB,CAAC;gBAEpB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,uBAAuB;CAsLzE"}
|
|
@@ -10,7 +10,10 @@ const database_construct_1 = require("@fy-stack/database-construct");
|
|
|
10
10
|
const event_construct_1 = require("@fy-stack/event-construct");
|
|
11
11
|
const secret_construct_1 = require("@fy-stack/secret-construct");
|
|
12
12
|
const storage_construct_1 = require("@fy-stack/storage-construct");
|
|
13
|
+
const task_construct_1 = require("@fy-stack/task-construct");
|
|
14
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
13
15
|
const ec2 = tslib_1.__importStar(require("aws-cdk-lib/aws-ec2"));
|
|
16
|
+
const ecs = tslib_1.__importStar(require("aws-cdk-lib/aws-ecs"));
|
|
14
17
|
const constructs_1 = require("constructs");
|
|
15
18
|
const types_1 = require("./types");
|
|
16
19
|
const AppBuilds = {
|
|
@@ -25,18 +28,20 @@ const AppBuilds = {
|
|
|
25
28
|
*
|
|
26
29
|
*/
|
|
27
30
|
class FullStackConstruct extends constructs_1.Construct {
|
|
31
|
+
vpc;
|
|
28
32
|
auth;
|
|
29
33
|
storage;
|
|
30
34
|
storagePolicy;
|
|
31
35
|
database;
|
|
32
36
|
event;
|
|
33
37
|
apps;
|
|
38
|
+
tasks;
|
|
34
39
|
cdn;
|
|
35
40
|
api;
|
|
36
41
|
secret;
|
|
37
42
|
constructor(scope, id, props) {
|
|
38
43
|
super(scope, id);
|
|
39
|
-
|
|
44
|
+
this.vpc = ec2.Vpc.fromLookup(this, 'VPC', props.vpcId ? { vpcId: props.vpcId } : { isDefault: true });
|
|
40
45
|
if (props.auth) {
|
|
41
46
|
this.auth = new auth_construct_1.AuthConstruct(this, props.appId + 'AuthConstruct', {
|
|
42
47
|
groups: props.auth.groups,
|
|
@@ -49,7 +54,7 @@ class FullStackConstruct extends constructs_1.Construct {
|
|
|
49
54
|
if (props.database) {
|
|
50
55
|
this.database = new database_construct_1.DatabaseConstruct(this, 'DatabaseConstruct', {
|
|
51
56
|
...props.database,
|
|
52
|
-
vpcId: vpc.vpcId,
|
|
57
|
+
vpcId: this.vpc.vpcId,
|
|
53
58
|
});
|
|
54
59
|
}
|
|
55
60
|
if (props.apps) {
|
|
@@ -59,17 +64,33 @@ class FullStackConstruct extends constructs_1.Construct {
|
|
|
59
64
|
return [
|
|
60
65
|
key,
|
|
61
66
|
new AppTypeConstruct(this, `${key}App`, {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
// @ts-expect-error invalid params
|
|
68
|
+
buildParams: AppTypeConstruct.parse(app.buildParams ?? {}),
|
|
69
|
+
vpc: this.vpc,
|
|
70
|
+
...app
|
|
65
71
|
}),
|
|
66
72
|
];
|
|
67
73
|
})));
|
|
68
74
|
this.apps = apps;
|
|
69
75
|
}
|
|
76
|
+
if (props.task) {
|
|
77
|
+
const tasks = {};
|
|
78
|
+
const cluster = new ecs.Cluster(this, 'AppCluster', { vpc: this.vpc });
|
|
79
|
+
Object.assign(tasks, Object.fromEntries(Object.entries(props.task).map(([key, task]) => {
|
|
80
|
+
return [
|
|
81
|
+
key,
|
|
82
|
+
new task_construct_1.TaskConstruct(this, `${key}Task`, {
|
|
83
|
+
clusterArn: cluster.clusterArn,
|
|
84
|
+
vpc: this.vpc,
|
|
85
|
+
...task
|
|
86
|
+
}),
|
|
87
|
+
];
|
|
88
|
+
})));
|
|
89
|
+
this.tasks = tasks;
|
|
90
|
+
}
|
|
70
91
|
if (props.events) {
|
|
71
92
|
this.event = new event_construct_1.EventConstruct(this, 'EventConstruct', {
|
|
72
|
-
resources: this.apps,
|
|
93
|
+
resources: { ...this.apps, ...this.tasks },
|
|
73
94
|
events: props.events,
|
|
74
95
|
});
|
|
75
96
|
}
|
|
@@ -88,12 +109,22 @@ class FullStackConstruct extends constructs_1.Construct {
|
|
|
88
109
|
domains: props.cdn.domains,
|
|
89
110
|
resources: { ...this.apps, uploads: this.storage },
|
|
90
111
|
});
|
|
112
|
+
new aws_cdk_lib_1.CfnOutput(this, 'CDN Url', {
|
|
113
|
+
key: 'cdnURl',
|
|
114
|
+
value: 'https://' + this.cdn.distribution.domainName,
|
|
115
|
+
});
|
|
91
116
|
}
|
|
92
117
|
if (props.api) {
|
|
93
118
|
this.api = new apigateway_construct_1.ApiGatewayConstruct(this, 'ApiConstruct', {
|
|
94
119
|
routes: props.api.routes,
|
|
95
120
|
resources: this.apps,
|
|
96
121
|
});
|
|
122
|
+
if (this.api.api.url) {
|
|
123
|
+
new aws_cdk_lib_1.CfnOutput(this, 'Api Url', {
|
|
124
|
+
key: 'apiUrl',
|
|
125
|
+
value: this.api.api.url,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
97
128
|
}
|
|
98
129
|
const resources = {
|
|
99
130
|
storage: this.storage,
|
|
@@ -104,6 +135,10 @@ class FullStackConstruct extends constructs_1.Construct {
|
|
|
104
135
|
};
|
|
105
136
|
if (this.storage && this.cdn) {
|
|
106
137
|
this.storagePolicy = JSON.stringify(this.storage.cloudfrontPolicy(this.cdn.distribution.distributionId));
|
|
138
|
+
new aws_cdk_lib_1.CfnOutput(this, 'StorageBucketCDNPolicy', {
|
|
139
|
+
key: 'storageBucketCDNPolicy',
|
|
140
|
+
value: this.storagePolicy
|
|
141
|
+
});
|
|
107
142
|
}
|
|
108
143
|
for (const i in props.apps) {
|
|
109
144
|
const attachments = Object.entries(props.apps[i]?.attachment ?? {})
|
|
@@ -119,6 +154,20 @@ class FullStackConstruct extends constructs_1.Construct {
|
|
|
119
154
|
this.apps?.[i]?.grant(...grants);
|
|
120
155
|
}
|
|
121
156
|
}
|
|
157
|
+
for (const i in props.task) {
|
|
158
|
+
const attachments = Object.entries(props.task[i]?.attachment ?? {})
|
|
159
|
+
.map(([key]) => [key, resources[key]])
|
|
160
|
+
.filter((v) => !!v);
|
|
161
|
+
if (attachments.length) {
|
|
162
|
+
this.tasks?.[i]?.attach(Object.fromEntries(attachments));
|
|
163
|
+
}
|
|
164
|
+
const grants = props.task[i]?.grant
|
|
165
|
+
?.map((val) => resources[val])
|
|
166
|
+
.filter((v) => !!v) ?? [];
|
|
167
|
+
if (grants.length) {
|
|
168
|
+
this.tasks?.[i]?.grant(...grants);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
122
171
|
}
|
|
123
172
|
}
|
|
124
173
|
exports.FullStackConstruct = FullStackConstruct;
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { CDNConstructProps } from '@fy-stack/cdn-construct';
|
|
1
2
|
import { DatabaseConstructProps } from '@fy-stack/database-construct';
|
|
3
|
+
import { TaskConstructsProps } from '@fy-stack/task-construct';
|
|
2
4
|
import { ResourceRef } from '@fy-stack/types';
|
|
3
5
|
import * as events from 'aws-cdk-lib/aws-events';
|
|
4
|
-
import { CDNConstructProps } from '@fy-stack/cdn-construct';
|
|
5
6
|
export declare enum AppType {
|
|
6
7
|
NODE_APP = "nodeApp",
|
|
7
8
|
NODE_API = "nestApi",
|
|
@@ -31,7 +32,12 @@ export type App = {
|
|
|
31
32
|
output: string;
|
|
32
33
|
attachment?: AppAttachment;
|
|
33
34
|
grant?: AppGrant[];
|
|
34
|
-
|
|
35
|
+
env?: Record<string, string>;
|
|
36
|
+
buildParams?: Record<string, unknown>;
|
|
37
|
+
};
|
|
38
|
+
export type Task = Omit<TaskConstructsProps, "clusterArn" | "vpc"> & {
|
|
39
|
+
attachment?: AppAttachment;
|
|
40
|
+
grant?: AppGrant[];
|
|
35
41
|
};
|
|
36
42
|
export type AppMessage = ResourceRef & {
|
|
37
43
|
messages: string[];
|
|
@@ -60,5 +66,6 @@ export type FullStackConstructProps = {
|
|
|
60
66
|
routes: Record<string, ResourceRef>;
|
|
61
67
|
};
|
|
62
68
|
secrets?: Record<string, string | undefined>;
|
|
69
|
+
task?: Record<string, Task>;
|
|
63
70
|
};
|
|
64
71
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,oBAAY,OAAO;IACjB,QAAQ,YAAY;IACpB,QAAQ,YAAY;IACpB,SAAS,aAAa;IACtB,eAAe,kBAAkB;IACjC,gBAAgB,mBAAmB;IACnC,cAAc,kBAAkB;CACjC;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAChC,CAAC;AAEF,oBAAY,QAAQ;IAClB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB;AAED,MAAM,MAAM,GAAG,GAAG;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3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AAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CAC7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fy-stack/fullstack-construct",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.130",
|
|
4
|
+
"repository": "https://github.com/festusyuma/fy-stack",
|
|
4
5
|
"dependencies": {
|
|
5
|
-
"
|
|
6
|
-
"@fy-stack/
|
|
7
|
-
"@fy-stack/
|
|
8
|
-
"@fy-stack/
|
|
9
|
-
"@fy-stack/
|
|
10
|
-
"@fy-stack/
|
|
11
|
-
"@fy-stack/
|
|
12
|
-
"@fy-stack/
|
|
13
|
-
"@fy-stack/
|
|
14
|
-
"@fy-stack/
|
|
6
|
+
"@fy-stack/apigateway-construct": "0.0.130",
|
|
7
|
+
"@fy-stack/app-construct": "0.0.130",
|
|
8
|
+
"@fy-stack/auth-construct": "0.0.130",
|
|
9
|
+
"@fy-stack/cdn-construct": "0.0.130",
|
|
10
|
+
"@fy-stack/database-construct": "0.0.130",
|
|
11
|
+
"@fy-stack/event-construct": "0.0.130",
|
|
12
|
+
"@fy-stack/secret-construct": "0.0.130",
|
|
13
|
+
"@fy-stack/storage-construct": "0.0.130",
|
|
14
|
+
"@fy-stack/task-construct": "0.0.130",
|
|
15
|
+
"@fy-stack/types": "0.0.130",
|
|
16
|
+
"tslib": "^2.3.0"
|
|
15
17
|
},
|
|
16
18
|
"peerDependencies": {
|
|
17
|
-
"aws-cdk-lib": "2.
|
|
18
|
-
"constructs": "10.4.2"
|
|
19
|
+
"aws-cdk-lib": "^2.174.1",
|
|
20
|
+
"constructs": "^10.4.2"
|
|
19
21
|
},
|
|
20
22
|
"type": "commonjs",
|
|
21
23
|
"main": "./dist/index.js",
|