@fy-stack/app-construct 0.0.143 → 0.0.145
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/dist/lib/ecs/apps/next-app-router-construct.d.ts +1 -0
- package/dist/lib/ecs/apps/next-app-router-construct.d.ts.map +1 -1
- package/dist/lib/ecs/apps/next-app-router-construct.js +6 -6
- package/dist/lib/ecs/apps/task-construct.d.ts +1 -1
- package/dist/lib/ecs/apps/task-construct.d.ts.map +1 -1
- package/dist/lib/ecs/apps/task-construct.js +7 -7
- package/dist/lib/ecs/ecs-server-construct.d.ts +5 -2
- package/dist/lib/ecs/ecs-server-construct.d.ts.map +1 -1
- package/dist/lib/ecs/ecs-server-construct.js +7 -6
- package/dist/lib/lambda/apps/next-app-router-construct.d.ts +1 -0
- package/dist/lib/lambda/apps/next-app-router-construct.d.ts.map +1 -1
- package/dist/lib/lambda/apps/next-app-router-construct.js +6 -6
- package/dist/lib/shared/next-app-router.d.ts +12 -4
- package/dist/lib/shared/next-app-router.d.ts.map +1 -1
- package/dist/lib/shared/next-app-router.js +32 -17
- package/package.json +2 -2
|
@@ -11,6 +11,7 @@ export declare class NextAppRouterConstruct extends Construct implements AppCons
|
|
|
11
11
|
container: ecs.ContainerDefinition;
|
|
12
12
|
queue: sqs.Queue | undefined;
|
|
13
13
|
private readonly static;
|
|
14
|
+
private readonly files;
|
|
14
15
|
constructor(scope: Construct, id: string, props: NextAppRouterProps);
|
|
15
16
|
cloudfront(path: string): Record<string, cloudfront.BehaviorOptions>;
|
|
16
17
|
cloudfrontPolicy(distributionId: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-app-router-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/ecs/apps/next-app-router-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAA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I,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,eAAe,CAAC;IAcpE,gBAAgB,CAAC,cAAc,EAAE,MAAM;IAIvC,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAI3C,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;IAO7C,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;CAG7B"}
|
|
@@ -10,17 +10,20 @@ class NextAppRouterConstruct extends constructs_1.Construct {
|
|
|
10
10
|
container;
|
|
11
11
|
queue;
|
|
12
12
|
static;
|
|
13
|
+
files;
|
|
13
14
|
constructor(scope, id, props) {
|
|
14
15
|
super(scope, id);
|
|
15
16
|
this.props = props;
|
|
16
|
-
|
|
17
|
+
const deployment = (0, next_app_router_1.staticDeployment)(this, props.output);
|
|
18
|
+
this.static = deployment.staticBucket;
|
|
19
|
+
this.files = deployment.files;
|
|
17
20
|
this.container = (0, taskDefinitionImage_1.taskDefinitionImage)(`${props.appName}AppContainer`, {
|
|
18
21
|
taskDefinition: props.taskDefinition,
|
|
19
22
|
port: props.port,
|
|
20
23
|
env: props.env,
|
|
21
24
|
output: props.output,
|
|
22
25
|
container: props.container,
|
|
23
|
-
environmentPath: props.environmentPath
|
|
26
|
+
environmentPath: props.environmentPath,
|
|
24
27
|
});
|
|
25
28
|
}
|
|
26
29
|
cloudfront(path) {
|
|
@@ -28,10 +31,7 @@ class NextAppRouterConstruct extends constructs_1.Construct {
|
|
|
28
31
|
if (!origin)
|
|
29
32
|
throw new Error('No server origin');
|
|
30
33
|
this.container.addEnvironment('BASE_PATH', basePath);
|
|
31
|
-
return
|
|
32
|
-
...(0, next_app_router_1.serverCloudfrontBehaviour)(this, origin, path),
|
|
33
|
-
...(0, next_app_router_1.staticCloudfrontBehaviour)(this.static, path),
|
|
34
|
-
};
|
|
34
|
+
return (0, next_app_router_1.cloudfrontBehaviours)(this, this.static, origin, path, this.files);
|
|
35
35
|
}
|
|
36
36
|
cloudfrontPolicy(distributionId) {
|
|
37
37
|
throw new Error(`cloudfrontPolicy not supported for ${this}`);
|
|
@@ -6,7 +6,7 @@ import { Construct } from 'constructs';
|
|
|
6
6
|
import { TaskConstructsProps } from '../types';
|
|
7
7
|
export declare class TaskConstruct extends Construct implements EventResource, Grant, Attach {
|
|
8
8
|
private props;
|
|
9
|
-
|
|
9
|
+
definition: ecs.FargateTaskDefinition;
|
|
10
10
|
constructor(scope: Construct, id: string, props: TaskConstructsProps);
|
|
11
11
|
subscription(props: snsSubscription.SubscriptionProps): sns.ITopicSubscription;
|
|
12
12
|
grant(...grantables: Grantable[]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/ecs/apps/task-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,UAAU,EACV,aAAa,EACb,KAAK,EACL,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAI3C,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,eAAe,MAAM,mCAAmC,CAAC;AAErE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,qBAAa,aACX,SAAQ,SACR,YAAW,aAAa,EAAE,KAAK,EAAE,MAAM;IAOrC,OAAO,CAAC,KAAK;IALR,
|
|
1
|
+
{"version":3,"file":"task-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/ecs/apps/task-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,UAAU,EACV,aAAa,EACb,KAAK,EACL,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAI3C,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,eAAe,MAAM,mCAAmC,CAAC;AAErE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,qBAAa,aACX,SAAQ,SACR,YAAW,aAAa,EAAE,KAAK,EAAE,MAAM;IAOrC,OAAO,CAAC,KAAK;IALR,UAAU,EAAE,GAAG,CAAC,qBAAqB,CAAC;gBAG3C,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACF,KAAK,EAAE,mBAAmB;IAgCpC,YAAY,CACV,KAAK,EAAE,eAAe,CAAC,iBAAiB,GACvC,GAAG,CAAC,kBAAkB;IA6CzB,KAAK,CAAC,GAAG,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI;IAMvC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;IAS7C,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;CAG7B"}
|
|
@@ -13,12 +13,12 @@ const constructs_1 = require("constructs");
|
|
|
13
13
|
const params_from_attachable_1 = require("../../util/params-from-attachable");
|
|
14
14
|
class TaskConstruct extends constructs_1.Construct {
|
|
15
15
|
props;
|
|
16
|
-
|
|
16
|
+
definition;
|
|
17
17
|
constructor(scope, id, props) {
|
|
18
18
|
super(scope, id);
|
|
19
19
|
this.props = props;
|
|
20
20
|
const { container, output, ...definitionProps } = props;
|
|
21
|
-
this.
|
|
21
|
+
this.definition = new ecs.FargateTaskDefinition(this, 'Task', {
|
|
22
22
|
cpu: 256,
|
|
23
23
|
memoryLimitMiB: 512,
|
|
24
24
|
runtimePlatform: {
|
|
@@ -28,7 +28,7 @@ class TaskConstruct extends constructs_1.Construct {
|
|
|
28
28
|
});
|
|
29
29
|
if (container) {
|
|
30
30
|
const { image: imageProps, logDuration, ...containerProps } = container;
|
|
31
|
-
this.
|
|
31
|
+
this.definition.addContainer('DefaultImage', {
|
|
32
32
|
image: ecs.ContainerImage.fromAsset(output, {
|
|
33
33
|
platform: ecrAssets.Platform.LINUX_AMD64,
|
|
34
34
|
...imageProps,
|
|
@@ -53,7 +53,7 @@ class TaskConstruct extends constructs_1.Construct {
|
|
|
53
53
|
desiredState: 'RUNNING',
|
|
54
54
|
targetParameters: {
|
|
55
55
|
ecsTaskParameters: {
|
|
56
|
-
taskDefinitionArn: this.
|
|
56
|
+
taskDefinitionArn: this.definition.taskDefinitionArn,
|
|
57
57
|
launchType: 'FARGATE',
|
|
58
58
|
networkConfiguration: {
|
|
59
59
|
awsvpcConfiguration: {
|
|
@@ -76,7 +76,7 @@ class TaskConstruct extends constructs_1.Construct {
|
|
|
76
76
|
},
|
|
77
77
|
});
|
|
78
78
|
queue.grantConsumeMessages(pipeRole);
|
|
79
|
-
this.
|
|
79
|
+
this.definition.grantRun(pipeRole);
|
|
80
80
|
return new snsSubscription.SqsSubscription(queue, {
|
|
81
81
|
...props,
|
|
82
82
|
rawMessageDelivery: true,
|
|
@@ -84,14 +84,14 @@ class TaskConstruct extends constructs_1.Construct {
|
|
|
84
84
|
}
|
|
85
85
|
grant(...grantables) {
|
|
86
86
|
for (const i in grantables) {
|
|
87
|
-
grantables[i].grantable(this.
|
|
87
|
+
grantables[i].grantable(this.definition.taskRole);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
attach(attachable) {
|
|
91
91
|
const params = {};
|
|
92
92
|
Object.assign(params, ...(0, params_from_attachable_1.paramsFromAttachable)(attachable));
|
|
93
93
|
for (const i in params) {
|
|
94
|
-
this.
|
|
94
|
+
this.definition.defaultContainer?.addEnvironment(i, params[i]);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
static parse(params) {
|
|
@@ -13,8 +13,11 @@ type EcsServerConstructProps = EcsConstructProps['server'] & {
|
|
|
13
13
|
export declare class EcsServerConstruct extends Construct implements Grant {
|
|
14
14
|
private props;
|
|
15
15
|
apps: Record<string, AppConstruct>;
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
definition: ecs.TaskDefinition;
|
|
17
|
+
loadBalancer?: {
|
|
18
|
+
alb: elbV2.IApplicationLoadBalancer;
|
|
19
|
+
listener: elbV2.IApplicationListener;
|
|
20
|
+
};
|
|
18
21
|
constructor(scope: Construct, id: string, props: EcsServerConstructProps);
|
|
19
22
|
grant(...grantables: Grantable[]): void;
|
|
20
23
|
private serverOrigin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecs-server-construct.d.ts","sourceRoot":"","sources":["../../../src/lib/ecs/ecs-server-construct.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,KAAK,EAAE,SAAS,EAAgB,MAAM,iBAAiB,CAAC;AAG1E,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,wCAAwC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAO1D,KAAK,uBAAuB,GAAG,iBAAiB,CAAC,QAAQ,CAAC,GAAG;IAC3D,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC;CACtB,CAAC;AAEF,qBAAa,kBAAmB,SAAQ,SAAU,YAAW,KAAK;IAY9D,OAAO,CAAC,KAAK;IAXR,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAM;IAE/
|
|
1
|
+
{"version":3,"file":"ecs-server-construct.d.ts","sourceRoot":"","sources":["../../../src/lib/ecs/ecs-server-construct.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,KAAK,EAAE,SAAS,EAAgB,MAAM,iBAAiB,CAAC;AAG1E,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,wCAAwC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAO1D,KAAK,uBAAuB,GAAG,iBAAiB,CAAC,QAAQ,CAAC,GAAG;IAC3D,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC;CACtB,CAAC;AAEF,qBAAa,kBAAmB,SAAQ,SAAU,YAAW,KAAK;IAY9D,OAAO,CAAC,KAAK;IAXR,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAM;IACxC,UAAU,EAAE,GAAG,CAAC,cAAc,CAAC;IAE/B,YAAY,CAAC,EAAE;QACpB,GAAG,EAAE,KAAK,CAAC,wBAAwB,CAAC;QACpC,QAAQ,EAAE,KAAK,CAAC,oBAAoB,CAAC;KACtC,CAAC;gBAGA,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACF,KAAK,EAAE,uBAAuB;IAsExC,KAAK,CAAC,GAAG,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI;IAMvC,OAAO,CAAC,YAAY;IA8CpB,gBAAgB;;;;IAuChB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;CA+CxC"}
|
|
@@ -20,7 +20,7 @@ const AppBuilds = {
|
|
|
20
20
|
class EcsServerConstruct extends constructs_1.Construct {
|
|
21
21
|
props;
|
|
22
22
|
apps = {};
|
|
23
|
-
|
|
23
|
+
definition;
|
|
24
24
|
loadBalancer;
|
|
25
25
|
constructor(scope, id, props) {
|
|
26
26
|
super(scope, id);
|
|
@@ -29,7 +29,7 @@ class EcsServerConstruct extends constructs_1.Construct {
|
|
|
29
29
|
vpc: props.vpc,
|
|
30
30
|
});
|
|
31
31
|
const { definition, apps, cluster, ...serverProps } = props;
|
|
32
|
-
this.
|
|
32
|
+
this.definition = new ecs.FargateTaskDefinition(this, 'ServerTaskDefinition', {
|
|
33
33
|
cpu: 256,
|
|
34
34
|
memoryLimitMiB: 512,
|
|
35
35
|
runtimePlatform: {
|
|
@@ -40,7 +40,7 @@ class EcsServerConstruct extends constructs_1.Construct {
|
|
|
40
40
|
});
|
|
41
41
|
const service = new ecs.FargateService(this, 'ServerService', {
|
|
42
42
|
cluster,
|
|
43
|
-
taskDefinition: this.
|
|
43
|
+
taskDefinition: this.definition,
|
|
44
44
|
capacityProviderStrategies: [{ capacityProvider: 'FARGATE', weight: 1 }],
|
|
45
45
|
desiredCount: 1,
|
|
46
46
|
vpcSubnets: {
|
|
@@ -49,6 +49,7 @@ class EcsServerConstruct extends constructs_1.Construct {
|
|
|
49
49
|
: ec2.SubnetType.PRIVATE_WITH_EGRESS,
|
|
50
50
|
},
|
|
51
51
|
securityGroups: [appSecurityGroup],
|
|
52
|
+
propagateTags: ecs.PropagatedTagSource.SERVICE,
|
|
52
53
|
...serverProps,
|
|
53
54
|
});
|
|
54
55
|
const serverOrigin = (port, containerName, appPath, healthPath) => this.serverOrigin(service, port, containerName, appPath, healthPath);
|
|
@@ -62,7 +63,7 @@ class EcsServerConstruct extends constructs_1.Construct {
|
|
|
62
63
|
environmentPath: props.environmentPath,
|
|
63
64
|
buildParams: AppTypeConstruct.parse(app.buildParams ?? {}),
|
|
64
65
|
serverOrigin,
|
|
65
|
-
taskDefinition: this.
|
|
66
|
+
taskDefinition: this.definition,
|
|
66
67
|
...app,
|
|
67
68
|
}),
|
|
68
69
|
];
|
|
@@ -70,7 +71,7 @@ class EcsServerConstruct extends constructs_1.Construct {
|
|
|
70
71
|
}
|
|
71
72
|
grant(...grantables) {
|
|
72
73
|
for (const i in grantables) {
|
|
73
|
-
grantables[i].grantable(this.
|
|
74
|
+
grantables[i].grantable(this.definition.taskRole);
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
serverOrigin(service, port, containerName, appPath, healthPath) {
|
|
@@ -127,7 +128,7 @@ class EcsServerConstruct extends constructs_1.Construct {
|
|
|
127
128
|
const configPath = './fy-stack.context.json';
|
|
128
129
|
let config = {};
|
|
129
130
|
let priorityRage = [0, 1000];
|
|
130
|
-
if (this.props.loadBalancer &&
|
|
131
|
+
if (this.props.loadBalancer && 'priorityRange' in this.props.loadBalancer) {
|
|
131
132
|
priorityRage = this.props.loadBalancer.priorityRange;
|
|
132
133
|
}
|
|
133
134
|
let priority = priorityRage[0];
|
|
@@ -18,6 +18,7 @@ export declare class NextAppRouterConstruct extends Construct implements AppCons
|
|
|
18
18
|
function: lambda.Function;
|
|
19
19
|
queue: sqs.Queue | undefined;
|
|
20
20
|
private readonly static;
|
|
21
|
+
private readonly files;
|
|
21
22
|
constructor(scope: Construct, id: string, props: AppProperties<z.infer<typeof BuildParamsSchema>>);
|
|
22
23
|
cloudfront(path: string): Record<string, cloudfront.BehaviorOptions>;
|
|
23
24
|
cloudfrontPolicy(distributionId: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-app-router-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/apps/next-app-router-construct.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAEzD,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,CA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EACV,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAwCzD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,eAAe,CAAC;IAiBpE,gBAAgB,CAAC,cAAc,EAAE,MAAM;IAIvC,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAI3C,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;IAI7C,KAAK,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE;IAI5B,YAAY,IAAI,kBAAkB;IAIlC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;;;CAG7B"}
|
|
@@ -19,11 +19,14 @@ class NextAppRouterConstruct extends constructs_1.Construct {
|
|
|
19
19
|
function;
|
|
20
20
|
queue;
|
|
21
21
|
static;
|
|
22
|
+
files;
|
|
22
23
|
constructor(scope, id, props) {
|
|
23
24
|
super(scope, id);
|
|
24
25
|
const region = cdk.Stack.of(this).region;
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
const deployment = (0, next_app_router_1.staticDeployment)(this, props.output);
|
|
27
|
+
this.static = deployment.staticBucket;
|
|
28
|
+
this.files = deployment.files;
|
|
29
|
+
const webAdapterLayer = lambda.LayerVersion.fromLayerVersionArn(this, 'WebAdapterLayer', `arn:aws:lambda:${region}:753240598075:layer:LambdaAdapterLayerX86:25`);
|
|
27
30
|
const environment = {
|
|
28
31
|
AWS_LAMBDA_EXEC_WRAPPER: '/opt/bootstrap',
|
|
29
32
|
PORT: '8080',
|
|
@@ -50,10 +53,7 @@ class NextAppRouterConstruct extends constructs_1.Construct {
|
|
|
50
53
|
invokeMode: lambda.InvokeMode.RESPONSE_STREAM,
|
|
51
54
|
});
|
|
52
55
|
const serverOrigin = new cloudfrontOrigin.FunctionUrlOrigin(webUrl);
|
|
53
|
-
return
|
|
54
|
-
...(0, next_app_router_1.serverCloudfrontBehaviour)(this, serverOrigin, path),
|
|
55
|
-
...(0, next_app_router_1.staticCloudfrontBehaviour)(this.static, path),
|
|
56
|
-
};
|
|
56
|
+
return (0, next_app_router_1.cloudfrontBehaviours)(this, this.static, serverOrigin, path, this.files);
|
|
57
57
|
}
|
|
58
58
|
cloudfrontPolicy(distributionId) {
|
|
59
59
|
throw new Error(`cloudfrontPolicy not supported for ${this}`);
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import * as cdk from 'aws-cdk-lib';
|
|
2
2
|
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
|
|
3
3
|
import * as s3 from 'aws-cdk-lib/aws-s3';
|
|
4
|
+
import * as s3Deploy from 'aws-cdk-lib/aws-s3-deployment';
|
|
4
5
|
import { Construct } from 'constructs';
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
export type AppFile = {
|
|
7
|
+
staticFiles: s3Deploy.ISource;
|
|
8
|
+
publicFiles: s3Deploy.ISource;
|
|
9
|
+
};
|
|
10
|
+
export declare function staticDeployment(app: Construct, output: string): {
|
|
11
|
+
staticBucket: cdk.aws_s3.Bucket;
|
|
12
|
+
files: {
|
|
13
|
+
staticFiles: cdk.aws_s3_deployment.ISource;
|
|
14
|
+
publicFiles: cdk.aws_s3_deployment.ISource;
|
|
15
|
+
};
|
|
8
16
|
};
|
|
9
|
-
export declare function
|
|
17
|
+
export declare function cloudfrontBehaviours(app: Construct, staticBucket: s3.Bucket, serverOrigin: cloudfront.IOrigin, basePath: string, files: AppFile): {
|
|
10
18
|
[x: string]: cdk.aws_cloudfront.BehaviorOptions;
|
|
11
19
|
};
|
|
12
20
|
//# sourceMappingURL=next-app-router.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-app-router.d.ts","sourceRoot":"","sources":["../../../src/lib/shared/next-app-router.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"next-app-router.d.ts","sourceRoot":"","sources":["../../../src/lib/shared/next-app-router.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,MAAM,OAAO,GAAG;IACpB,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC;IAC9B,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC;CAC/B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM;;;;;;EAsC9D;AAED,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,SAAS,EACd,YAAY,EAAE,EAAE,CAAC,MAAM,EACvB,YAAY,EAAE,UAAU,CAAC,OAAO,EAChC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO;;EA+Df"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.staticDeployment = staticDeployment;
|
|
4
|
-
exports.
|
|
5
|
-
exports.serverCloudfrontBehaviour = serverCloudfrontBehaviour;
|
|
4
|
+
exports.cloudfrontBehaviours = cloudfrontBehaviours;
|
|
6
5
|
const tslib_1 = require("tslib");
|
|
7
6
|
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
8
7
|
const cdk = tslib_1.__importStar(require("aws-cdk-lib"));
|
|
@@ -26,21 +25,41 @@ function staticDeployment(app, output) {
|
|
|
26
25
|
},
|
|
27
26
|
],
|
|
28
27
|
});
|
|
28
|
+
const staticFiles = s3Deploy.Source.asset(node_path_1.default.join(output, '/.next/static'));
|
|
29
|
+
const publicFiles = s3Deploy.Source.asset(node_path_1.default.join(output, '/public'));
|
|
29
30
|
new s3Deploy.BucketDeployment(app, `StaticDeployment`, {
|
|
30
31
|
destinationBucket: staticBucket,
|
|
31
|
-
sources: [
|
|
32
|
+
sources: [staticFiles],
|
|
32
33
|
destinationKeyPrefix: '_next/static',
|
|
33
34
|
retainOnDelete: false,
|
|
34
35
|
});
|
|
35
36
|
new s3Deploy.BucketDeployment(app, `PublicDeployment`, {
|
|
36
37
|
destinationBucket: staticBucket,
|
|
37
|
-
sources: [
|
|
38
|
+
sources: [publicFiles],
|
|
38
39
|
destinationKeyPrefix: '',
|
|
39
40
|
retainOnDelete: false,
|
|
40
41
|
});
|
|
41
|
-
return
|
|
42
|
+
return {
|
|
43
|
+
staticBucket,
|
|
44
|
+
files: { staticFiles, publicFiles },
|
|
45
|
+
};
|
|
42
46
|
}
|
|
43
|
-
function
|
|
47
|
+
function cloudfrontBehaviours(app, staticBucket, serverOrigin, basePath, files) {
|
|
48
|
+
if (basePath) {
|
|
49
|
+
// redeploy files for apps hosted in sub path
|
|
50
|
+
new s3Deploy.BucketDeployment(app, `${basePath}StaticDeployment`, {
|
|
51
|
+
destinationBucket: staticBucket,
|
|
52
|
+
sources: [files.staticFiles],
|
|
53
|
+
destinationKeyPrefix: `${basePath}/_next/static`,
|
|
54
|
+
retainOnDelete: false,
|
|
55
|
+
});
|
|
56
|
+
new s3Deploy.BucketDeployment(app, `${basePath}PublicDeployment`, {
|
|
57
|
+
destinationBucket: staticBucket,
|
|
58
|
+
sources: [files.publicFiles],
|
|
59
|
+
destinationKeyPrefix: basePath,
|
|
60
|
+
retainOnDelete: false,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
44
63
|
const staticOrigin = new cloudfrontOrigin.S3StaticWebsiteOrigin(staticBucket);
|
|
45
64
|
const staticBehavior = {
|
|
46
65
|
origin: staticOrigin,
|
|
@@ -50,16 +69,6 @@ function staticCloudfrontBehaviour(staticBucket, basePath) {
|
|
|
50
69
|
compress: true,
|
|
51
70
|
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
52
71
|
};
|
|
53
|
-
return {
|
|
54
|
-
[`${basePath}/_next/*`]: staticBehavior,
|
|
55
|
-
[`${basePath}/*.ico`]: staticBehavior,
|
|
56
|
-
[`${basePath}/*.png`]: staticBehavior,
|
|
57
|
-
[`${basePath}/*.svg`]: staticBehavior,
|
|
58
|
-
[`${basePath}/*.jpg`]: staticBehavior,
|
|
59
|
-
[`${basePath}/*.jpeg`]: staticBehavior,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function serverCloudfrontBehaviour(app, serverOrigin, basePath) {
|
|
63
72
|
const imageCachePolicy = new cloudfront.CachePolicy(app, 'ImagePolicy', {
|
|
64
73
|
queryStringBehavior: cloudfront.CacheQueryStringBehavior.all(),
|
|
65
74
|
maxTtl: cdk.Duration.days(365),
|
|
@@ -77,11 +86,17 @@ function serverCloudfrontBehaviour(app, serverOrigin, basePath) {
|
|
|
77
86
|
.CORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHT_AND_SECURITY_HEADERS,
|
|
78
87
|
};
|
|
79
88
|
return {
|
|
80
|
-
[`${basePath}/*`]: appBehaviour,
|
|
81
89
|
[`${basePath}/_next/image`]: {
|
|
82
90
|
...appBehaviour,
|
|
83
91
|
cachePolicy: imageCachePolicy,
|
|
84
92
|
allowedMethods: cloudfront.AllowedMethods.ALLOW_GET_HEAD,
|
|
85
93
|
},
|
|
94
|
+
[`${basePath}/_next/*`]: staticBehavior,
|
|
95
|
+
[`${basePath}/*.ico`]: staticBehavior,
|
|
96
|
+
[`${basePath}/*.png`]: staticBehavior,
|
|
97
|
+
[`${basePath}/*.svg`]: staticBehavior,
|
|
98
|
+
[`${basePath}/*.jpg`]: staticBehavior,
|
|
99
|
+
[`${basePath}/*.jpeg`]: staticBehavior,
|
|
100
|
+
[`${basePath}/*`]: appBehaviour,
|
|
86
101
|
};
|
|
87
102
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fy-stack/app-construct",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.145",
|
|
4
4
|
"repository": "https://github.com/festusyuma/fy-stack",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@fy-stack/types": "0.0.
|
|
6
|
+
"@fy-stack/types": "0.0.145",
|
|
7
7
|
"tslib": "^2.3.0",
|
|
8
8
|
"zod": "^3.24.1"
|
|
9
9
|
},
|