@fy-stack/fullstack-construct 0.0.143 → 0.0.144
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 +68 -57
- package/dist/lib/fullstack-construct.d.ts.map +1 -1
- package/dist/lib/fullstack-construct.js +53 -49
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -1,64 +1,75 @@
|
|
|
1
1
|
# Fullstack Construct Documentation
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Overview
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
The Fullstack Construct is a high-level AWS CDK construct that enables deploying full-stack applications to AWS infrastructure. It provides an integrated solution for deploying various types of applications with their associated infrastructure.
|
|
6
|
+
|
|
7
|
+
## Supported Application Types
|
|
8
|
+
|
|
9
|
+
### 1. Static Applications
|
|
10
|
+
- **Static Website** (`AppType.STATIC_WEBSITE`)
|
|
11
|
+
- Simple static websites with HTML, CSS, and JavaScript
|
|
12
|
+
- Deployed to S3 and served via CloudFront
|
|
13
|
+
|
|
14
|
+
### 2. Next.js Applications
|
|
15
|
+
- **Next.js Pages Export** (`AppType.NEXT_PAGE_EXPORT`)
|
|
16
|
+
- Static export mode of Next.js applications
|
|
17
|
+
- Optimized for static site generation
|
|
18
|
+
- **Next.js App Router** (`AppType.NEXT_APP_ROUTER`)
|
|
19
|
+
- Support for the newer App Router architecture
|
|
20
|
+
- Includes handling for server components
|
|
21
|
+
|
|
22
|
+
### 3. Node.js Applications
|
|
23
|
+
- **Node App** (`AppType.NODE_APP`)
|
|
24
|
+
- General purpose Node.js applications
|
|
25
|
+
- Deployable as containers or Lambda functions
|
|
26
|
+
- **Node API** (`AppType.NODE_API`)
|
|
27
|
+
- Specialized for NestJS API applications
|
|
28
|
+
- Includes API Gateway integration
|
|
29
|
+
|
|
30
|
+
### 4. Container Applications
|
|
31
|
+
- **Image App** (`AppType.IMAGE_APP`)
|
|
32
|
+
- Docker container-based applications
|
|
33
|
+
- Deployable to ECS with Fargate
|
|
34
|
+
|
|
35
|
+
## Deployment Options
|
|
12
36
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
attachment: { secrets: true, queue: { batchSize: 10 } },
|
|
28
|
-
grant: [AppGrant.SECRETS],
|
|
29
|
-
},
|
|
30
|
-
web: {
|
|
31
|
-
type: AppType.NEXT_PAGE_EXPORT,
|
|
32
|
-
output: process.cwd() + '/dist/apps/web',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
secrets: {
|
|
36
|
-
SOME_OTHER_ENV: "envValue"
|
|
37
|
-
},
|
|
38
|
-
events: {
|
|
39
|
-
messages: [
|
|
40
|
-
{ messages: [EventType.DAILY_SPOOL], $resource: 'eventHandler' },
|
|
41
|
-
],
|
|
42
|
-
cron: [
|
|
43
|
-
{
|
|
44
|
-
messages: [EventType.DAILY_SPOOL],
|
|
45
|
-
cron: { hour: '0', minute: '0' },
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
},
|
|
49
|
-
cdn: {
|
|
50
|
-
routes: {
|
|
51
|
-
'/*': { $resource: 'web' },
|
|
52
|
-
},
|
|
53
|
-
domains: [
|
|
54
|
-
{ domain: 'example.com', records: ['*', 'www'] },
|
|
55
|
-
{ domain: 'example.com.ng', records: ['*', 'www'] },
|
|
56
|
-
],
|
|
57
|
-
},
|
|
58
|
-
api: {
|
|
59
|
-
routes: {
|
|
60
|
-
'/*': { $resource: 'api' },
|
|
37
|
+
### 1. Lambda Deployment
|
|
38
|
+
- Suitable for serverless applications
|
|
39
|
+
- Configurable memory and timeout settings
|
|
40
|
+
- Environment variable support
|
|
41
|
+
- Example configuration:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
{
|
|
45
|
+
type: AppType.NODE_API,
|
|
46
|
+
buildParams: {
|
|
47
|
+
memorySize: 512,
|
|
48
|
+
timeout: 30,
|
|
49
|
+
environment: {
|
|
50
|
+
NODE_ENV: 'production'
|
|
61
51
|
}
|
|
62
52
|
}
|
|
63
|
-
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
### 2. ECS Deployment
|
|
58
|
+
- Container-based deployment with Fargate
|
|
59
|
+
- Supports both service and task patterns
|
|
60
|
+
- Load balancer integration
|
|
61
|
+
- Example configuration:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
{
|
|
65
|
+
server: {
|
|
66
|
+
apps: {
|
|
67
|
+
api: {
|
|
68
|
+
type: AppType.NODE_API,
|
|
69
|
+
// ECS-specific configuration
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
loadBalancer: {
|
|
73
|
+
// Load balancer configuration
|
|
74
|
+
} }, tasks: { // Background task configurations } }
|
|
64
75
|
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fullstack-construct.d.ts","sourceRoot":"","sources":["../../src/lib/fullstack-construct.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EAChB,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;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC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,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE;IAW5C,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM;CAgB/B"}
|
|
@@ -51,25 +51,6 @@ class FullStackConstruct extends constructs_1.Construct {
|
|
|
51
51
|
vpcId: this.vpc.vpcId,
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
this.secret = new secret_construct_1.SecretsConstruct(this, 'SecretConstruct', {
|
|
55
|
-
resources: {
|
|
56
|
-
auth: this.auth,
|
|
57
|
-
database: this.database,
|
|
58
|
-
storage: this.storage,
|
|
59
|
-
event: this.event,
|
|
60
|
-
},
|
|
61
|
-
secrets: {
|
|
62
|
-
REGION: aws_cdk_lib_1.Stack.of(this).region,
|
|
63
|
-
ENVIRONMENT: props.environment,
|
|
64
|
-
...props.secret,
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
if (props.outputs) {
|
|
68
|
-
new aws_cdk_lib_1.CfnOutput(this, 'SecretsName', {
|
|
69
|
-
key: 'appSecrets',
|
|
70
|
-
value: this.secret.secrets.secretName,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
54
|
if (props.ecs) {
|
|
74
55
|
this.ecs = new app_construct_1.EcsConstruct(this, 'EcsConstruct', {
|
|
75
56
|
vpc: this.vpc,
|
|
@@ -77,36 +58,12 @@ class FullStackConstruct extends constructs_1.Construct {
|
|
|
77
58
|
environment: props.environment,
|
|
78
59
|
...props.ecs,
|
|
79
60
|
});
|
|
80
|
-
if (this.ecs.server) {
|
|
81
|
-
this.fromGrants(this.ecs.server, props.ecs.server?.grants);
|
|
82
|
-
for (const i in this.ecs.server.apps) {
|
|
83
|
-
if (!props.ecs.server?.apps[i].attachment)
|
|
84
|
-
continue;
|
|
85
|
-
this.fromAttachments(this.ecs.server.apps[i], props.ecs.server.apps[i].attachment);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
for (const i in this.ecs.tasks) {
|
|
89
|
-
if (props.ecs.tasks[i]?.grants) {
|
|
90
|
-
this.fromGrants(this.ecs.tasks[i], props.ecs.tasks[i]?.grants);
|
|
91
|
-
}
|
|
92
|
-
if (props.ecs.tasks[i]?.attachment) {
|
|
93
|
-
this.fromAttachments(this.ecs.tasks[i], props.ecs.tasks[i]?.attachment);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
61
|
}
|
|
97
62
|
if (props.lambda) {
|
|
98
63
|
this.lambda = new app_construct_1.LambdaConstruct(this, 'LambdaConstruct', {
|
|
99
64
|
vpc: this.vpc,
|
|
100
65
|
apps: props.lambda,
|
|
101
66
|
});
|
|
102
|
-
for (const i in this.lambda.apps) {
|
|
103
|
-
if (props.lambda[i].attachment) {
|
|
104
|
-
this.fromAttachments(this.lambda.apps[i], props.lambda[i].attachment);
|
|
105
|
-
}
|
|
106
|
-
if (props.lambda[i].grants) {
|
|
107
|
-
this.fromGrants(this.lambda.apps[i], props.lambda[i].grants);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
67
|
}
|
|
111
68
|
if (props.static) {
|
|
112
69
|
this.static = new app_construct_1.StaticConstruct(this, 'StaticConstruct', {
|
|
@@ -155,14 +112,61 @@ class FullStackConstruct extends constructs_1.Construct {
|
|
|
155
112
|
});
|
|
156
113
|
}
|
|
157
114
|
}
|
|
115
|
+
this.secret = new secret_construct_1.SecretsConstruct(this, 'SecretConstruct', {
|
|
116
|
+
resources: {
|
|
117
|
+
auth: this.auth,
|
|
118
|
+
database: this.database,
|
|
119
|
+
storage: this.storage,
|
|
120
|
+
event: this.event,
|
|
121
|
+
cdn: this.cdn,
|
|
122
|
+
api: this.api,
|
|
123
|
+
},
|
|
124
|
+
secrets: {
|
|
125
|
+
REGION: aws_cdk_lib_1.Stack.of(this).region,
|
|
126
|
+
ENVIRONMENT: props.environment,
|
|
127
|
+
...props.secret,
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
if (props.outputs) {
|
|
131
|
+
new aws_cdk_lib_1.CfnOutput(this, 'SecretsName', {
|
|
132
|
+
key: 'appSecrets',
|
|
133
|
+
value: this.secret.secrets.secretName,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
if (this.ecs && props.ecs) {
|
|
137
|
+
if (this.ecs.server) {
|
|
138
|
+
this.fromGrants(this.ecs.server, props.ecs.server?.grants);
|
|
139
|
+
for (const i in this.ecs.server.apps) {
|
|
140
|
+
if (!props.ecs.server?.apps[i].attachment)
|
|
141
|
+
continue;
|
|
142
|
+
this.fromAttachments(this.ecs.server.apps[i], props.ecs.server.apps[i].attachment);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
for (const i in this.ecs.tasks) {
|
|
146
|
+
if (props.ecs.tasks[i]?.grants) {
|
|
147
|
+
this.fromGrants(this.ecs.tasks[i], props.ecs.tasks[i]?.grants);
|
|
148
|
+
}
|
|
149
|
+
if (props.ecs.tasks[i]?.attachment) {
|
|
150
|
+
this.fromAttachments(this.ecs.tasks[i], props.ecs.tasks[i]?.attachment);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (this.lambda && props.lambda) {
|
|
155
|
+
for (const i in this.lambda.apps) {
|
|
156
|
+
if (props.lambda[i].attachment) {
|
|
157
|
+
this.fromAttachments(this.lambda.apps[i], props.lambda[i].attachment);
|
|
158
|
+
}
|
|
159
|
+
if (props.lambda[i].grants) {
|
|
160
|
+
this.fromGrants(this.lambda.apps[i], props.lambda[i].grants);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
158
164
|
if (this.storage && this.cdn) {
|
|
159
165
|
this.storagePolicy = JSON.stringify(this.storage.cloudfrontPolicy(this.cdn.distribution.distributionId));
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
+
new aws_cdk_lib_1.CfnOutput(this, 'StorageBucketCDNPolicy', {
|
|
167
|
+
key: 'storageBucketCDNPolicy',
|
|
168
|
+
value: this.storagePolicy,
|
|
169
|
+
});
|
|
166
170
|
}
|
|
167
171
|
aws_cdk_lib_1.Tags.of(this).add('App', props.name);
|
|
168
172
|
aws_cdk_lib_1.Tags.of(this).add('Environment', props.environment);
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fy-stack/fullstack-construct",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.144",
|
|
4
4
|
"repository": "https://github.com/festusyuma/fy-stack",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@fy-stack/apigateway-construct": "0.0.
|
|
7
|
-
"@fy-stack/app-construct": "0.0.
|
|
8
|
-
"@fy-stack/auth-construct": "0.0.
|
|
9
|
-
"@fy-stack/cdn-construct": "0.0.
|
|
10
|
-
"@fy-stack/database-construct": "0.0.
|
|
11
|
-
"@fy-stack/event-construct": "0.0.
|
|
12
|
-
"@fy-stack/secret-construct": "0.0.
|
|
13
|
-
"@fy-stack/storage-construct": "0.0.
|
|
6
|
+
"@fy-stack/apigateway-construct": "0.0.144",
|
|
7
|
+
"@fy-stack/app-construct": "0.0.144",
|
|
8
|
+
"@fy-stack/auth-construct": "0.0.144",
|
|
9
|
+
"@fy-stack/cdn-construct": "0.0.144",
|
|
10
|
+
"@fy-stack/database-construct": "0.0.144",
|
|
11
|
+
"@fy-stack/event-construct": "0.0.144",
|
|
12
|
+
"@fy-stack/secret-construct": "0.0.144",
|
|
13
|
+
"@fy-stack/storage-construct": "0.0.144",
|
|
14
14
|
"tslib": "^2.3.0",
|
|
15
|
-
"@fy-stack/types": "0.0.
|
|
15
|
+
"@fy-stack/types": "0.0.144"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"aws-cdk-lib": "^2.198.0",
|