@fy-stack/app-construct 0.0.147-alpha.3066 → 0.0.147-alpha.3068
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.js +1 -1
- package/dist/lib/ecs/shared/taskDefinitionImage.js +2 -2
- package/dist/lib/lambda/apps/image-app-construct.d.ts +0 -2
- package/dist/lib/lambda/apps/image-app-construct.d.ts.map +1 -1
- package/dist/lib/lambda/apps/image-app-construct.js +4 -7
- package/dist/lib/lambda/apps/next-app-router-construct.d.ts.map +1 -1
- package/dist/lib/lambda/apps/next-app-router-construct.js +21 -9
- package/dist/lib/lambda/apps/node-api-construct.d.ts +2 -10
- package/dist/lib/lambda/apps/node-api-construct.d.ts.map +1 -1
- package/dist/lib/lambda/apps/node-api-construct.js +4 -6
- package/dist/lib/lambda/apps/node-app-construct.d.ts +2 -10
- package/dist/lib/lambda/apps/node-app-construct.d.ts.map +1 -1
- package/dist/lib/lambda/apps/node-app-construct.js +1 -5
- package/dist/lib/lambda/types.d.ts +1 -0
- package/dist/lib/lambda/types.d.ts.map +1 -1
- package/dist/lib/shared/code-from-param.d.ts +6 -0
- package/dist/lib/shared/code-from-param.d.ts.map +1 -0
- package/dist/lib/shared/code-from-param.js +11 -0
- package/dist/lib/shared/container-from-param.d.ts +7 -0
- package/dist/lib/shared/container-from-param.d.ts.map +1 -0
- package/dist/lib/shared/container-from-param.js +12 -0
- package/dist/lib/shared/next-app-router.d.ts +1 -1
- package/dist/lib/shared/next-app-router.js +2 -2
- package/dist/lib/standalone/image-app-container.d.ts +1 -0
- package/dist/lib/standalone/image-app-container.d.ts.map +1 -1
- package/dist/lib/standalone/image-app-container.js +4 -0
- package/package.json +2 -2
|
@@ -28,7 +28,7 @@ class NextAppRouterConstruct extends constructs_1.Construct {
|
|
|
28
28
|
this.files = { artifactBucket: artifactBucket, ...deployment.files };
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
|
-
const fileParams = (0, next_app_router_1.
|
|
31
|
+
const fileParams = (0, next_app_router_1.filesFromSSM)(this, props.reference);
|
|
32
32
|
const appArtifact = s3.Bucket.fromBucketName(scope, 'AppArtifactStorage', fileParams.artifact);
|
|
33
33
|
this.files = { ...fileParams, artifactBucket: appArtifact };
|
|
34
34
|
}
|
|
@@ -6,7 +6,7 @@ const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
|
6
6
|
const ecr = tslib_1.__importStar(require("aws-cdk-lib/aws-ecr"));
|
|
7
7
|
const ecrAssets = tslib_1.__importStar(require("aws-cdk-lib/aws-ecr-assets"));
|
|
8
8
|
const ecs = tslib_1.__importStar(require("aws-cdk-lib/aws-ecs"));
|
|
9
|
-
const
|
|
9
|
+
const container_from_param_1 = require("../../shared/container-from-param");
|
|
10
10
|
function taskDefinitionImage(scope, id, props) {
|
|
11
11
|
let image;
|
|
12
12
|
let containerProps;
|
|
@@ -23,7 +23,7 @@ function taskDefinitionImage(scope, id, props) {
|
|
|
23
23
|
containerProps = _containerProps;
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
|
-
const params = (0,
|
|
26
|
+
const params = (0, container_from_param_1.containerParamsFromSSM)(scope, props.reference);
|
|
27
27
|
const repository = ecr.Repository.fromRepositoryName(scope, `${id}Repository`, params.repository);
|
|
28
28
|
image = ecs.ContainerImage.fromEcrRepository(repository, params.tag);
|
|
29
29
|
containerProps = props.container;
|
|
@@ -10,7 +10,6 @@ import { AppConstruct, AppProperties } from '../types';
|
|
|
10
10
|
declare const BuildParamsSchema: z.ZodObject<{
|
|
11
11
|
container: z.ZodOptional<z.ZodObject<{
|
|
12
12
|
file: z.ZodOptional<z.ZodString>;
|
|
13
|
-
cmd: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
14
13
|
}, z.core.$loose>>;
|
|
15
14
|
}, z.core.$loose>;
|
|
16
15
|
export declare class ImageAppConstruct extends Construct implements AppConstruct {
|
|
@@ -28,7 +27,6 @@ export declare class ImageAppConstruct extends Construct implements AppConstruct
|
|
|
28
27
|
container?: {
|
|
29
28
|
[x: string]: unknown;
|
|
30
29
|
file?: string | undefined;
|
|
31
|
-
cmd?: string[] | undefined;
|
|
32
30
|
} | undefined;
|
|
33
31
|
};
|
|
34
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-app-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/apps/image-app-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAEL,eAAe,EAKhB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAEL,QAAQ,EAIT,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAK5E,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAMvD,QAAA,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"image-app-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/apps/image-app-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAEL,eAAe,EAKhB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAEL,QAAQ,EAIT,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAK5E,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAMvD,QAAA,MAAM,iBAAiB;;;;iBAOP,CAAC;AAEjB,qBAAa,iBAAkB,SAAQ,SAAU,YAAW,YAAY;IAC/D,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;gBAG9B,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAoDzD,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,IAAI;IAIpD,KAAK,CAAC,GAAG,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI;IAIvC,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,kBAAkB;IAW1D,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IAqBzD,gBAAgB,CAAC,cAAc,EAAE,MAAM;IAIvC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAIvD,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;;;;;;;CAG7B"}
|
|
@@ -13,7 +13,7 @@ const aws_sns_subscriptions_1 = require("aws-cdk-lib/aws-sns-subscriptions");
|
|
|
13
13
|
const aws_sqs_1 = require("aws-cdk-lib/aws-sqs");
|
|
14
14
|
const constructs_1 = require("constructs");
|
|
15
15
|
const zod_1 = require("zod");
|
|
16
|
-
const
|
|
16
|
+
const container_from_param_1 = require("../../shared/container-from-param");
|
|
17
17
|
const getDefaultLambda_1 = require("../utils/getDefaultLambda");
|
|
18
18
|
const lambda_api_1 = require("../utils/lambda-api");
|
|
19
19
|
const lambda_attach_1 = require("../utils/lambda-attach");
|
|
@@ -21,10 +21,7 @@ const lambda_grant_1 = require("../utils/lambda-grant");
|
|
|
21
21
|
const BuildParamsSchema = zod_1.z
|
|
22
22
|
.object({
|
|
23
23
|
container: zod_1.z
|
|
24
|
-
.object({
|
|
25
|
-
file: zod_1.z.string().optional(),
|
|
26
|
-
cmd: zod_1.z.string().array().optional(),
|
|
27
|
-
})
|
|
24
|
+
.object({ file: zod_1.z.string().optional() })
|
|
28
25
|
.passthrough()
|
|
29
26
|
.optional(),
|
|
30
27
|
})
|
|
@@ -37,11 +34,11 @@ class ImageAppConstruct extends constructs_1.Construct {
|
|
|
37
34
|
const { container, ...functionProps } = props.buildParams;
|
|
38
35
|
let code;
|
|
39
36
|
if ('reference' in props) {
|
|
40
|
-
const params = (0,
|
|
37
|
+
const params = (0, container_from_param_1.containerParamsFromSSM)(this, props.reference);
|
|
41
38
|
const repository = ecr.Repository.fromRepositoryName(this, 'Repository', params.repository);
|
|
42
39
|
code = aws_lambda_1.Code.fromEcrImage(repository, {
|
|
43
40
|
tagOrDigest: params.tag,
|
|
44
|
-
cmd:
|
|
41
|
+
cmd: params.cmd,
|
|
45
42
|
});
|
|
46
43
|
}
|
|
47
44
|
else {
|
|
@@ -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;AAEzE,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAEzD,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAIjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,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AC,cAAc,EAAE,MAAM;IAIvC,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAgG3D,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"}
|
|
@@ -18,6 +18,7 @@ const public_bucket_1 = require("../../shared/public-bucket");
|
|
|
18
18
|
const getDefaultLambda_1 = require("../utils/getDefaultLambda");
|
|
19
19
|
const lambda_attach_1 = require("../utils/lambda-attach");
|
|
20
20
|
const lambda_grant_1 = require("../utils/lambda-grant");
|
|
21
|
+
const code_from_param_1 = require("../../shared/code-from-param");
|
|
21
22
|
const BuildParamsSchema = zod_1.z.object({ cmd: zod_1.z.string() }).passthrough();
|
|
22
23
|
class NextAppRouterConstruct extends constructs_1.Construct {
|
|
23
24
|
function;
|
|
@@ -26,17 +27,12 @@ class NextAppRouterConstruct extends constructs_1.Construct {
|
|
|
26
27
|
files;
|
|
27
28
|
constructor(scope, id, props) {
|
|
28
29
|
super(scope, id);
|
|
29
|
-
if (!('output' in props)) {
|
|
30
|
-
throw new Error('Output is required');
|
|
31
|
-
}
|
|
32
30
|
const region = cdk.Stack.of(this).region;
|
|
33
31
|
this.static = (0, public_bucket_1.publicBucket)(this, 'StaticBucket');
|
|
34
32
|
const artifactBucket = new s3.Bucket(this, 'ArtifactStorage', {
|
|
35
33
|
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
36
34
|
autoDeleteObjects: true,
|
|
37
35
|
});
|
|
38
|
-
const deployment = (0, next_app_router_1.staticDeployment)(this, artifactBucket, props.output);
|
|
39
|
-
this.files = { artifactBucket, ...deployment.files };
|
|
40
36
|
const webAdapterLayer = lambda.LayerVersion.fromLayerVersionArn(this, 'WebAdapterLayer', `arn:aws:lambda:${region}:753240598075:layer:LambdaAdapterLayerX86:25`);
|
|
41
37
|
const environment = {
|
|
42
38
|
AWS_LAMBDA_EXEC_WRAPPER: '/opt/bootstrap',
|
|
@@ -45,15 +41,31 @@ class NextAppRouterConstruct extends constructs_1.Construct {
|
|
|
45
41
|
AWS_LWA_INVOKE_MODE: 'response_stream',
|
|
46
42
|
};
|
|
47
43
|
const { cmd, ...functionProps } = props.buildParams;
|
|
48
|
-
const serverOutput = path.join(props.output, '/.next/standalone');
|
|
49
|
-
fs.writeFileSync(path.join(serverOutput, 'run.sh'), cmd);
|
|
50
44
|
const defaultProps = (0, getDefaultLambda_1.getDefaultLambda)(props);
|
|
45
|
+
let handler;
|
|
46
|
+
let code;
|
|
47
|
+
if ('output' in props) {
|
|
48
|
+
const deployment = (0, next_app_router_1.staticDeployment)(this, artifactBucket, props.output);
|
|
49
|
+
this.files = { artifactBucket, ...deployment.files };
|
|
50
|
+
const serverOutput = path.join(props.output, '/.next/standalone');
|
|
51
|
+
fs.writeFileSync(path.join(serverOutput, 'run.sh'), cmd);
|
|
52
|
+
handler = 'run.sh';
|
|
53
|
+
code = lambda.Code.fromAsset(serverOutput);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const fileParams = (0, next_app_router_1.filesFromSSM)(this, props.reference);
|
|
57
|
+
const appArtifact = s3.Bucket.fromBucketName(scope, 'AppArtifactStorage', fileParams.artifact);
|
|
58
|
+
this.files = { ...fileParams, artifactBucket: appArtifact };
|
|
59
|
+
const cmdParams = (0, code_from_param_1.codeFromSSM)(this, props.reference);
|
|
60
|
+
handler = cmdParams.cmd;
|
|
61
|
+
code = lambda.Code.fromBucketV2(appArtifact, cmdParams.code);
|
|
62
|
+
}
|
|
51
63
|
this.function = new lambda.Function(this, `AppFunction`, {
|
|
52
64
|
...defaultProps,
|
|
53
65
|
environment: Object.assign({}, defaultProps.environment, environment),
|
|
54
66
|
runtime: lambda.Runtime.NODEJS_20_X,
|
|
55
|
-
handler
|
|
56
|
-
code
|
|
67
|
+
handler,
|
|
68
|
+
code,
|
|
57
69
|
layers: [webAdapterLayer],
|
|
58
70
|
...functionProps,
|
|
59
71
|
});
|
|
@@ -4,15 +4,11 @@ import * as lambda from 'aws-cdk-lib/aws-lambda';
|
|
|
4
4
|
import { ITopicSubscription, SubscriptionProps } from 'aws-cdk-lib/aws-sns';
|
|
5
5
|
import * as sqs from 'aws-cdk-lib/aws-sqs';
|
|
6
6
|
import { Construct } from 'constructs';
|
|
7
|
-
import { z } from 'zod';
|
|
8
7
|
import { AppConstruct, AppProperties } from '../types';
|
|
9
|
-
declare const BuildParamsSchema: z.ZodObject<{
|
|
10
|
-
cmd: z.ZodString;
|
|
11
|
-
}, z.core.$loose>;
|
|
12
8
|
export declare class NodeApiConstruct extends Construct implements AppConstruct {
|
|
13
9
|
function: lambda.Function;
|
|
14
10
|
queue: sqs.Queue | undefined;
|
|
15
|
-
constructor(scope: Construct, id: string, props: AppProperties
|
|
11
|
+
constructor(scope: Construct, id: string, props: AppProperties);
|
|
16
12
|
attach(attachable: Record<string, Attachable>): void;
|
|
17
13
|
grant(...grants: Grantable[]): void;
|
|
18
14
|
subscription(props: SubscriptionProps): ITopicSubscription;
|
|
@@ -31,10 +27,6 @@ export declare class NodeApiConstruct extends Construct implements AppConstruct
|
|
|
31
27
|
api(path: string): {
|
|
32
28
|
[x: string]: cdk.aws_apigatewayv2_integrations.HttpUrlIntegration;
|
|
33
29
|
};
|
|
34
|
-
static parse(params:
|
|
35
|
-
[x: string]: unknown;
|
|
36
|
-
cmd: string;
|
|
37
|
-
};
|
|
30
|
+
static parse<T>(params: T): T;
|
|
38
31
|
}
|
|
39
|
-
export {};
|
|
40
32
|
//# sourceMappingURL=node-api-construct.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-api-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/apps/node-api-construct.ts"],"names":[],"mappings":"AAGA,OAAO,EAA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gB,CAAC,cAAc,EAAE,MAAM;IAIvC,GAAG,CAAC,IAAI,EAAE,MAAM;;;IAIhB,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;CAG1B"}
|
|
@@ -11,12 +11,10 @@ const lambda = tslib_1.__importStar(require("aws-cdk-lib/aws-lambda"));
|
|
|
11
11
|
const lambdaEventSource = tslib_1.__importStar(require("aws-cdk-lib/aws-lambda-event-sources"));
|
|
12
12
|
const sqs = tslib_1.__importStar(require("aws-cdk-lib/aws-sqs"));
|
|
13
13
|
const constructs_1 = require("constructs");
|
|
14
|
-
const zod_1 = require("zod");
|
|
15
14
|
const getDefaultLambda_1 = require("../utils/getDefaultLambda");
|
|
16
15
|
const lambda_api_1 = require("../utils/lambda-api");
|
|
17
16
|
const lambda_attach_1 = require("../utils/lambda-attach");
|
|
18
17
|
const lambda_grant_1 = require("../utils/lambda-grant");
|
|
19
|
-
const BuildParamsSchema = zod_1.z.object({ cmd: zod_1.z.string() }).passthrough();
|
|
20
18
|
class NodeApiConstruct extends constructs_1.Construct {
|
|
21
19
|
function;
|
|
22
20
|
queue;
|
|
@@ -34,14 +32,14 @@ class NodeApiConstruct extends constructs_1.Construct {
|
|
|
34
32
|
const layers = [
|
|
35
33
|
lambda.LayerVersion.fromLayerVersionArn(this, 'WebAdapterLayer', `arn:aws:lambda:${region}:753240598075:layer:LambdaAdapterLayerX86:16`),
|
|
36
34
|
];
|
|
37
|
-
const
|
|
38
|
-
node_fs_1.default.writeFileSync(node_path_1.default.join(props.output, 'run.sh'), cmd);
|
|
35
|
+
const functionProps = props.buildParams;
|
|
36
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(props.output, 'run.sh'), props.cmd);
|
|
39
37
|
const defaultProps = (0, getDefaultLambda_1.getDefaultLambda)(props);
|
|
40
38
|
this.function = new lambda.Function(this, `AppFunction`, {
|
|
41
39
|
...defaultProps,
|
|
42
40
|
environment: Object.assign({}, defaultProps.environment, environment),
|
|
43
41
|
runtime: lambda.Runtime.NODEJS_20_X,
|
|
44
|
-
handler:
|
|
42
|
+
handler: props.cmd,
|
|
45
43
|
code: lambda.Code.fromAsset(props.output),
|
|
46
44
|
layers,
|
|
47
45
|
...functionProps,
|
|
@@ -87,7 +85,7 @@ class NodeApiConstruct extends constructs_1.Construct {
|
|
|
87
85
|
return (0, lambda_api_1.lambdaApi)(this.function, path);
|
|
88
86
|
}
|
|
89
87
|
static parse(params) {
|
|
90
|
-
return
|
|
88
|
+
return params;
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
91
|
exports.NodeApiConstruct = NodeApiConstruct;
|
|
@@ -5,25 +5,17 @@ import * as lambda from 'aws-cdk-lib/aws-lambda';
|
|
|
5
5
|
import { ITopicSubscription, SubscriptionProps } from 'aws-cdk-lib/aws-sns';
|
|
6
6
|
import * as sqs from 'aws-cdk-lib/aws-sqs';
|
|
7
7
|
import { Construct } from 'constructs';
|
|
8
|
-
import { z } from 'zod';
|
|
9
8
|
import { AppConstruct, AppProperties } from '../types';
|
|
10
|
-
declare const BuildParamsSchema: z.ZodObject<{
|
|
11
|
-
handler: z.ZodOptional<z.ZodString>;
|
|
12
|
-
}, z.core.$loose>;
|
|
13
9
|
export declare class NodeAppConstruct extends Construct implements AppConstruct {
|
|
14
10
|
function: lambda.Function;
|
|
15
11
|
queue: sqs.Queue | undefined;
|
|
16
|
-
constructor(scope: Construct, id: string, props: AppProperties
|
|
12
|
+
constructor(scope: Construct, id: string, props: AppProperties);
|
|
17
13
|
attach(attachable: Record<string, Attachable>): void;
|
|
18
14
|
grant(...grants: Grantable[]): void;
|
|
19
15
|
subscription(props: SubscriptionProps): ITopicSubscription;
|
|
20
16
|
cloudfront(path: string): Record<string, BehaviorOptions>;
|
|
21
17
|
cloudfrontPolicy(distributionId: string): void;
|
|
22
18
|
api(path: string): Record<string, HttpRouteIntegration>;
|
|
23
|
-
static parse(params:
|
|
24
|
-
[x: string]: unknown;
|
|
25
|
-
handler?: string | undefined;
|
|
26
|
-
};
|
|
19
|
+
static parse<T>(params: T): T;
|
|
27
20
|
}
|
|
28
|
-
export {};
|
|
29
21
|
//# sourceMappingURL=node-app-construct.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-app-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/apps/node-app-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"node-app-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/apps/node-app-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAKvD,qBAAa,gBAAiB,SAAQ,SAAU,YAAW,YAAY;IAC9D,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC;gBAExB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa;IAgC9D,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;IAI7C,KAAK,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE;IAI5B,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,kBAAkB;IAU1D,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IAIzD,gBAAgB,CAAC,cAAc,EAAE,MAAM;IAIvC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAcvD,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;CAG1B"}
|
|
@@ -9,13 +9,9 @@ const aws_lambda_event_sources_1 = require("aws-cdk-lib/aws-lambda-event-sources
|
|
|
9
9
|
const snsSubscriptions = tslib_1.__importStar(require("aws-cdk-lib/aws-sns-subscriptions"));
|
|
10
10
|
const aws_sqs_1 = require("aws-cdk-lib/aws-sqs");
|
|
11
11
|
const constructs_1 = require("constructs");
|
|
12
|
-
const zod_1 = require("zod");
|
|
13
12
|
const getDefaultLambda_1 = require("../utils/getDefaultLambda");
|
|
14
13
|
const lambda_attach_1 = require("../utils/lambda-attach");
|
|
15
14
|
const lambda_grant_1 = require("../utils/lambda-grant");
|
|
16
|
-
const BuildParamsSchema = zod_1.z
|
|
17
|
-
.object({ handler: zod_1.z.string().optional() })
|
|
18
|
-
.passthrough();
|
|
19
15
|
class NodeAppConstruct extends constructs_1.Construct {
|
|
20
16
|
function;
|
|
21
17
|
queue;
|
|
@@ -71,7 +67,7 @@ class NodeAppConstruct extends constructs_1.Construct {
|
|
|
71
67
|
};
|
|
72
68
|
}
|
|
73
69
|
static parse(params) {
|
|
74
|
-
return
|
|
70
|
+
return params;
|
|
75
71
|
}
|
|
76
72
|
}
|
|
77
73
|
exports.NodeAppConstruct = NodeAppConstruct;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/lambda/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,OAAO,EACP,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,KAAK,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,MAAM,WAAW,YACf,SAAQ,MAAM,EACZ,KAAK,EACL,WAAW,EACX,aAAa,EACb,WAAW;IACb,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,MAAM,GAAG,GAAG;IAChB,IAAI,EACA,OAAO,OAAO,CAAC,SAAS,GACxB,OAAO,OAAO,CAAC,eAAe,GAC9B,OAAO,OAAO,CAAC,QAAQ,GACvB,OAAO,OAAO,CAAC,QAAQ,CAAC;CAC7B,GAAG,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,UAAU,CAAC,CAAC;AAE5C,MAAM,MAAM,WAAW,
|
|
1
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AAC,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IACjE,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACrD,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAClD,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;CAC3B,GAAG,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-from-param.d.ts","sourceRoot":"","sources":["../../../src/lib/shared/code-from-param.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM;;;EAa9D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.codeFromSSM = codeFromSSM;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const ssm = tslib_1.__importStar(require("aws-cdk-lib/aws-ssm"));
|
|
6
|
+
function codeFromSSM(scope, reference) {
|
|
7
|
+
return {
|
|
8
|
+
code: ssm.StringParameter.fromStringParameterName(scope, 'CodeFilesKeyParam', `/${reference}/code`).stringValue,
|
|
9
|
+
cmd: ssm.StringParameter.fromStringParameterName(scope, 'CodeCMDParam', `/${reference}/code/handler`).stringValue,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-from-param.d.ts","sourceRoot":"","sources":["../../../src/lib/shared/container-from-param.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM;;;;EAkBzE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.containerParamsFromSSM = containerParamsFromSSM;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const ssm = tslib_1.__importStar(require("aws-cdk-lib/aws-ssm"));
|
|
6
|
+
function containerParamsFromSSM(scope, reference) {
|
|
7
|
+
return {
|
|
8
|
+
repository: ssm.StringParameter.fromStringParameterName(scope, 'RepositoryName', `/${reference}/repository`).stringValue,
|
|
9
|
+
tag: ssm.StringParameter.fromStringParameterName(scope, 'VersionNumber', `/${reference}/tag`).stringValue,
|
|
10
|
+
cmd: ssm.StringListParameter.fromStringListParameterName(scope, 'ImageCMD', `/${reference}/cmd`).stringListValue,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -14,7 +14,7 @@ export type AppFile = {
|
|
|
14
14
|
key: string;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
-
export declare function
|
|
17
|
+
export declare function filesFromSSM(scope: Construct, reference: string): {
|
|
18
18
|
artifact: string;
|
|
19
19
|
publicFiles: {
|
|
20
20
|
key: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.filesFromSSM = filesFromSSM;
|
|
4
4
|
exports.staticDeployment = staticDeployment;
|
|
5
5
|
exports.cloudfrontBehaviours = cloudfrontBehaviours;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
@@ -10,7 +10,7 @@ const cloudfront = tslib_1.__importStar(require("aws-cdk-lib/aws-cloudfront"));
|
|
|
10
10
|
const cloudfrontOrigin = tslib_1.__importStar(require("aws-cdk-lib/aws-cloudfront-origins"));
|
|
11
11
|
const s3Deploy = tslib_1.__importStar(require("aws-cdk-lib/aws-s3-deployment"));
|
|
12
12
|
const ssm = tslib_1.__importStar(require("aws-cdk-lib/aws-ssm"));
|
|
13
|
-
function
|
|
13
|
+
function filesFromSSM(scope, reference) {
|
|
14
14
|
return {
|
|
15
15
|
artifact: ssm.StringParameter.fromStringParameterName(scope, 'ArtifactStorage', `/${reference}/artifacts`).stringValue,
|
|
16
16
|
publicFiles: {
|
|
@@ -3,6 +3,7 @@ import { Construct } from 'constructs';
|
|
|
3
3
|
import type { StandaloneApp } from './types';
|
|
4
4
|
export type ImageAppProps = StandaloneApp & {
|
|
5
5
|
container?: DockerImageAssetOptions;
|
|
6
|
+
cmd: string[];
|
|
6
7
|
};
|
|
7
8
|
export declare class ImageAppContainer extends Construct {
|
|
8
9
|
constructor(scope: Construct, id: string, props: ImageAppProps);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-app-container.d.ts","sourceRoot":"","sources":["../../../src/lib/standalone/image-app-container.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAI1E,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG;IAC1C,SAAS,CAAC,EAAE,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"image-app-container.d.ts","sourceRoot":"","sources":["../../../src/lib/standalone/image-app-container.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAI1E,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG;IAC1C,SAAS,CAAC,EAAE,uBAAuB,CAAC;IACpC,GAAG,EAAE,MAAM,EAAE,CAAC;CACf,CAAC;AAEF,qBAAa,iBAAkB,SAAQ,SAAS;gBAClC,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa;CAsC/D"}
|
|
@@ -29,6 +29,10 @@ class ImageAppContainer extends constructs_1.Construct {
|
|
|
29
29
|
parameterName: `/${stackName}/repository`,
|
|
30
30
|
stringValue: repo.repositoryName,
|
|
31
31
|
});
|
|
32
|
+
new ssm.StringListParameter(this, 'ImageCMD', {
|
|
33
|
+
parameterName: `/${stackName}/cmd`,
|
|
34
|
+
stringListValue: props.cmd,
|
|
35
|
+
});
|
|
32
36
|
new ssm.StringParameter(this, 'TagParam', {
|
|
33
37
|
parameterName: `/${stackName}/tag`,
|
|
34
38
|
stringValue: props.version,
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fy-stack/app-construct",
|
|
3
|
-
"version": "0.0.147-alpha.
|
|
3
|
+
"version": "0.0.147-alpha.3068",
|
|
4
4
|
"repository": "https://github.com/festusyuma/fy-stack",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@fy-stack/types": "0.0.147-alpha.
|
|
6
|
+
"@fy-stack/types": "0.0.147-alpha.3068",
|
|
7
7
|
"tslib": "^2.3.0",
|
|
8
8
|
"zod": "^4.3.6"
|
|
9
9
|
},
|