@relkit/aws 0.3.0
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/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/access/index.d.ts +27 -0
- package/dist/access/index.d.ts.map +1 -0
- package/dist/access/index.js +11 -0
- package/dist/access/index.js.map +1 -0
- package/dist/access/materialize.d.ts +3 -0
- package/dist/access/materialize.d.ts.map +1 -0
- package/dist/access/materialize.js +94 -0
- package/dist/access/materialize.js.map +1 -0
- package/dist/aws.d.ts +29 -0
- package/dist/aws.d.ts.map +1 -0
- package/dist/aws.js +73 -0
- package/dist/aws.js.map +1 -0
- package/dist/host/environment.d.ts +6 -0
- package/dist/host/environment.d.ts.map +1 -0
- package/dist/host/environment.js +28 -0
- package/dist/host/environment.js.map +1 -0
- package/dist/host/index.d.ts +21 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +11 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/materialize.d.ts +3 -0
- package/dist/host/materialize.d.ts.map +1 -0
- package/dist/host/materialize.js +15 -0
- package/dist/host/materialize.js.map +1 -0
- package/dist/host/network.d.ts +4 -0
- package/dist/host/network.d.ts.map +1 -0
- package/dist/host/network.js +62 -0
- package/dist/host/network.js.map +1 -0
- package/dist/host/service-support.d.ts +5 -0
- package/dist/host/service-support.d.ts.map +1 -0
- package/dist/host/service-support.js +56 -0
- package/dist/host/service-support.js.map +1 -0
- package/dist/host/service.d.ts +4 -0
- package/dist/host/service.d.ts.map +1 -0
- package/dist/host/service.js +94 -0
- package/dist/host/service.js.map +1 -0
- package/dist/host/shared.d.ts +14 -0
- package/dist/host/shared.d.ts.map +1 -0
- package/dist/host/shared.js +43 -0
- package/dist/host/shared.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/index.d.ts +25 -0
- package/dist/infrastructure/index.d.ts.map +1 -0
- package/dist/infrastructure/index.js +11 -0
- package/dist/infrastructure/index.js.map +1 -0
- package/dist/infrastructure/materialize.d.ts +3 -0
- package/dist/infrastructure/materialize.d.ts.map +1 -0
- package/dist/infrastructure/materialize.js +10 -0
- package/dist/infrastructure/materialize.js.map +1 -0
- package/dist/infrastructure/redis.d.ts +3 -0
- package/dist/infrastructure/redis.d.ts.map +1 -0
- package/dist/infrastructure/redis.js +58 -0
- package/dist/infrastructure/redis.js.map +1 -0
- package/dist/infrastructure/s3.d.ts +3 -0
- package/dist/infrastructure/s3.d.ts.map +1 -0
- package/dist/infrastructure/s3.js +32 -0
- package/dist/infrastructure/s3.js.map +1 -0
- package/dist/infrastructure/shared.d.ts +16 -0
- package/dist/infrastructure/shared.d.ts.map +1 -0
- package/dist/infrastructure/shared.js +49 -0
- package/dist/infrastructure/shared.js.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 rel-kit
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const awsAccess: Readonly<{
|
|
2
|
+
kind: "deployment-integration";
|
|
3
|
+
protocolVersion: 1;
|
|
4
|
+
integrationId: "aws";
|
|
5
|
+
role: "access";
|
|
6
|
+
materialize: (input: {
|
|
7
|
+
readonly plan: import("@relkit/deploy").DeploymentPlan;
|
|
8
|
+
readonly stackName: string;
|
|
9
|
+
readonly operation: import("@relkit/deploy").AccessOperationPlan;
|
|
10
|
+
readonly host: import("@relkit/deploy").DeploymentHostMaterialization;
|
|
11
|
+
readonly infrastructure: import("@relkit/deploy").DeploymentInfrastructureMaterialization;
|
|
12
|
+
}) => import("@relkit/deploy").DeploymentAccessMaterialization;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const deploymentIntegration: Readonly<{
|
|
15
|
+
kind: "deployment-integration";
|
|
16
|
+
protocolVersion: 1;
|
|
17
|
+
integrationId: "aws";
|
|
18
|
+
role: "access";
|
|
19
|
+
materialize: (input: {
|
|
20
|
+
readonly plan: import("@relkit/deploy").DeploymentPlan;
|
|
21
|
+
readonly stackName: string;
|
|
22
|
+
readonly operation: import("@relkit/deploy").AccessOperationPlan;
|
|
23
|
+
readonly host: import("@relkit/deploy").DeploymentHostMaterialization;
|
|
24
|
+
readonly infrastructure: import("@relkit/deploy").DeploymentInfrastructureMaterialization;
|
|
25
|
+
}) => import("@relkit/deploy").DeploymentAccessMaterialization;
|
|
26
|
+
}>;
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/access/index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS;;;;;;;;;;;;EAMkB,CAAC;AAEzC,eAAO,MAAM,qBAAqB;;;;;;;;;;;;EAAY,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DEPLOYMENT_INTEGRATION_PROTOCOL_VERSION, } from "@relkit/deploy";
|
|
2
|
+
import { materializeAwsAccess } from "./materialize.js";
|
|
3
|
+
export const awsAccess = Object.freeze({
|
|
4
|
+
kind: "deployment-integration",
|
|
5
|
+
protocolVersion: DEPLOYMENT_INTEGRATION_PROTOCOL_VERSION,
|
|
6
|
+
integrationId: "aws",
|
|
7
|
+
role: "access",
|
|
8
|
+
materialize: materializeAwsAccess,
|
|
9
|
+
});
|
|
10
|
+
export const deploymentIntegration = awsAccess;
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/access/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uCAAuC,GAExC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,wBAAwB;IAC9B,eAAe,EAAE,uCAAuC;IACxD,aAAa,EAAE,KAAK;IACpB,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,oBAAoB;CAClC,CAAuC,CAAC;AAEzC,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"materialize.d.ts","sourceRoot":"","sources":["../../src/access/materialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,2BAA2B,EAGjC,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,oBAAoB,EAAE,2BAA2B,CAAC,aAAa,CAO3E,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { deploymentJson, } from "@relkit/deploy";
|
|
2
|
+
export const materializeAwsAccess = (input) => {
|
|
3
|
+
const infrastructure = input.plan.infrastructureOperations.find((entry) => entry.bindingId === input.operation.bindingId);
|
|
4
|
+
if (infrastructure?.capability === "bucket")
|
|
5
|
+
return bucketAccess(input);
|
|
6
|
+
if (infrastructure?.capability === "cache")
|
|
7
|
+
return cacheAccess(input);
|
|
8
|
+
throw new TypeError(`AWS access for "${input.operation.bindingId}" is unsupported.`);
|
|
9
|
+
};
|
|
10
|
+
function bucketAccess(input) {
|
|
11
|
+
const actions = actionList(input.operation.integration.configuration);
|
|
12
|
+
const list = actions.filter((action) => action === "s3:ListBucket");
|
|
13
|
+
const objects = actions.filter((action) => action !== "s3:ListBucket");
|
|
14
|
+
const statements = [
|
|
15
|
+
...(list.length === 0
|
|
16
|
+
? []
|
|
17
|
+
: [
|
|
18
|
+
{
|
|
19
|
+
Effect: "Allow",
|
|
20
|
+
Action: list,
|
|
21
|
+
Resource: required(input.infrastructure.access.bucketArn, "bucket ARN"),
|
|
22
|
+
},
|
|
23
|
+
]),
|
|
24
|
+
...(objects.length === 0
|
|
25
|
+
? []
|
|
26
|
+
: [
|
|
27
|
+
{
|
|
28
|
+
Effect: "Allow",
|
|
29
|
+
Action: objects,
|
|
30
|
+
Resource: required(input.infrastructure.access.objectArn, "object ARN"),
|
|
31
|
+
},
|
|
32
|
+
]),
|
|
33
|
+
];
|
|
34
|
+
return {
|
|
35
|
+
resources: statements.length === 0
|
|
36
|
+
? []
|
|
37
|
+
: [
|
|
38
|
+
operation(input, "bucket-policy", "aws:iam/rolePolicy:RolePolicy", {
|
|
39
|
+
role: input.host.workload.roleName,
|
|
40
|
+
policy: deploymentJson({ Version: "2012-10-17", Statement: statements }),
|
|
41
|
+
}),
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function cacheAccess(input) {
|
|
46
|
+
return {
|
|
47
|
+
resources: [
|
|
48
|
+
operation(input, "cache-ingress", "aws:ec2/securityGroupRule:SecurityGroupRule", {
|
|
49
|
+
type: "ingress",
|
|
50
|
+
fromPort: number(input.infrastructure.access.port, "cache port"),
|
|
51
|
+
toPort: number(input.infrastructure.access.port, "cache port"),
|
|
52
|
+
protocol: "tcp",
|
|
53
|
+
securityGroupId: required(input.infrastructure.access.securityGroupId, "cache group"),
|
|
54
|
+
sourceSecurityGroupId: input.host.network.serviceSecurityGroupId,
|
|
55
|
+
}),
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function operation(input, suffix, type, values) {
|
|
60
|
+
const id = `aws.access.${input.operation.bindingId}.${suffix}`;
|
|
61
|
+
return {
|
|
62
|
+
kind: "deployment-resource",
|
|
63
|
+
id,
|
|
64
|
+
type,
|
|
65
|
+
name: id
|
|
66
|
+
.toLowerCase()
|
|
67
|
+
.replace(/[^a-z0-9-]+/g, "-")
|
|
68
|
+
.slice(0, 63),
|
|
69
|
+
inputs: values,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function actionList(value) {
|
|
73
|
+
const actions = record(value).actions;
|
|
74
|
+
const allowed = new Set(["s3:GetObject", "s3:PutObject", "s3:DeleteObject", "s3:ListBucket"]);
|
|
75
|
+
if (!Array.isArray(actions) || actions.some((action) => !allowed.has(String(action))))
|
|
76
|
+
throw new TypeError("AWS S3 access actions are invalid.");
|
|
77
|
+
return [...new Set(actions)].sort();
|
|
78
|
+
}
|
|
79
|
+
function required(value, label) {
|
|
80
|
+
if (value === undefined)
|
|
81
|
+
throw new TypeError(`AWS ${label} output is missing.`);
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
function number(value, label) {
|
|
85
|
+
if (typeof value !== "number")
|
|
86
|
+
throw new TypeError(`AWS ${label} output is invalid.`);
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
function record(value) {
|
|
90
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
91
|
+
? value
|
|
92
|
+
: {};
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=materialize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"materialize.js","sourceRoot":"","sources":["../../src/access/materialize.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAIf,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,MAAM,oBAAoB,GAA+C,CAAC,KAAK,EAAE,EAAE;IACxF,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAC7D,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS,CAAC,SAAS,CACzD,CAAC;IACF,IAAI,cAAc,EAAE,UAAU,KAAK,QAAQ;QAAE,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;IACxE,IAAI,cAAc,EAAE,UAAU,KAAK,OAAO;QAAE,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;IACtE,MAAM,IAAI,SAAS,CAAC,mBAAmB,KAAK,CAAC,SAAS,CAAC,SAAS,mBAAmB,CAAC,CAAC;AACvF,CAAC,CAAC;AAEF,SAAS,YAAY,CAAC,KAAgE;IAGpF,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IACtE,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,eAAe,CAAC,CAAC;IACpE,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,eAAe,CAAC,CAAC;IACvE,MAAM,UAAU,GAAG;QACjB,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;YACnB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC;gBACE;oBACE,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AI,OAAO,KAAK,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,OAAO,KAAK,qBAAqB,CAAC,CAAC;IACtF,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzE,CAAC,CAAE,KAA2C;QAC9C,CAAC,CAAC,EAAE,CAAC;AACT,CAAC"}
|
package/dist/aws.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type InfrastructureProviderSource, type ProviderAdapter, type ProviderCapability } from "@relkit/provider";
|
|
2
|
+
type S3Adapter = ProviderAdapter<ProviderCapability<"bucket">, "s3">;
|
|
3
|
+
type RedisAdapter = ProviderAdapter<ProviderCapability<"cache">, "redis">;
|
|
4
|
+
export type AwsAdapter = S3Adapter | RedisAdapter;
|
|
5
|
+
export interface AwsS3Options {
|
|
6
|
+
readonly versioning?: boolean;
|
|
7
|
+
readonly forceDestroy?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface AwsRedisOptions {
|
|
10
|
+
readonly engine?: "valkey" | "redis";
|
|
11
|
+
readonly nodeType?: string;
|
|
12
|
+
readonly replicas?: number;
|
|
13
|
+
}
|
|
14
|
+
export type AwsOptions<Adapter extends AwsAdapter> = Adapter extends S3Adapter ? AwsS3Options : AwsRedisOptions;
|
|
15
|
+
/**
|
|
16
|
+
* Provisions a supported S3 or Redis adapter on AWS and grants only its workload access.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { aws } from "@relkit/aws";
|
|
21
|
+
* import { s3 } from "@relkit/s3";
|
|
22
|
+
* const receipts = aws(s3(), { versioning: true });
|
|
23
|
+
* ```
|
|
24
|
+
* @category Integrations
|
|
25
|
+
* @since 0.2.0
|
|
26
|
+
*/
|
|
27
|
+
export declare function aws<const Adapter extends AwsAdapter>(adapter: Adapter, options?: AwsOptions<Adapter>): InfrastructureProviderSource<Adapter>;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=aws.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aws.d.ts","sourceRoot":"","sources":["../src/aws.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,4BAA4B,EACjC,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAE1B,KAAK,SAAS,GAAG,eAAe,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC;AACrE,KAAK,YAAY,GAAG,eAAe,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;AAC1E,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,YAAY,CAAC;AAElD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,UAAU,CAAC,OAAO,SAAS,UAAU,IAAI,OAAO,SAAS,SAAS,GAC1E,YAAY,GACZ,eAAe,CAAC;AAIpB;;;;;;;;;;;GAWG;AACH,wBAAgB,GAAG,CAAC,KAAK,CAAC,OAAO,SAAS,UAAU,EAClD,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,UAAU,CAAC,OAAO,CAA6B,GACvD,4BAA4B,CAAC,OAAO,CAAC,CAwBvC"}
|
package/dist/aws.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { defineInfrastructureProviderSource, defineIntegrationReference, defineProviderAccess, } from "@relkit/provider";
|
|
2
|
+
const integration = defineIntegrationReference("aws");
|
|
3
|
+
/**
|
|
4
|
+
* Provisions a supported S3 or Redis adapter on AWS and grants only its workload access.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { aws } from "@relkit/aws";
|
|
9
|
+
* import { s3 } from "@relkit/s3";
|
|
10
|
+
* const receipts = aws(s3(), { versioning: true });
|
|
11
|
+
* ```
|
|
12
|
+
* @category Integrations
|
|
13
|
+
* @since 0.2.0
|
|
14
|
+
*/
|
|
15
|
+
export function aws(adapter, options = {}) {
|
|
16
|
+
const capability = adapter.capability.id;
|
|
17
|
+
if (capability === "bucket" && adapter.adapterId === "s3") {
|
|
18
|
+
assertS3Options(options);
|
|
19
|
+
return defineInfrastructureProviderSource(adapter, integration, s3Configuration(options), defineProviderAccess({
|
|
20
|
+
kind: "iam",
|
|
21
|
+
actions: ["s3:GetObject", "s3:PutObject", "s3:DeleteObject", "s3:ListBucket"],
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
if (capability === "cache" && adapter.adapterId === "redis") {
|
|
25
|
+
assertRedisOptions(options);
|
|
26
|
+
return defineInfrastructureProviderSource(adapter, integration, redisConfiguration(options), defineProviderAccess({ kind: "network", port: 6379 }));
|
|
27
|
+
}
|
|
28
|
+
throw new TypeError(`AWS does not support ${capability}:${adapter.adapterId}`);
|
|
29
|
+
}
|
|
30
|
+
function s3Configuration(options) {
|
|
31
|
+
return {
|
|
32
|
+
...(options.versioning === undefined ? {} : { versioning: options.versioning }),
|
|
33
|
+
...(options.forceDestroy === undefined ? {} : { forceDestroy: options.forceDestroy }),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function redisConfiguration(options) {
|
|
37
|
+
return {
|
|
38
|
+
...(options.engine === undefined ? {} : { engine: options.engine }),
|
|
39
|
+
...(options.nodeType === undefined ? {} : { nodeType: options.nodeType }),
|
|
40
|
+
...(options.replicas === undefined ? {} : { replicas: options.replicas }),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function assertS3Options(value) {
|
|
44
|
+
const options = record(value, "AWS S3 options");
|
|
45
|
+
assertKeys(options, ["versioning", "forceDestroy"]);
|
|
46
|
+
for (const name of ["versioning", "forceDestroy"])
|
|
47
|
+
if (options[name] !== undefined && typeof options[name] !== "boolean")
|
|
48
|
+
throw new TypeError(`AWS S3 ${name} must be a boolean`);
|
|
49
|
+
}
|
|
50
|
+
function assertRedisOptions(value) {
|
|
51
|
+
const options = record(value, "AWS Redis options");
|
|
52
|
+
assertKeys(options, ["engine", "nodeType", "replicas"]);
|
|
53
|
+
if (options.engine !== undefined && options.engine !== "valkey" && options.engine !== "redis")
|
|
54
|
+
throw new TypeError('AWS Redis engine must be "valkey" or "redis"');
|
|
55
|
+
if (options.nodeType !== undefined && !/^cache\.[a-z0-9.-]+$/i.test(String(options.nodeType)))
|
|
56
|
+
throw new TypeError("AWS Redis nodeType is invalid");
|
|
57
|
+
if (options.replicas !== undefined &&
|
|
58
|
+
(!Number.isSafeInteger(options.replicas) ||
|
|
59
|
+
Number(options.replicas) < 0 ||
|
|
60
|
+
Number(options.replicas) > 5))
|
|
61
|
+
throw new RangeError("AWS Redis replicas must be between 0 and 5");
|
|
62
|
+
}
|
|
63
|
+
function assertKeys(value, allowed) {
|
|
64
|
+
for (const key of Object.keys(value))
|
|
65
|
+
if (!allowed.includes(key))
|
|
66
|
+
throw new TypeError(`Unknown AWS option "${key}"`);
|
|
67
|
+
}
|
|
68
|
+
function record(value, label) {
|
|
69
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
70
|
+
throw new TypeError(`${label} must be an object`);
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=aws.js.map
|
package/dist/aws.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aws.js","sourceRoot":"","s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"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAExB,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,cAAc,GACnB,SAAS,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,eAAe,CAAA;CAAE,CAAC,EAAE,CA2B/D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { deploymentBinding, deploymentConfiguration, deploymentJson, } from "@relkit/deploy";
|
|
2
|
+
export function containerEnvironment(plan) {
|
|
3
|
+
const environment = new Map([
|
|
4
|
+
["RELKIT_APPLICATION_ID", plan.application.id],
|
|
5
|
+
]);
|
|
6
|
+
for (const name of plan.application.environmentNames)
|
|
7
|
+
environment.set(name, deploymentConfiguration(name));
|
|
8
|
+
for (const binding of plan.connectedBindings)
|
|
9
|
+
for (const value of binding.namedValues)
|
|
10
|
+
environment.set(value.name, deploymentConfiguration(value.name, { sensitive: value.sensitive }));
|
|
11
|
+
const infrastructure = Object.fromEntries(plan.infrastructureOperations.map((binding) => [
|
|
12
|
+
binding.bindingId,
|
|
13
|
+
Object.fromEntries(Object.keys(record(binding.adapter.connectionContract))
|
|
14
|
+
.sort()
|
|
15
|
+
.map((field) => [field, deploymentBinding(binding.bindingId, field)])),
|
|
16
|
+
]));
|
|
17
|
+
if (Object.keys(infrastructure).length > 0)
|
|
18
|
+
environment.set("RELKIT_INFRASTRUCTURE_BINDINGS", deploymentJson(infrastructure));
|
|
19
|
+
return [...environment]
|
|
20
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
21
|
+
.map(([name, value]) => ({ name, value }));
|
|
22
|
+
}
|
|
23
|
+
function record(value) {
|
|
24
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
25
|
+
? value
|
|
26
|
+
: {};
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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AE,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC;IACpF,OAAO,CAAC,GAAG,WAAW,CAAC;SACpB,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;SACpD,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzE,CAAC,CAAE,KAA2C;QAC9C,CAAC,CAAC,EAAE,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const awsHost: Readonly<{
|
|
2
|
+
kind: "deployment-integration";
|
|
3
|
+
protocolVersion: 1;
|
|
4
|
+
integrationId: "aws";
|
|
5
|
+
role: "host";
|
|
6
|
+
materialize: (input: {
|
|
7
|
+
readonly plan: import("@relkit/deploy").DeploymentPlan;
|
|
8
|
+
readonly stackName: string;
|
|
9
|
+
}) => import("@relkit/deploy").DeploymentHostMaterialization;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const deploymentIntegration: Readonly<{
|
|
12
|
+
kind: "deployment-integration";
|
|
13
|
+
protocolVersion: 1;
|
|
14
|
+
integrationId: "aws";
|
|
15
|
+
role: "host";
|
|
16
|
+
materialize: (input: {
|
|
17
|
+
readonly plan: import("@relkit/deploy").DeploymentPlan;
|
|
18
|
+
readonly stackName: string;
|
|
19
|
+
}) => import("@relkit/deploy").DeploymentHostMaterialization;
|
|
20
|
+
}>;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,OAAO;;;;;;;;;EAMkB,CAAC;AAEvC,eAAO,MAAM,qBAAqB;;;;;;;;;EAAU,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DEPLOYMENT_INTEGRATION_PROTOCOL_VERSION, } from "@relkit/deploy";
|
|
2
|
+
import { materializeAwsHost } from "./materialize.js";
|
|
3
|
+
export const awsHost = Object.freeze({
|
|
4
|
+
kind: "deployment-integration",
|
|
5
|
+
protocolVersion: DEPLOYMENT_INTEGRATION_PROTOCOL_VERSION,
|
|
6
|
+
integrationId: "aws",
|
|
7
|
+
role: "host",
|
|
8
|
+
materialize: materializeAwsHost,
|
|
9
|
+
});
|
|
10
|
+
export const deploymentIntegration = awsHost;
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uCAAuC,GAExC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE,wBAAwB;IAC9B,eAAe,EAAE,uCAAuC;IACxD,aAAa,EAAE,KAAK;IACpB,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,kBAAkB;CAChC,CAAqC,CAAC;AAEvC,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"materialize.d.ts","sourceRoot":"","sources":["../../src/host/materialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAKhE,eAAO,MAAM,kBAAkB,EAAE,yBAAyB,CAAC,aAAa,CAavE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { network } from "./network.js";
|
|
2
|
+
import { service } from "./service.js";
|
|
3
|
+
import { hostContext } from "./shared.js";
|
|
4
|
+
export const materializeAwsHost = ({ plan, stackName, }) => {
|
|
5
|
+
const context = hostContext(plan, stackName);
|
|
6
|
+
const foundation = network(context);
|
|
7
|
+
const application = service(context, foundation.network);
|
|
8
|
+
return Object.freeze({
|
|
9
|
+
resources: Object.freeze([...foundation.resources, ...application.resources]),
|
|
10
|
+
network: Object.freeze(foundation.network),
|
|
11
|
+
workload: Object.freeze(application.workload),
|
|
12
|
+
outputs: Object.freeze(application.outputs),
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=materialize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"materialize.js","sourceRoot":"","sources":["../../src/host/materialize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,CAAC,MAAM,kBAAkB,GAA6C,CAAC,EAC3E,IAAI,EACJ,SAAS,GACV,EAAE,EAAE;IACH,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC7C,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IACzD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,SAAS,EAAE,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;QAC7E,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC;QAC1C,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC;QAC7C,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC;KAC5C,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type DeploymentHostMaterialization } from "@relkit/deploy";
|
|
2
|
+
import { type HostContext } from "./shared.js";
|
|
3
|
+
export declare function network(context: HostContext): Pick<DeploymentHostMaterialization, "resources" | "network">;
|
|
4
|
+
//# sourceMappingURL=network.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/host/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,aAAa,CAAC;AAEjE,wBAAgB,OAAO,CACrB,OAAO,EAAE,WAAW,GACnB,IAAI,CAAC,6BAA6B,EAAE,WAAW,GAAG,SAAS,CAAC,CAkG9D"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { deploymentJoin } from "@relkit/deploy";
|
|
2
|
+
import { output, resource } from "./shared.js";
|
|
3
|
+
export function network(context) {
|
|
4
|
+
const commonEgress = [
|
|
5
|
+
{ fromPort: 0, toPort: 0, protocol: "-1", cidrBlocks: ["0.0.0.0/0"] },
|
|
6
|
+
];
|
|
7
|
+
const resources = [
|
|
8
|
+
resource(context, "vpc", "aws:ec2/vpc:Vpc", {
|
|
9
|
+
cidrBlock: "10.42.0.0/16",
|
|
10
|
+
enableDnsHostnames: true,
|
|
11
|
+
enableDnsSupport: true,
|
|
12
|
+
tags: context.tags,
|
|
13
|
+
}, ["id"]),
|
|
14
|
+
resource(context, "internet-gateway", "aws:ec2/internetGateway:InternetGateway", { vpcId: output("vpc", "id"), tags: context.tags }, ["id"]),
|
|
15
|
+
resource(context, "route-table", "aws:ec2/routeTable:RouteTable", {
|
|
16
|
+
vpcId: output("vpc", "id"),
|
|
17
|
+
routes: [{ cidrBlock: "0.0.0.0/0", gatewayId: output("internet-gateway", "id") }],
|
|
18
|
+
tags: context.tags,
|
|
19
|
+
}, ["id"]),
|
|
20
|
+
...["a", "b"].map((zone, index) => resource(context, `subnet-${zone}`, "aws:ec2/subnet:Subnet", {
|
|
21
|
+
vpcId: output("vpc", "id"),
|
|
22
|
+
cidrBlock: `10.42.${index}.0/24`,
|
|
23
|
+
availabilityZone: deploymentJoin(context.region, zone),
|
|
24
|
+
mapPublicIpOnLaunch: true,
|
|
25
|
+
tags: context.tags,
|
|
26
|
+
}, ["id"])),
|
|
27
|
+
...["a", "b"].map((zone) => resource(context, `route-${zone}`, "aws:ec2/routeTableAssociation:RouteTableAssociation", {
|
|
28
|
+
routeTableId: output("route-table", "id"),
|
|
29
|
+
subnetId: output(`subnet-${zone}`, "id"),
|
|
30
|
+
})),
|
|
31
|
+
resource(context, "alb-security-group", "aws:ec2/securityGroup:SecurityGroup", {
|
|
32
|
+
vpcId: output("vpc", "id"),
|
|
33
|
+
description: "RelKit public load balancer",
|
|
34
|
+
ingress: [{ fromPort: 80, toPort: 80, protocol: "tcp", cidrBlocks: ["0.0.0.0/0"] }],
|
|
35
|
+
egress: commonEgress,
|
|
36
|
+
tags: context.tags,
|
|
37
|
+
}, ["id"]),
|
|
38
|
+
resource(context, "service-security-group", "aws:ec2/securityGroup:SecurityGroup", {
|
|
39
|
+
vpcId: output("vpc", "id"),
|
|
40
|
+
description: "RelKit ECS service",
|
|
41
|
+
ingress: [
|
|
42
|
+
{
|
|
43
|
+
fromPort: context.plan.http.port,
|
|
44
|
+
toPort: context.plan.http.port,
|
|
45
|
+
protocol: "tcp",
|
|
46
|
+
securityGroups: [output("alb-security-group", "id")],
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
egress: commonEgress,
|
|
50
|
+
tags: context.tags,
|
|
51
|
+
}, ["id"]),
|
|
52
|
+
];
|
|
53
|
+
return {
|
|
54
|
+
resources,
|
|
55
|
+
network: {
|
|
56
|
+
vpcId: output("vpc", "id"),
|
|
57
|
+
subnetIds: [output("subnet-a", "id"), output("subnet-b", "id")],
|
|
58
|
+
serviceSecurityGroupId: output("service-security-group", "id"),
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=network.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/host/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAsC,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAoB,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEjE,MAAM,UAAU,OAAO,CACrB,OAAoB;IAEpB,MAAM,YAAY,GAAG;QACnB,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,WAAW,CAAC,EAAE;KAC7D,CAAC;IACX,MAAM,SAAS,GAAG;QAChB,QAAQ,CACN,OAAO,EACP,KAAK,EACL,iBAAiB,EACjB;YACE,SAAS,EAAE,cAAc;YACzB,kBAAkB,EAAE,IAAI;YACxB,gBAAgB,EAAE,IAAI;YACtB,IAAI,EAAE,OAAO,CAAC,IAAI;SACnB,EACD,CAAC,IAAI,CAAC,CACP;QACD,QAAQ,CACN,OAAO,EACP,kBAAkB,EAClB,yCAAyC,EACzC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAClD,CAAC,IAAI,CAAC,CACP;QACD,QAAQ,CACN,OAAO,EACP,aAAa,EACb,+BAA+B,EAC/B;YACE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC;YAC1B,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,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CACP;QACD,QAAQ,CACN,OAAO,EACP,wBAAwB,EACxB,qCAAqC,EACrC;YACE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC;YAC1B,WAAW,EAAE,oBAAoB;YACjC,OAAO,EAAE;gBACP;oBACE,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;oBAChC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;oBAC9B,QAAQ,EAAE,KAAK;oBACf,cAAc,EAAE,CAAC,MAAM,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC;iBACrD;aACF;YACD,MAAM,EAAE,YAAY;YACpB,IAAI,EAAE,OAAO,CAAC,IAAI;SACnB,EACD,CAAC,IAAI,CAAC,CACP;KACF,CAAC;IACF,OAAO;QACL,SAAS;QACT,OAAO,EAAE;YACP,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC;YAC1B,SAAS,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;YAC/D,sBAAsB,EAAE,MAAM,CAAC,wBAAwB,EAAE,IAAI,CAAC;SAC/D;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type DeploymentInput, type DeploymentResourceOperation } from "@relkit/deploy";
|
|
2
|
+
import { type HostContext } from "./shared.js";
|
|
3
|
+
export declare function role(context: HostContext, id: string): DeploymentResourceOperation;
|
|
4
|
+
export declare function container(context: HostContext): Readonly<Record<string, DeploymentInput>>;
|
|
5
|
+
//# sourceMappingURL=service-support.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-support.d.ts","sourceRoot":"","sources":["../../src/host/service-support.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,2BAA2B,EACjC,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,aAAa,CAAC;AAajE,wBAAgB,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,GAAG,2BAA2B,CAQlF;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CA2BzF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { deploymentJoin, } from "@relkit/deploy";
|
|
2
|
+
import { containerEnvironment } from "./environment.js";
|
|
3
|
+
import { output, resource } from "./shared.js";
|
|
4
|
+
const ASSUME_ROLE_POLICY = JSON.stringify({
|
|
5
|
+
Version: "2012-10-17",
|
|
6
|
+
Statement: [
|
|
7
|
+
{
|
|
8
|
+
Effect: "Allow",
|
|
9
|
+
Principal: { Service: "ecs-tasks.amazonaws.com" },
|
|
10
|
+
Action: "sts:AssumeRole",
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
});
|
|
14
|
+
export function role(context, id) {
|
|
15
|
+
return resource(context, id, "aws:iam/role:Role", { assumeRolePolicy: ASSUME_ROLE_POLICY, tags: context.tags }, ["arn", "name"]);
|
|
16
|
+
}
|
|
17
|
+
export function container(context) {
|
|
18
|
+
return {
|
|
19
|
+
name: "app",
|
|
20
|
+
image: image(context),
|
|
21
|
+
essential: true,
|
|
22
|
+
portMappings: [{ containerPort: context.plan.http.port, protocol: "tcp" }],
|
|
23
|
+
environment: containerEnvironment(context.plan),
|
|
24
|
+
stopTimeout: 30,
|
|
25
|
+
healthCheck: {
|
|
26
|
+
command: [
|
|
27
|
+
"CMD-SHELL",
|
|
28
|
+
`wget -q -O /dev/null http://127.0.0.1:${context.plan.http.port}${context.plan.http.health.livenessPath} || exit 1`,
|
|
29
|
+
],
|
|
30
|
+
interval: 30,
|
|
31
|
+
timeout: 5,
|
|
32
|
+
retries: 3,
|
|
33
|
+
startPeriod: 10,
|
|
34
|
+
},
|
|
35
|
+
logConfiguration: {
|
|
36
|
+
logDriver: "awslogs",
|
|
37
|
+
options: {
|
|
38
|
+
"awslogs-group": output("log-group", "name"),
|
|
39
|
+
"awslogs-region": context.region,
|
|
40
|
+
"awslogs-stream-prefix": "relkit",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function image(context) {
|
|
46
|
+
const image = context.plan.application.image;
|
|
47
|
+
if (image.digest !== undefined)
|
|
48
|
+
return `${image.name}@${image.digest}`;
|
|
49
|
+
if (image.name.slice(image.name.lastIndexOf("/") + 1).includes(":"))
|
|
50
|
+
return image.name;
|
|
51
|
+
const tag = image.tag ?? "latest";
|
|
52
|
+
return image.name.includes("/")
|
|
53
|
+
? `${image.name}:${tag}`
|
|
54
|
+
: deploymentJoin(output("registry", "repositoryUrl"), `:${tag}`);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=service-support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-support.js","sourceRoot":"","sources":["../../src/host/service-support.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAGf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAoB,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEjE,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,CAAC;IACxC,OAAO,EAAE,YAAY;IACrB,SAAS,EAAE;QACT;YACE,MAAM,EAAE,OAAO;YACf,SAAS,EAAE,EAAE,OAAO,EAAE,yBAAyB,EAAE;YACjD,MAAM,EAAE,gBAAgB;SACzB;KACF;CACF,CAAC,CAAC;AAEH,MAAM,UAAU,IAAI,CAAC,OAAoB,EAAE,EAAU;IACnD,OAAO,QAAQ,CACb,OAAO,EACP,EAAE,EACF,mBAAmB,EACnB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,IAAI,E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CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC;IACvF,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI,QAAQ,CAAC;IAClC,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC7B,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,GAAG,EAAE;QACxB,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type DeploymentHostMaterialization } from "@relkit/deploy";
|
|
2
|
+
import { type HostContext } from "./shared.js";
|
|
3
|
+
export declare function service(context: HostContext, network: DeploymentHostMaterialization["network"]): Pick<DeploymentHostMaterialization, "resources" | "workload" | "outputs">;
|
|
4
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/host/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,6BAA6B,EAEnC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,WAAW,EAA0B,MAAM,aAAa,CAAC;AAKvE,wBAAgB,OAAO,CACrB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,6BAA6B,CAAC,SAAS,CAAC,GAChD,IAAI,CAAC,6BAA6B,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC,CA0I3E"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { deploymentJoin, deploymentJson, } from "@relkit/deploy";
|
|
2
|
+
import { name, output, resource } from "./shared.js";
|
|
3
|
+
import { container, role } from "./service-support.js";
|
|
4
|
+
const EXECUTION_POLICY = "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy";
|
|
5
|
+
export function service(context, network) {
|
|
6
|
+
const resources = [
|
|
7
|
+
resource(context, "registry", "aws:ecr/repository:Repository", {
|
|
8
|
+
imageTagMutability: "IMMUTABLE",
|
|
9
|
+
imageScanningConfiguration: { scanOnPush: true },
|
|
10
|
+
forceDelete: false,
|
|
11
|
+
tags: context.tags,
|
|
12
|
+
}, ["arn", "repositoryUrl"]),
|
|
13
|
+
resource(context, "log-group", "aws:cloudwatch/logGroup:LogGroup", { retentionInDays: 30, tags: context.tags }, ["arn", "name"]),
|
|
14
|
+
role(context, "execution-role"),
|
|
15
|
+
resource(context, "execution-policy", "aws:iam/rolePolicyAttachment:RolePolicyAttachment", {
|
|
16
|
+
role: output("execution-role", "name"),
|
|
17
|
+
policyArn: EXECUTION_POLICY,
|
|
18
|
+
}),
|
|
19
|
+
role(context, "task-role"),
|
|
20
|
+
resource(context, "cluster", "aws:ecs/cluster:Cluster", { settings: [{ name: "containerInsights", value: "enabled" }], tags: context.tags }, ["arn", "name"]),
|
|
21
|
+
resource(context, "target-group", "aws:lb/targetGroup:TargetGroup", {
|
|
22
|
+
vpcId: network.vpcId,
|
|
23
|
+
targetType: "ip",
|
|
24
|
+
port: context.plan.http.port,
|
|
25
|
+
protocol: "HTTP",
|
|
26
|
+
deregistrationDelay: 30,
|
|
27
|
+
healthCheck: {
|
|
28
|
+
enabled: true,
|
|
29
|
+
path: context.plan.http.health.readinessPath,
|
|
30
|
+
protocol: "HTTP",
|
|
31
|
+
matcher: "200-399",
|
|
32
|
+
},
|
|
33
|
+
tags: context.tags,
|
|
34
|
+
}, ["arn"]),
|
|
35
|
+
resource(context, "load-balancer", "aws:lb/loadBalancer:LoadBalancer", {
|
|
36
|
+
loadBalancerType: "application",
|
|
37
|
+
internal: false,
|
|
38
|
+
securityGroups: [output("alb-security-group", "id")],
|
|
39
|
+
subnets: network.subnetIds,
|
|
40
|
+
tags: context.tags,
|
|
41
|
+
}, ["arn", "dnsName"]),
|
|
42
|
+
resource(context, "listener", "aws:lb/listener:Listener", {
|
|
43
|
+
loadBalancerArn: output("load-balancer", "arn"),
|
|
44
|
+
port: 80,
|
|
45
|
+
protocol: "HTTP",
|
|
46
|
+
defaultActions: [{ type: "forward", targetGroupArn: output("target-group", "arn") }],
|
|
47
|
+
}, ["arn"]),
|
|
48
|
+
resource(context, "task-definition", "aws:ecs/taskDefinition:TaskDefinition", {
|
|
49
|
+
family: name(`${context.prefix}-task`),
|
|
50
|
+
requiresCompatibilities: ["FARGATE"],
|
|
51
|
+
networkMode: "awsvpc",
|
|
52
|
+
cpu: "256",
|
|
53
|
+
memory: "512",
|
|
54
|
+
executionRoleArn: output("execution-role", "arn"),
|
|
55
|
+
taskRoleArn: output("task-role", "arn"),
|
|
56
|
+
containerDefinitions: deploymentJson([container(context)]),
|
|
57
|
+
tags: context.tags,
|
|
58
|
+
}, ["arn"], ["execution-policy"]),
|
|
59
|
+
resource(context, "service", "aws:ecs/service:Service", {
|
|
60
|
+
cluster: output("cluster", "arn"),
|
|
61
|
+
taskDefinition: output("task-definition", "arn"),
|
|
62
|
+
launchType: "FARGATE",
|
|
63
|
+
desiredCount: 1,
|
|
64
|
+
healthCheckGracePeriodSeconds: 60,
|
|
65
|
+
deploymentCircuitBreaker: { enable: true, rollback: true },
|
|
66
|
+
networkConfiguration: {
|
|
67
|
+
assignPublicIp: true,
|
|
68
|
+
subnets: network.subnetIds,
|
|
69
|
+
securityGroups: [network.serviceSecurityGroupId],
|
|
70
|
+
},
|
|
71
|
+
loadBalancers: [
|
|
72
|
+
{
|
|
73
|
+
targetGroupArn: output("target-group", "arn"),
|
|
74
|
+
containerName: "app",
|
|
75
|
+
containerPort: context.plan.http.port,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
tags: context.tags,
|
|
79
|
+
}, ["name"], ["listener"]),
|
|
80
|
+
];
|
|
81
|
+
return {
|
|
82
|
+
resources,
|
|
83
|
+
workload: {
|
|
84
|
+
roleName: output("task-role", "name"),
|
|
85
|
+
roleArn: output("task-role", "arn"),
|
|
86
|
+
},
|
|
87
|
+
outputs: {
|
|
88
|
+
endpoint: deploymentJoin("http://", output("load-balancer", "dnsName")),
|
|
89
|
+
registryUrl: output("registry", "repositoryUrl"),
|
|
90
|
+
logGroupName: output("log-group", "name"),
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/host/service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,GAGf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAoB,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,gBAAgB,GAAG,uEAAuE,CAAC;AAEjG,MAAM,UAAU,OAAO,CACrB,OAAoB,EACpB,OAAiD;IAEjD,MAAM,SAAS,GAAkC;QAC/C,QAAQ,CACN,OAAO,EACP,UAAU,EACV,+BAA+B,EAC/B;YACE,kBAAkB,EAAE,WAAW;YAC/B,0BAA0B,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;YAChD,WAAW,EAAE,KAAK;YAClB,IAAI,EAAE,OAAO,CAAC,IAAI;SACnB,EACD,CAAC,KAAK,EAAE,eAAe,CAAC,CACzB;QACD,QAAQ,CACN,OAAO,EACP,WAAW,EACX,kCAAkC,EAClC,EAAE,eAAe,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAC3C,CAAC,KAAK,EAAE,MAAM,CAAC,CAChB;QACD,IAAI,CAAC,OAAO,EAAE,gBAAgB,CAAC;QAC/B,QAAQ,CAAC,OAAO,EAAE,kBAAkB,EAAE,mDAAmD,EAAE;YACzF,IAAI,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC;YACtC,SAAS,EA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AAI,CAAC,IAAI,CAAC,IAAI;iBACtC;aACF;YACD,IAAI,EAAE,OAAO,CAAC,IAAI;SACnB,EACD,CAAC,MAAM,CAAC,EACR,CAAC,UAAU,CAAC,CACb;KACF,CAAC;IACF,OAAO;QACL,SAAS;QACT,QAAQ,EAAE;YACR,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC;YACrC,OAAO,EAAE,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC;SACpC;QACD,OAAO,EAAE;YACP,QAAQ,EAAE,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;YACvE,WAAW,EAAE,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC;YAChD,YAAY,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC;SAC1C;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type DeploymentInput, type DeploymentPlan, type DeploymentResourceOperation } from "@relkit/deploy";
|
|
2
|
+
export interface HostContext {
|
|
3
|
+
readonly plan: DeploymentPlan;
|
|
4
|
+
readonly stackName: string;
|
|
5
|
+
readonly prefix: string;
|
|
6
|
+
readonly tags: Readonly<Record<string, string>>;
|
|
7
|
+
readonly region: DeploymentInput;
|
|
8
|
+
}
|
|
9
|
+
export declare function hostContext(plan: DeploymentPlan, stackName: string): HostContext;
|
|
10
|
+
export declare function resource(context: HostContext, id: string, type: string, inputs: Readonly<Record<string, DeploymentInput>>, outputs?: readonly string[], dependsOn?: readonly string[]): DeploymentResourceOperation;
|
|
11
|
+
export declare function hostId(id: string): string;
|
|
12
|
+
export declare function output(id: string, property: string): DeploymentInput;
|
|
13
|
+
export declare function name(value: string, max?: number): string;
|
|
14
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/host/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,2BAA2B,EACjC,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;CAClC;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,GAAG,WAAW,CAchF;AAED,wBAAgB,QAAQ,CACtB,OAAO,EAAE,WAAW,EACpB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,EACjD,OAAO,GAAE,SAAS,MAAM,EAAO,EAC/B,SAAS,GAAE,SAAS,MAAM,EAAO,GAChC,2BAA2B,CAU7B;AAED,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,CAEpE;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAK,GAAG,MAAM,CAUpD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { deploymentConfiguration, deploymentOutput, } from "@relkit/deploy";
|
|
2
|
+
export function hostContext(plan, stackName) {
|
|
3
|
+
const prefix = name(`${stackName}-${plan.application.id}`);
|
|
4
|
+
return {
|
|
5
|
+
plan,
|
|
6
|
+
stackName,
|
|
7
|
+
prefix,
|
|
8
|
+
tags: {
|
|
9
|
+
app: plan.application.id,
|
|
10
|
+
stack: stackName,
|
|
11
|
+
graphHash: plan.graphHash,
|
|
12
|
+
"managed-by": "relkit",
|
|
13
|
+
},
|
|
14
|
+
region: deploymentConfiguration("aws:region", { fallback: "us-east-1" }),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function resource(context, id, type, inputs, outputs = [], dependsOn = []) {
|
|
18
|
+
return {
|
|
19
|
+
kind: "deployment-resource",
|
|
20
|
+
id: hostId(id),
|
|
21
|
+
type,
|
|
22
|
+
name: name(`${context.prefix}-${id}`),
|
|
23
|
+
inputs,
|
|
24
|
+
...(outputs.length === 0 ? {} : { outputs }),
|
|
25
|
+
...(dependsOn.length === 0 ? {} : { dependsOn: dependsOn.map(hostId) }),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function hostId(id) {
|
|
29
|
+
return `aws.host.${id}`;
|
|
30
|
+
}
|
|
31
|
+
export function output(id, property) {
|
|
32
|
+
return deploymentOutput(hostId(id), property);
|
|
33
|
+
}
|
|
34
|
+
export function name(value, max = 63) {
|
|
35
|
+
return (value
|
|
36
|
+
.toLowerCase()
|
|
37
|
+
.replace(/[^a-z0-9-]+/g, "-")
|
|
38
|
+
.replace(/^-+/, "")
|
|
39
|
+
.replace(/(?<!-)-+$/, "")
|
|
40
|
+
.slice(0, max)
|
|
41
|
+
.replace(/-+$/g, "") || "relkit");
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/host/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,gBAAgB,GAIjB,MAAM,gBAAgB,CAAC;AAUxB,MAAM,UAAU,WAAW,CAAC,IAAoB,EAAE,SAAiB;IACjE,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3D,OAAO;QACL,I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AG,CAAC;SAC5B,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;SAClB,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;SACxB,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;SACb,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,QAAQ,CACnC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const awsInfrastructure: Readonly<{
|
|
2
|
+
kind: "deployment-integration";
|
|
3
|
+
protocolVersion: 1;
|
|
4
|
+
integrationId: "aws";
|
|
5
|
+
role: "infrastructure";
|
|
6
|
+
materialize: (input: {
|
|
7
|
+
readonly plan: import("@relkit/deploy").DeploymentPlan;
|
|
8
|
+
readonly stackName: string;
|
|
9
|
+
readonly operation: import("@relkit/deploy").InfrastructureOperationPlan;
|
|
10
|
+
readonly host: import("@relkit/deploy").DeploymentHostMaterialization;
|
|
11
|
+
}) => import("@relkit/deploy").DeploymentInfrastructureMaterialization;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const deploymentIntegration: Readonly<{
|
|
14
|
+
kind: "deployment-integration";
|
|
15
|
+
protocolVersion: 1;
|
|
16
|
+
integrationId: "aws";
|
|
17
|
+
role: "infrastructure";
|
|
18
|
+
materialize: (input: {
|
|
19
|
+
readonly plan: import("@relkit/deploy").DeploymentPlan;
|
|
20
|
+
readonly stackName: string;
|
|
21
|
+
readonly operation: import("@relkit/deploy").InfrastructureOperationPlan;
|
|
22
|
+
readonly host: import("@relkit/deploy").DeploymentHostMaterialization;
|
|
23
|
+
}) => import("@relkit/deploy").DeploymentInfrastructureMaterialization;
|
|
24
|
+
}>;
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/infrastructure/index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,iBAAiB;;;;;;;;;;;EAMkB,CAAC;AAEjD,eAAO,MAAM,qBAAqB;;;;;;;;;;;EAAoB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DEPLOYMENT_INTEGRATION_PROTOCOL_VERSION, } from "@relkit/deploy";
|
|
2
|
+
import { materializeAwsInfrastructure } from "./materialize.js";
|
|
3
|
+
export const awsInfrastructure = Object.freeze({
|
|
4
|
+
kind: "deployment-integration",
|
|
5
|
+
protocolVersion: DEPLOYMENT_INTEGRATION_PROTOCOL_VERSION,
|
|
6
|
+
integrationId: "aws",
|
|
7
|
+
role: "infrastructure",
|
|
8
|
+
materialize: materializeAwsInfrastructure,
|
|
9
|
+
});
|
|
10
|
+
export const deploymentIntegration = awsInfrastructure;
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/infrastructure/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uCAAuC,GAExC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAEhE,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7C,IAAI,EAAE,wBAAwB;IAC9B,eAAe,EAAE,uCAAuC;IACxD,aAAa,EAAE,KAAK;IACpB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,4BAA4B;CAC1C,CAA+C,CAAC;AAEjD,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"materialize.d.ts","sourceRoot":"","sources":["../../src/infrastructure/materialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,gBAAgB,CAAC;AAI1E,eAAO,MAAM,4BAA4B,EAAE,mCAAmC,CAAC,aAAa,CAU3F,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { materializeRedis } from "./redis.js";
|
|
2
|
+
import { materializeS3 } from "./s3.js";
|
|
3
|
+
export const materializeAwsInfrastructure = (input) => {
|
|
4
|
+
if (input.operation.capability === "bucket")
|
|
5
|
+
return materializeS3(input.plan, input.stackName, input.operation);
|
|
6
|
+
if (input.operation.capability === "cache")
|
|
7
|
+
return materializeRedis(input.plan, input.stackName, input.operation, input.host);
|
|
8
|
+
throw new TypeError(`AWS does not support infrastructure capability "${input.operation.capability}".`);
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=materialize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"materialize.js","sourceRoot":"","sources":["../../src/infrastructure/materialize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,MAAM,CAAC,MAAM,4BAA4B,GAAuD,CAC9F,KAAK,EACL,EAAE;IACF,IAAI,KAAK,CAAC,SAAS,CAAC,UAAU,KAAK,QAAQ;QACzC,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IACrE,IAAI,KAAK,CAAC,SAAS,CAAC,UAAU,KAAK,OAAO;QACxC,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACpF,MAAM,IAAI,SAAS,CACjB,mDAAmD,KAAK,CAAC,SAAS,CAAC,UAAU,IAAI,CAClF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type DeploymentHostMaterialization, type DeploymentInfrastructureMaterialization, type DeploymentPlan, type InfrastructureOperationPlan } from "@relkit/deploy";
|
|
2
|
+
export declare function materializeRedis(plan: DeploymentPlan, stackName: string, operation: InfrastructureOperationPlan, host: DeploymentHostMaterialization): DeploymentInfrastructureMaterialization;
|
|
3
|
+
//# sourceMappingURL=redis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/infrastructure/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,6BAA6B,EAClC,KAAK,uCAAuC,EAC5C,KAAK,cAAc,EACnB,KAAK,2BAA2B,EACjC,MAAM,gBAAgB,CAAC;AAGxB,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,cAAc,EACpB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,2BAA2B,EACtC,IAAI,EAAE,6BAA6B,GAClC,uCAAuC,CAkEzC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { deploymentJoin, } from "@relkit/deploy";
|
|
2
|
+
import { assertAdapter, context, name, output, resource, settings } from "./shared.js";
|
|
3
|
+
export function materializeRedis(plan, stackName, operation, host) {
|
|
4
|
+
assertAdapter(operation, "cache", "redis", ["atomicIncrement"]);
|
|
5
|
+
const value = context(plan.application.id, plan.graphHash, stackName, operation);
|
|
6
|
+
const options = settings(operation.integration.configuration);
|
|
7
|
+
const engine = options.engine ?? "valkey";
|
|
8
|
+
const nodeType = options.nodeType ?? "cache.t4g.micro";
|
|
9
|
+
const replicas = options.replicas ?? 0;
|
|
10
|
+
assertOptions(engine, nodeType, replicas, options);
|
|
11
|
+
const resources = [
|
|
12
|
+
resource(value, "security-group", "aws:ec2/securityGroup:SecurityGroup", {
|
|
13
|
+
vpcId: host.network.vpcId,
|
|
14
|
+
description: "RelKit managed cache",
|
|
15
|
+
egress: [{ fromPort: 0, toPort: 0, protocol: "-1", cidrBlocks: ["0.0.0.0/0"] }],
|
|
16
|
+
tags: value.tags,
|
|
17
|
+
}, ["id"]),
|
|
18
|
+
resource(value, "subnet-group", "aws:elasticache/subnetGroup:SubnetGroup", { subnetIds: host.network.subnetIds, tags: value.tags }, ["name"]),
|
|
19
|
+
resource(value, "replication-group", "aws:elasticache/replicationGroup:ReplicationGroup", {
|
|
20
|
+
replicationGroupId: name(value.prefix, 40),
|
|
21
|
+
description: `RelKit ${operation.bindingId}`,
|
|
22
|
+
engine: engine,
|
|
23
|
+
nodeType: nodeType,
|
|
24
|
+
numCacheClusters: Number(replicas) + 1,
|
|
25
|
+
automaticFailoverEnabled: Number(replicas) > 0,
|
|
26
|
+
multiAzEnabled: Number(replicas) > 0,
|
|
27
|
+
transitEncryptionEnabled: true,
|
|
28
|
+
atRestEncryptionEnabled: true,
|
|
29
|
+
port: 6379,
|
|
30
|
+
subnetGroupName: output(value, "subnet-group", "name"),
|
|
31
|
+
securityGroupIds: [output(value, "security-group", "id")],
|
|
32
|
+
tags: value.tags,
|
|
33
|
+
}, ["arn", "primaryEndpointAddress", "port"]),
|
|
34
|
+
];
|
|
35
|
+
return {
|
|
36
|
+
resources,
|
|
37
|
+
connection: {
|
|
38
|
+
url: deploymentJoin("rediss://", output(value, "replication-group", "primaryEndpointAddress"), ":", output(value, "replication-group", "port")),
|
|
39
|
+
},
|
|
40
|
+
access: {
|
|
41
|
+
securityGroupId: output(value, "security-group", "id"),
|
|
42
|
+
port: 6379,
|
|
43
|
+
cacheArn: output(value, "replication-group", "arn"),
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function assertOptions(engine, nodeType, replicas, options) {
|
|
48
|
+
for (const key of Object.keys(options))
|
|
49
|
+
if (!["engine", "nodeType", "replicas"].includes(key))
|
|
50
|
+
throw new TypeError(`Unknown AWS Redis option "${key}".`);
|
|
51
|
+
if (engine !== "valkey" && engine !== "redis")
|
|
52
|
+
throw new TypeError("AWS Redis engine is invalid.");
|
|
53
|
+
if (typeof nodeType !== "string" || !/^cache\.[a-z0-9.-]+$/i.test(nodeType))
|
|
54
|
+
throw new TypeError("AWS Redis nodeType is invalid.");
|
|
55
|
+
if (!Number.isSafeInteger(replicas) || Number(replicas) < 0 || Number(replicas) > 5)
|
|
56
|
+
throw new TypeError("AWS Redis replicas are invalid.");
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=redis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../../src/infrastructure/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAKf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvF,MAAM,UAAU,gBAAgB,CAC9B,IAAoB,EACpB,SAAiB,EACjB,SAAsC,EACtC,IAAmC;IAEnC,aAAa,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAChE,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IACjF,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,QAAQ,CAAC;IAC1C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,iBAAiB,CAAC;IACvD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC;IACvC,aAAa,CAAC,MAA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CAAiC,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type DeploymentInfrastructureMaterialization, type DeploymentPlan, type InfrastructureOperationPlan } from "@relkit/deploy";
|
|
2
|
+
export declare function materializeS3(plan: DeploymentPlan, stackName: string, operation: InfrastructureOperationPlan): DeploymentInfrastructureMaterialization;
|
|
3
|
+
//# sourceMappingURL=s3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3.d.ts","sourceRoot":"","sources":["../../src/infrastructure/s3.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uCAAuC,EAC5C,KAAK,cAAc,EACnB,KAAK,2BAA2B,EACjC,MAAM,gBAAgB,CAAC;AAGxB,wBAAgB,aAAa,CAC3B,IAAI,EAAE,cAAc,EACpB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,2BAA2B,GACrC,uCAAuC,CA0BzC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { deploymentJoin, } from "@relkit/deploy";
|
|
2
|
+
import { assertAdapter, context, output, resource, settings } from "./shared.js";
|
|
3
|
+
export function materializeS3(plan, stackName, operation) {
|
|
4
|
+
assertAdapter(operation, "bucket", "s3", ["signedReadUrl", "signedWriteUrl"]);
|
|
5
|
+
const value = context(plan.application.id, plan.graphHash, stackName, operation);
|
|
6
|
+
const options = settings(operation.integration.configuration);
|
|
7
|
+
assertOptions(options);
|
|
8
|
+
const bucket = resource(value, "bucket", "aws:s3/bucket:Bucket", {
|
|
9
|
+
forceDestroy: options.forceDestroy === true,
|
|
10
|
+
versioning: { enabled: options.versioning === true },
|
|
11
|
+
tags: value.tags,
|
|
12
|
+
}, ["arn", "bucket", "region"]);
|
|
13
|
+
const arn = output(value, "bucket", "arn");
|
|
14
|
+
return {
|
|
15
|
+
resources: [bucket],
|
|
16
|
+
connection: {
|
|
17
|
+
endpoint: deploymentJoin("https://s3.", value.region, ".amazonaws.com"),
|
|
18
|
+
bucketName: output(value, "bucket", "bucket"),
|
|
19
|
+
region: output(value, "bucket", "region"),
|
|
20
|
+
},
|
|
21
|
+
access: { bucketArn: arn, objectArn: deploymentJoin(arn, "/*") },
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function assertOptions(options) {
|
|
25
|
+
for (const key of Object.keys(options))
|
|
26
|
+
if (key !== "versioning" && key !== "forceDestroy")
|
|
27
|
+
throw new TypeError(`Unknown AWS S3 option "${key}".`);
|
|
28
|
+
for (const key of ["versioning", "forceDestroy"])
|
|
29
|
+
if (options[key] !== undefined && typeof options[key] !== "boolean")
|
|
30
|
+
throw new TypeError(`AWS S3 ${key} must be a boolean.`);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=s3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3.js","sourceRoot":"","sources":["../../src/infrastructure/s3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAIf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEjF,MAAM,UAAU,aAAa,CAC3B,IAAoB,EACpB,SAAiB,EACjB,SAAsC;IAEtC,aAAa,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAC9E,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IACjF,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAC9D,aAAa,CAAC,OAAO,CAAC,CAAC;IACvB,MAAM,MAAM,GAAG,QAAQ,CACrB,KAAK,EACL,QAAQ,EACR,sBAAsB,EACtB;QACE,YAAY,EAAE,OA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Plan } from "@relkit/deploy";
|
|
2
|
+
export interface InfrastructureContext {
|
|
3
|
+
readonly stackName: string;
|
|
4
|
+
readonly operation: InfrastructureOperationPlan;
|
|
5
|
+
readonly prefix: string;
|
|
6
|
+
readonly tags: Readonly<Record<string, string>>;
|
|
7
|
+
readonly region: DeploymentInput;
|
|
8
|
+
}
|
|
9
|
+
export declare function context(appId: string, graphHash: string, stackName: string, operation: InfrastructureOperationPlan): InfrastructureContext;
|
|
10
|
+
export declare function resource(context: InfrastructureContext, suffix: string, type: string, inputs: Readonly<Record<string, DeploymentInput>>, outputs?: readonly string[]): DeploymentResourceOperation;
|
|
11
|
+
export declare function output(context: InfrastructureContext, suffix: string, property: string): DeploymentInput;
|
|
12
|
+
export declare function id(context: InfrastructureContext, suffix: string): string;
|
|
13
|
+
export declare function name(value: string, max?: number): string;
|
|
14
|
+
export declare function settings(value: unknown): Readonly<Record<string, unknown>>;
|
|
15
|
+
export declare function assertAdapter(operation: InfrastructureOperationPlan, capability: string, adapterId: string, features: readonly string[]): void;
|
|
16
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/infrastructure/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EACjC,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,2BAA2B,CAAC;IAChD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;CAClC;AAED,wBAAgB,OAAO,CACrB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,2BAA2B,GACrC,qBAAqB,CAQvB;AAED,wBAAgB,QAAQ,CACtB,OAAO,EAAE,qBAAqB,EAC9B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,EACjD,OAAO,GAAE,SAAS,MAAM,EAAO,GAC9B,2BAA2B,CAS7B;AAED,wBAAgB,MAAM,CACpB,OAAO,EAAE,qBAAqB,EAC9B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,eAAe,CAEjB;AAED,wBAAgB,EAAE,CAAC,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAK,GAAG,MAAM,CAUpD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAI1E;AAED,wBAAgB,aAAa,CAC3B,SAAS,EAAE,2BAA2B,EACtC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,SAAS,MAAM,EAAE,GAC1B,IAAI,CAWN"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { deploymentConfiguration, deploymentOutput, } from "@relkit/deploy";
|
|
2
|
+
export function context(appId, graphHash, stackName, operation) {
|
|
3
|
+
return {
|
|
4
|
+
stackName,
|
|
5
|
+
operation,
|
|
6
|
+
prefix: name(`${stackName}-${appId}-${operation.bindingId}`),
|
|
7
|
+
tags: { app: appId, stack: stackName, graphHash, "managed-by": "relkit" },
|
|
8
|
+
region: deploymentConfiguration("aws:region", { fallback: "us-east-1" }),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export function resource(context, suffix, type, inputs, outputs = []) {
|
|
12
|
+
return {
|
|
13
|
+
kind: "deployment-resource",
|
|
14
|
+
id: id(context, suffix),
|
|
15
|
+
type,
|
|
16
|
+
name: name(`${context.prefix}-${suffix}`),
|
|
17
|
+
inputs,
|
|
18
|
+
...(outputs.length === 0 ? {} : { outputs }),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function output(context, suffix, property) {
|
|
22
|
+
return deploymentOutput(id(context, suffix), property);
|
|
23
|
+
}
|
|
24
|
+
export function id(context, suffix) {
|
|
25
|
+
return `aws.infrastructure.${context.operation.bindingId}.${suffix}`;
|
|
26
|
+
}
|
|
27
|
+
export function name(value, max = 63) {
|
|
28
|
+
return (value
|
|
29
|
+
.toLowerCase()
|
|
30
|
+
.replace(/[^a-z0-9-]+/g, "-")
|
|
31
|
+
.replace(/^-+/, "")
|
|
32
|
+
.replace(/(?<!-)-+$/, "")
|
|
33
|
+
.slice(0, max)
|
|
34
|
+
.replace(/-+$/g, "") || "relkit");
|
|
35
|
+
}
|
|
36
|
+
export function settings(value) {
|
|
37
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
38
|
+
? value
|
|
39
|
+
: {};
|
|
40
|
+
}
|
|
41
|
+
export function assertAdapter(operation, capability, adapterId, features) {
|
|
42
|
+
if (operation.capability !== capability ||
|
|
43
|
+
operation.adapter.integrationId !== adapterId ||
|
|
44
|
+
operation.adapter.adapterId !== adapterId ||
|
|
45
|
+
operation.adapter.protocolVersion !== 1 ||
|
|
46
|
+
operation.adapter.features.some((feature) => !features.includes(feature)))
|
|
47
|
+
throw new TypeError(`AWS does not support ${operation.capability}:${operation.adapter.integrationId}:${operation.adapter.adapterId}.`);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/infrastructure/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBA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
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/rel-kit/relkit.git",
|
|
9
|
+
"directory": "integrations/packages/aws"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/rel-kit/relkit#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/rel-kit/relkit/issues"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"bun": ">=1.3.10"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./host": {
|
|
31
|
+
"types": "./dist/host/index.d.ts",
|
|
32
|
+
"import": "./dist/host/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./infrastructure": {
|
|
35
|
+
"types": "./dist/infrastructure/index.d.ts",
|
|
36
|
+
"import": "./dist/infrastructure/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./access": {
|
|
39
|
+
"types": "./dist/access/index.d.ts",
|
|
40
|
+
"import": "./dist/access/index.js"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"relkit": {
|
|
44
|
+
"integration": {
|
|
45
|
+
"id": "aws",
|
|
46
|
+
"exports": {
|
|
47
|
+
"authoring": ".",
|
|
48
|
+
"host": "./host",
|
|
49
|
+
"infrastructure": "./infrastructure",
|
|
50
|
+
"access": "./access"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsc -b",
|
|
56
|
+
"check": "tsc -b --pretty false",
|
|
57
|
+
"typecheck": "tsc -b --pretty false"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@pulumi/aws": "7.43.0",
|
|
61
|
+
"@relkit/deploy": "0.3.0",
|
|
62
|
+
"@relkit/provider": "0.3.0"
|
|
63
|
+
}
|
|
64
|
+
}
|