@aws/agentcore-cdk 0.1.0-alpha.44 → 0.1.0-alpha.46
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/cdk/constructs/bundling/container/ContainerSourceAsset.d.ts +21 -4
- package/dist/cdk/constructs/bundling/container/ContainerSourceAsset.d.ts.map +1 -1
- package/dist/cdk/constructs/bundling/container/ContainerSourceAsset.js +69 -6
- package/dist/cdk/constructs/bundling/container/ContainerSourceAsset.js.map +1 -1
- package/dist/cdk/constructs/components/container/ContainerBuildProject.d.ts +3 -0
- package/dist/cdk/constructs/components/container/ContainerBuildProject.d.ts.map +1 -1
- package/dist/cdk/constructs/components/container/ContainerBuildProject.js +7 -1
- package/dist/cdk/constructs/components/container/ContainerBuildProject.js.map +1 -1
- package/dist/cdk/constructs/components/container/ContainerImageBuilder.d.ts +10 -3
- package/dist/cdk/constructs/components/container/ContainerImageBuilder.d.ts.map +1 -1
- package/dist/cdk/constructs/components/container/ContainerImageBuilder.js +33 -5
- package/dist/cdk/constructs/components/container/ContainerImageBuilder.js.map +1 -1
- package/dist/cdk/constructs/components/container/container-build-handler.d.ts +4 -1
- package/dist/cdk/constructs/components/container/container-build-handler.d.ts.map +1 -1
- package/dist/cdk/constructs/components/container/container-build-handler.js +14 -0
- package/dist/cdk/constructs/components/container/container-build-handler.js.map +1 -1
- package/dist/cdk/constructs/components/mcp/Gateway.d.ts.map +1 -1
- package/dist/cdk/constructs/components/mcp/Gateway.js +30 -1
- package/dist/cdk/constructs/components/mcp/Gateway.js.map +1 -1
- package/dist/cdk/constructs/l3/AgentEnvironment.d.ts.map +1 -1
- package/dist/cdk/constructs/l3/AgentEnvironment.js +3 -0
- package/dist/cdk/constructs/l3/AgentEnvironment.js.map +1 -1
- package/dist/lib/packaging/helpers.d.ts +15 -0
- package/dist/lib/packaging/helpers.d.ts.map +1 -1
- package/dist/lib/packaging/helpers.js +26 -6
- package/dist/lib/packaging/helpers.js.map +1 -1
- package/dist/lib/packaging/index.d.ts +1 -1
- package/dist/lib/packaging/index.d.ts.map +1 -1
- package/dist/lib/packaging/index.js +3 -1
- package/dist/lib/packaging/index.js.map +1 -1
- package/dist/schema/schemas/agent-env.d.ts +13 -0
- package/dist/schema/schemas/agent-env.d.ts.map +1 -1
- package/dist/schema/schemas/agent-env.js +104 -15
- package/dist/schema/schemas/agent-env.js.map +1 -1
- package/dist/schema/schemas/agentcore-project.d.ts +4 -0
- package/dist/schema/schemas/agentcore-project.d.ts.map +1 -1
- package/dist/schema/schemas/mcp.d.ts +3 -0
- package/dist/schema/schemas/mcp.d.ts.map +1 -1
- package/dist/schema/schemas/mcp.js +1 -0
- package/dist/schema/schemas/mcp.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,11 +8,28 @@ export interface ContainerSourceAssetProps {
|
|
|
8
8
|
readonly config: AgentEnvSpec;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* Packages the
|
|
11
|
+
* Packages the Docker build context (including the Dockerfile) as an S3 asset for CodeBuild.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* The uploaded directory is `buildContextPath` when set, otherwise `codeLocation`. It becomes both
|
|
14
|
+
* the `docker build` context (the `.` in the buildspec) and the root the Dockerfile path is resolved
|
|
15
|
+
* against, so a shared Dockerfile in a monorepo can COPY files that live outside the agent's own
|
|
16
|
+
* `codeLocation`.
|
|
17
|
+
*
|
|
18
|
+
* The uploaded context's `exclude` list (evaluated with `IgnoreMode.DOCKER`, last match wins) layers:
|
|
19
|
+
* 1. {@link CONTAINER_CONTEXT_SECRET_EXCLUDES} — an unconditional secret/junk baseline applied to
|
|
20
|
+
* BOTH `codeLocation` and `buildContextPath` builds, so a stray `.env` / `.git` / `node_modules`
|
|
21
|
+
* is never persisted to the assets bucket or baked into the image (mirrors the CodeZip guard);
|
|
22
|
+
* 2. the user's own build-context-root `.dockerignore`, so they can exclude more or re-include a
|
|
23
|
+
* baseline path with a `!pattern` line;
|
|
24
|
+
* 3. {@link forceKeepDockerfilePatterns} — a force-keep of the Dockerfile (+ ancestor dirs) so an
|
|
25
|
+
* allowlist-style `.dockerignore` can't drop the file CodeBuild builds with.
|
|
26
|
+
*
|
|
27
|
+
* NOTE: applying the baseline unconditionally changes the asset hash for pre-existing container stacks
|
|
28
|
+
* (which previously uploaded the raw directory), so the first deploy after upgrade re-uploads the
|
|
29
|
+
* context and rebuilds the image once. This is intentional — it is what closes the secret-leak.
|
|
30
|
+
*
|
|
31
|
+
* Unlike BundledCodeZipAsset which packages code into a zip with dependencies, this uploads the
|
|
32
|
+
* directory as-is; CodeBuild uses the Dockerfile within it to build the container image.
|
|
16
33
|
*/
|
|
17
34
|
export declare class ContainerSourceAsset extends Construct {
|
|
18
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContainerSourceAsset.d.ts","sourceRoot":"","sources":["../../../../../src/cdk/constructs/bundling/container/ContainerSourceAsset.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ContainerSourceAsset.d.ts","sourceRoot":"","sources":["../../../../../src/cdk/constructs/bundling/container/ContainerSourceAsset.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC/B;AAsCD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;IACjD;;OAEG;IACH,SAAgB,KAAK,EAAE,KAAK,CAAC;gBAEjB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB;CAuB3E"}
|
|
@@ -2,14 +2,68 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ContainerSourceAsset = void 0;
|
|
4
4
|
const lib_1 = require("../../../../lib");
|
|
5
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
5
6
|
const aws_s3_assets_1 = require("aws-cdk-lib/aws-s3-assets");
|
|
6
7
|
const constructs_1 = require("constructs");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = require("path");
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
11
|
+
* Read the `.dockerignore` at the build-context root and return its patterns (comments and blank
|
|
12
|
+
* lines stripped). Paired with `IgnoreMode.DOCKER` on the `Asset`, this makes the uploaded deploy
|
|
13
|
+
* context honor exactly what a local `docker build` from the same context would — the CDK `Asset`
|
|
14
|
+
* does not read `.dockerignore` on its own. Returns `[]` when there is no `.dockerignore`.
|
|
15
|
+
*/
|
|
16
|
+
function readDockerignorePatterns(contextRoot) {
|
|
17
|
+
const dockerignorePath = (0, path_1.join)(contextRoot, '.dockerignore');
|
|
18
|
+
if (!(0, fs_1.existsSync)(dockerignorePath)) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
return (0, fs_1.readFileSync)(dockerignorePath, 'utf-8')
|
|
22
|
+
.split(/\r?\n/)
|
|
23
|
+
.map(line => line.trim())
|
|
24
|
+
.filter(line => line.length > 0 && !line.startsWith('#'));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Force-keep the Dockerfile (and each of its ancestor directories) so an allowlist-style
|
|
28
|
+
* `.dockerignore` (`*` then `!keep`) — or any baseline/user pattern — can never drop the very file
|
|
29
|
+
* CodeBuild builds with (`-f`). Docker will not re-include a file whose parent directory is excluded,
|
|
30
|
+
* so each ancestor segment is negated too. Emitted last; in Docker semantics the last matching pattern
|
|
31
|
+
* wins, so these negations override any preceding exclude.
|
|
32
|
+
*/
|
|
33
|
+
function forceKeepDockerfilePatterns(dockerfileRelPath) {
|
|
34
|
+
const segments = dockerfileRelPath.split('/').filter(segment => segment.length > 0);
|
|
35
|
+
const patterns = [];
|
|
36
|
+
for (let i = 1; i < segments.length; i++) {
|
|
37
|
+
patterns.push(`!${segments.slice(0, i).join('/')}`);
|
|
38
|
+
}
|
|
39
|
+
if (segments.length > 0) {
|
|
40
|
+
patterns.push(`!${segments.join('/')}`);
|
|
41
|
+
}
|
|
42
|
+
return patterns;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Packages the Docker build context (including the Dockerfile) as an S3 asset for CodeBuild.
|
|
46
|
+
*
|
|
47
|
+
* The uploaded directory is `buildContextPath` when set, otherwise `codeLocation`. It becomes both
|
|
48
|
+
* the `docker build` context (the `.` in the buildspec) and the root the Dockerfile path is resolved
|
|
49
|
+
* against, so a shared Dockerfile in a monorepo can COPY files that live outside the agent's own
|
|
50
|
+
* `codeLocation`.
|
|
51
|
+
*
|
|
52
|
+
* The uploaded context's `exclude` list (evaluated with `IgnoreMode.DOCKER`, last match wins) layers:
|
|
53
|
+
* 1. {@link CONTAINER_CONTEXT_SECRET_EXCLUDES} — an unconditional secret/junk baseline applied to
|
|
54
|
+
* BOTH `codeLocation` and `buildContextPath` builds, so a stray `.env` / `.git` / `node_modules`
|
|
55
|
+
* is never persisted to the assets bucket or baked into the image (mirrors the CodeZip guard);
|
|
56
|
+
* 2. the user's own build-context-root `.dockerignore`, so they can exclude more or re-include a
|
|
57
|
+
* baseline path with a `!pattern` line;
|
|
58
|
+
* 3. {@link forceKeepDockerfilePatterns} — a force-keep of the Dockerfile (+ ancestor dirs) so an
|
|
59
|
+
* allowlist-style `.dockerignore` can't drop the file CodeBuild builds with.
|
|
60
|
+
*
|
|
61
|
+
* NOTE: applying the baseline unconditionally changes the asset hash for pre-existing container stacks
|
|
62
|
+
* (which previously uploaded the raw directory), so the first deploy after upgrade re-uploads the
|
|
63
|
+
* context and rebuilds the image once. This is intentional — it is what closes the secret-leak.
|
|
9
64
|
*
|
|
10
|
-
* Unlike BundledCodeZipAsset which packages code into a zip with dependencies,
|
|
11
|
-
*
|
|
12
|
-
* within the source to build the container image.
|
|
65
|
+
* Unlike BundledCodeZipAsset which packages code into a zip with dependencies, this uploads the
|
|
66
|
+
* directory as-is; CodeBuild uses the Dockerfile within it to build the container image.
|
|
13
67
|
*/
|
|
14
68
|
class ContainerSourceAsset extends constructs_1.Construct {
|
|
15
69
|
/**
|
|
@@ -22,9 +76,18 @@ class ContainerSourceAsset extends constructs_1.Construct {
|
|
|
22
76
|
if (!configRoot) {
|
|
23
77
|
throw new Error('Could not find .agentcore directory. Ensure you are running from within an AgentCore project.');
|
|
24
78
|
}
|
|
25
|
-
const
|
|
79
|
+
const buildContext = props.config.buildContextPath ?? props.config.codeLocation;
|
|
80
|
+
const resolvedBuildContext = (0, lib_1.resolveCodeLocation)(buildContext, configRoot);
|
|
81
|
+
const dockerfileRelPath = props.config.dockerfile ?? 'Dockerfile';
|
|
82
|
+
const exclude = [
|
|
83
|
+
...lib_1.CONTAINER_CONTEXT_SECRET_EXCLUDES,
|
|
84
|
+
...readDockerignorePatterns(resolvedBuildContext),
|
|
85
|
+
...forceKeepDockerfilePatterns(dockerfileRelPath),
|
|
86
|
+
];
|
|
26
87
|
this.asset = new aws_s3_assets_1.Asset(this, 'SourceAsset', {
|
|
27
|
-
path:
|
|
88
|
+
path: resolvedBuildContext,
|
|
89
|
+
exclude,
|
|
90
|
+
ignoreMode: aws_cdk_lib_1.IgnoreMode.DOCKER,
|
|
28
91
|
});
|
|
29
92
|
}
|
|
30
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContainerSourceAsset.js","sourceRoot":"","sources":["../../../../../src/cdk/constructs/bundling/container/ContainerSourceAsset.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"ContainerSourceAsset.js","sourceRoot":"","sources":["../../../../../src/cdk/const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AAC,IAAI,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAa,oBAAqB,SAAQ,sBAAS;IACjD;;OAEG;IACa,KAAK,CAAQ;IAE7B,YAAY,KAAgB,EAAE,EAAU,EAAE,KAAgC;QACxE,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAEjB,MAAM,UAAU,GAAG,IAAA,oBAAc,GAAE,CAAC;QACpC,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,+FAA+F,CAAC,CAAC;QACnH,CAAC;QACD,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,gBAAgB,IAAI,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC;QAChF,MAAM,oBAAoB,GAAG,IAAA,yBAAmB,EAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QAC3E,MAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,IAAI,YAAY,CAAC;QAElE,MAAM,OAAO,GAAG;YACd,GAAG,uCAAiC;YACpC,GAAG,wBAAwB,CAAC,oBAAoB,CAAC;YACjD,GAAG,2BAA2B,CAAC,iBAAiB,CAAC;SAClD,CAAC;QAEF,IAAI,CAAC,KAAK,GAAG,IAAI,qBAAK,CAAC,IAAI,EAAE,aAAa,EAAE;YAC1C,IAAI,EAAE,oBAAoB;YAC1B,OAAO;YACP,UAAU,EAAE,wBAAU,CAAC,MAAM;SAC9B,CAAC,CAAC;IACL,CAAC;CACF;AA7BD,oDA6BC"}
|
|
@@ -32,6 +32,9 @@ export declare function toBuildNetwork(label: string, networkMode: string | unde
|
|
|
32
32
|
* - ECR_REGISTRY: The ECR registry URL
|
|
33
33
|
* - IMAGE_URI: The full image URI (repo:tag)
|
|
34
34
|
* - DOCKERFILE_PATH: Path to the Dockerfile within the source
|
|
35
|
+
* - BUILD_ARG_FLAGS: Space-separated `--build-arg NAME` flags (may be empty). Each NAME's value is
|
|
36
|
+
* supplied as its own build environment variable, so `docker build` inherits it — keeping build-arg
|
|
37
|
+
* values off the shell command line. Set per-build via CodeBuild environment overrides.
|
|
35
38
|
*/
|
|
36
39
|
export declare class ContainerBuildProject extends Construct {
|
|
37
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContainerBuildProject.d.ts","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/ContainerBuildProject.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;CACnC;AASD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,aAAa,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,SAAS,GACzF,kBAAkB,GAAG,SAAS,CAmBhC;AAED
|
|
1
|
+
{"version":3,"file":"ContainerBuildProject.d.ts","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/ContainerBuildProject.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;CACnC;AASD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,aAAa,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,SAAS,GACzF,kBAAkB,GAAG,SAAS,CAmBhC;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,qBAAsB,SAAQ,SAAS;IAClD;;;;;;;OAOG;WACW,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,EAAE,kBAAkB,GAAG,qBAAqB;IAatG,SAAgB,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC;IAC3C,SAAgB,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC;IAC/B,SAAgB,aAAa,CAAC,EAAE,kBAAkB,CAAC;gBAEvC,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,kBAAkB;IA8G5E;;OAEG;IACI,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI;CAGtD"}
|
|
@@ -83,6 +83,9 @@ function toBuildNetwork(label, networkMode, networkConfig) {
|
|
|
83
83
|
* - ECR_REGISTRY: The ECR registry URL
|
|
84
84
|
* - IMAGE_URI: The full image URI (repo:tag)
|
|
85
85
|
* - DOCKERFILE_PATH: Path to the Dockerfile within the source
|
|
86
|
+
* - BUILD_ARG_FLAGS: Space-separated `--build-arg NAME` flags (may be empty). Each NAME's value is
|
|
87
|
+
* supplied as its own build environment variable, so `docker build` inherits it — keeping build-arg
|
|
88
|
+
* values off the shell command line. Set per-build via CodeBuild environment overrides.
|
|
86
89
|
*/
|
|
87
90
|
class ContainerBuildProject extends constructs_1.Construct {
|
|
88
91
|
/**
|
|
@@ -154,7 +157,10 @@ class ContainerBuildProject extends constructs_1.Construct {
|
|
|
154
157
|
],
|
|
155
158
|
},
|
|
156
159
|
build: {
|
|
157
|
-
commands: [
|
|
160
|
+
commands: [
|
|
161
|
+
'echo "Building container image..."',
|
|
162
|
+
'docker build -t $IMAGE_URI -f $DOCKERFILE_PATH $BUILD_ARG_FLAGS .',
|
|
163
|
+
],
|
|
158
164
|
},
|
|
159
165
|
post_build: {
|
|
160
166
|
commands: ['echo "Pushing image to ECR..."', 'docker push $IMAGE_URI', 'echo "Image pushed: $IMAGE_URI"'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContainerBuildProject.js","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/ContainerBuildProject.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,wCAuBC;AApDD,iDAAmC;AACnC,qEAAuD;AAEvD,yDAA2C;AAC3C,2CAAuC;AACvC,mCAAoC;AAQpC;;;;GAIG;AACH,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAEpC;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAC5B,KAAa,EACb,WAA+B,EAC/B,aAA0F;IAE1F,IAAI,WAAW,KAAK,KAAK,IAAI,CAAC,aAAa;QAAE,OAAO,SAAS,CAAC;IAC9D,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,GAAG,KAAK,uEAAuE;YAC7E,wEAAwE,CAC3E,CAAC;IACJ,CAAC;IACD,IAAI,aAAa,CAAC,cAAc,CAAC,MAAM,GAAG,yBAAyB,EAAE,CAAC;QACpE,MAAM,IAAI,KAAK,CACb,GAAG,KAAK,kDAAkD,yBAAyB,mBAAmB;YACpG,0BAA0B,aAAa,CAAC,cAAc,CAAC,MAAM,iBAAiB,CACjF,CAAC;IACJ,CAAC;IACD,OAAO;QACL,KAAK,EAAE,aAAa,CAAC,KAAK;QAC1B,OAAO,EAAE,aAAa,CAAC,OAAO;QAC9B,cAAc,EAAE,aAAa,CAAC,cAAc;KAC7C,CAAC;AACJ,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"ContainerBuildProject.js","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/ContainerBuildProject.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,wCAuBC;AApDD,iDAAmC;AACnC,qEAAuD;AAEvD,yDAA2C;AAC3C,2CAAuC;AACvC,mCAAoC;AAQpC;;;;GAIG;AACH,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAEpC;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAC5B,KAAa,EACb,WAA+B,EAC/B,aAA0F;IAE1F,IAAI,WAAW,KAAK,KAAK,IAAI,CAAC,aAAa;QAAE,OAAO,SAAS,CAAC;IAC9D,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,GAAG,KAAK,uEAAuE;YAC7E,wEAAwE,CAC3E,CAAC;IACJ,CAAC;IACD,IAAI,aAAa,CAAC,cAAc,CAAC,MAAM,GAAG,yBAAyB,EAAE,CAAC;QACpE,MAAM,IAAI,KAAK,CACb,GAAG,KAAK,kDAAkD,yBAAyB,mBAAmB;YACpG,0BAA0B,aAAa,CAAC,cAAc,CAAC,MAAM,iBAAiB,CACjF,CAAC;IACJ,CAAC;IACD,OAAO;QACL,KAAK,EAAE,aAAa,CAAC,KAAK;QAC1B,OAAO,EAAE,aAAa,CAAC,OAAO;QAC9B,cAAc,EAAE,aAAa,CAAC,cAAc;KAC7C,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O,SAAS,QAAQ,MAAM,IAAI,OAAO,sBAAsB,CAAC;gBAC5E,UAAU,EAAE;oBACV,YAAY,EAAE;wBACZ,uBAAuB,EAAE,yBAAyB;wBAClD,YAAY,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,SAAS,QAAQ,MAAM,IAAI,OAAO,WAAW,CAAC,EAAE,CAAC;qBACtG;iBACF;aACF,CAAC,CACH,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACI,WAAW,CAAC,UAA2B;QAC5C,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CACF;AA9ID,sDA8IC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,CAAqB;IAC9C,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAC/B,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE;QAC9B,cAAc,EAAE,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC,IAAI,EAAE;KAC7C,CAAC,CAAC;IACH,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -18,10 +18,17 @@ export interface ContainerImageBuilderProps {
|
|
|
18
18
|
*/
|
|
19
19
|
repository: AgentEcrRepository;
|
|
20
20
|
/**
|
|
21
|
-
* Path to the Dockerfile
|
|
21
|
+
* Path to the Dockerfile, relative to the source asset root (the build context).
|
|
22
22
|
* @default 'Dockerfile'
|
|
23
23
|
*/
|
|
24
24
|
dockerfile: string;
|
|
25
|
+
/**
|
|
26
|
+
* Docker build args forwarded to the build as `--build-arg` flags. Keys become build environment
|
|
27
|
+
* variables and are referenced by name, so values never touch the shell command line. Folded into
|
|
28
|
+
* the image tag so changing an arg rebuilds and rolls the runtime to the new image.
|
|
29
|
+
* @default undefined
|
|
30
|
+
*/
|
|
31
|
+
buildArgs?: Record<string, string>;
|
|
25
32
|
/**
|
|
26
33
|
* VPC placement for the build Lambda. When present the Lambda is created in
|
|
27
34
|
* these subnets/security groups. Lambda infers the VPC from the subnets, so
|
|
@@ -41,8 +48,8 @@ export interface ContainerImageBuilderProps {
|
|
|
41
48
|
* 2. Polls for build completion
|
|
42
49
|
* 3. Returns the container URI as a CloudFormation output
|
|
43
50
|
*
|
|
44
|
-
* The image tag is derived from the source asset hash, ensuring rebuilds
|
|
45
|
-
* happen when
|
|
51
|
+
* The image tag is derived from the source asset hash (and any custom build args), ensuring rebuilds
|
|
52
|
+
* happen when the build context, Dockerfile, or a build arg changes.
|
|
46
53
|
*/
|
|
47
54
|
export declare class ContainerImageBuilder extends Construct {
|
|
48
55
|
readonly containerUri: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContainerImageBuilder.d.ts","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/ContainerImageBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAKrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"ContainerImageBuilder.d.ts","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/ContainerImageBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAKrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,YAAY,EAAE,qBAAqB,CAAC;IAEpC;;OAEG;IACH,WAAW,EAAE;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,CAAC;IAE9B;;OAEG;IACH,UAAU,EAAE,kBAAkB,CAAC;IAE/B;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEnC;;;;OAIG;IACH,aAAa,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,cAAc,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CACjE;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,qBAAsB,SAAQ,SAAS;IAClD,SAAgB,YAAY,EAAE,MAAM,CAAC;gBAEzB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,0BAA0B;CAkE5E"}
|
|
@@ -39,6 +39,7 @@ const cdk = __importStar(require("aws-cdk-lib"));
|
|
|
39
39
|
const iam = __importStar(require("aws-cdk-lib/aws-iam"));
|
|
40
40
|
const lambda = __importStar(require("aws-cdk-lib/aws-lambda"));
|
|
41
41
|
const constructs_1 = require("constructs");
|
|
42
|
+
const crypto_1 = require("crypto");
|
|
42
43
|
/**
|
|
43
44
|
* Custom resource that triggers a CodeBuild build at deploy time to build and push
|
|
44
45
|
* a container image to ECR.
|
|
@@ -48,14 +49,15 @@ const constructs_1 = require("constructs");
|
|
|
48
49
|
* 2. Polls for build completion
|
|
49
50
|
* 3. Returns the container URI as a CloudFormation output
|
|
50
51
|
*
|
|
51
|
-
* The image tag is derived from the source asset hash, ensuring rebuilds
|
|
52
|
-
* happen when
|
|
52
|
+
* The image tag is derived from the source asset hash (and any custom build args), ensuring rebuilds
|
|
53
|
+
* happen when the build context, Dockerfile, or a build arg changes.
|
|
53
54
|
*/
|
|
54
55
|
class ContainerImageBuilder extends constructs_1.Construct {
|
|
55
56
|
containerUri;
|
|
56
57
|
constructor(scope, id, props) {
|
|
57
58
|
super(scope, id);
|
|
58
|
-
const { buildProject, sourceAsset, repository, dockerfile } = props;
|
|
59
|
+
const { buildProject, sourceAsset, repository, dockerfile, buildArgs } = props;
|
|
60
|
+
const hasBuildArgs = buildArgs !== undefined && Object.keys(buildArgs).length > 0;
|
|
59
61
|
const handler = new lambda.Function(this, 'ContainerBuildHandler', {
|
|
60
62
|
runtime: lambda.Runtime.NODEJS_22_X,
|
|
61
63
|
handler: 'index.handler',
|
|
@@ -78,8 +80,16 @@ class ContainerImageBuilder extends constructs_1.Construct {
|
|
|
78
80
|
actions: ['codebuild:StartBuild', 'codebuild:BatchGetBuilds'],
|
|
79
81
|
resources: [buildProject.project.projectArn],
|
|
80
82
|
}));
|
|
81
|
-
// Image tag
|
|
82
|
-
|
|
83
|
+
// Image tag drives cache invalidation: a new tag means a new build + a new runtime image URI, so
|
|
84
|
+
// the runtime rolls. The source asset hash covers the build context (code + Dockerfile). Build args
|
|
85
|
+
// are NOT part of the uploaded source, so fold them into the tag too — otherwise changing only a
|
|
86
|
+
// build arg would rebuild into the same tag and the runtime (which pins the URI) would never roll.
|
|
87
|
+
// With no build args the tag is exactly the asset hash, so existing deployments don't churn.
|
|
88
|
+
const imageTag = hasBuildArgs
|
|
89
|
+
? (0, crypto_1.createHash)('sha256')
|
|
90
|
+
.update(`${sourceAsset.asset.assetHash}:${canonicalBuildArgs(buildArgs)}`)
|
|
91
|
+
.digest('hex')
|
|
92
|
+
: sourceAsset.asset.assetHash;
|
|
83
93
|
const imageUri = `${repository.repository.repositoryUri}:${imageTag}`;
|
|
84
94
|
const cr = new cdk.CustomResource(this, 'ContainerBuildTrigger', {
|
|
85
95
|
serviceToken: handler.functionArn,
|
|
@@ -91,10 +101,28 @@ class ContainerImageBuilder extends constructs_1.Construct {
|
|
|
91
101
|
DockerfilePath: dockerfile,
|
|
92
102
|
EcrRegistry: `${cdk.Aws.ACCOUNT_ID}.dkr.ecr.${cdk.Aws.REGION}.${cdk.Aws.URL_SUFFIX}`,
|
|
93
103
|
SourceHash: sourceAsset.asset.assetHash,
|
|
104
|
+
// Only emitted when set, so existing container stacks (no build args) see no property change.
|
|
105
|
+
// Canonicalized (keys sorted) so merely reordering build-arg keys doesn't change the property
|
|
106
|
+
// and trigger a no-op rebuild — matching the order-insensitive image tag.
|
|
107
|
+
...(hasBuildArgs && { BuildArgs: canonicalBuildArgs(buildArgs) }),
|
|
94
108
|
},
|
|
95
109
|
});
|
|
96
110
|
this.containerUri = cr.getAttString('ContainerUri');
|
|
97
111
|
}
|
|
98
112
|
}
|
|
99
113
|
exports.ContainerImageBuilder = ContainerImageBuilder;
|
|
114
|
+
/**
|
|
115
|
+
* Deterministic JSON serialization of build args with keys sorted, used both for folding into the
|
|
116
|
+
* image tag and for the custom-resource BuildArgs property. Key order in the source config must not
|
|
117
|
+
* change the output (no spurious rebuild); a changed name or value must. Emitted as a JSON object so
|
|
118
|
+
* the build Lambda can `JSON.parse` it straight back into a name->value map.
|
|
119
|
+
*/
|
|
120
|
+
function canonicalBuildArgs(args) {
|
|
121
|
+
// The replacer-array form of JSON.stringify emits only the listed keys, in the array's order, so
|
|
122
|
+
// sorting the keys yields a canonical (order-insensitive) serialization in one call. Safe here
|
|
123
|
+
// because build-arg values are strings (BuildArgValueSchema) — no nested objects for the replacer
|
|
124
|
+
// to prune.
|
|
125
|
+
const safe = args ?? {};
|
|
126
|
+
return JSON.stringify(safe, Object.keys(safe).sort());
|
|
127
|
+
}
|
|
100
128
|
//# sourceMappingURL=ContainerImageBuilder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContainerImageBuilder.js","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/ContainerImageBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,uEAAyE;AACzE,iDAAmC;AACnC,yDAA2C;AAC3C,+DAAiD;AAEjD,2CAAuC;
|
|
1
|
+
{"version":3,"file":"ContainerImageBuilder.js","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/ContainerImageBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,uEAAyE;AACzE,iDAAmC;AACnC,yDAA2C;AAC3C,+DAAiD;AAEjD,2CAAuC;AACvC,mCAAoC;AAwCpC;;;;;;;;;;;GAWG;AACH,MAAa,qBAAsB,SAAQ,sBAAS;IAClC,YAAY,CAAS;IAErC,YAAY,KAAgB,EAAE,EAAU,EAAE,KAAiC;QACzE,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAEjB,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;QAC/E,MAAM,YAAY,GAAG,SAAS,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QAElF,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,uBAAuB,EAAE;YACjE,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW;YACnC,OAAO,EAAE,eAAe;YACxB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,sDAA4B,CAAC;YAC1D,OAAO,EAAE,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,UAAU,EAAE,GAAG;SAChB,CAAC,CAAC;QAEH,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM,KAAK,GAAG,OAAO,CAA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,KAAK,CAAC,WAAW;gBACxC,QAAQ,EAAE,QAAQ;gBAClB,cAAc,EAAE,UAAU;gBAC1B,WAAW,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,UAAU,YAAY,GAAG,CAAC,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE;gBACpF,UAAU,EAAE,WAAW,CAAC,KAAK,CAAC,SAAS;gBACvC,8FAA8F;gBAC9F,8FAA8F;gBAC9F,0EAA0E;gBAC1E,GAAG,CAAC,YAAY,IAAI,EAAE,SAAS,EAAE,kBAAkB,CAAC,SAAS,CAAC,EAAE,CAAC;aAClE;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IACtD,CAAC;CACF;AArED,sDAqEC;AAED;;;;;GAKG;AACH,SAAS,kBAAkB,CAAC,IAAwC;IAClE,iGAAiG;IACjG,+FAA+F;IAC/F,kGAAkG;IAClG,YAAY;IACZ,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IACxB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
* - EcrRegistry: ECR registry URL
|
|
15
15
|
* - ImageUri: Target image URI (repo:tag)
|
|
16
16
|
* - DockerfilePath: Path to Dockerfile in the source
|
|
17
|
+
* - BuildArgs: (optional) JSON object of docker build args ({ NAME: "value" }). Each entry is passed
|
|
18
|
+
* to CodeBuild as its own environment variable and referenced by `docker build --build-arg NAME`,
|
|
19
|
+
* so values are inherited from the environment rather than interpolated onto the command line.
|
|
17
20
|
*/
|
|
18
|
-
export declare const CONTAINER_BUILD_HANDLER_CODE = "\nconst { CodeBuildClient, StartBuildCommand, BatchGetBuildsCommand } = require('@aws-sdk/client-codebuild');\nconst codebuild = new CodeBuildClient();\n\nexports.handler = async function(event, context) {\n const props = event.ResourceProperties;\n const requestType = event.RequestType;\n\n // Build the response object\n const response = {\n Status: 'SUCCESS',\n PhysicalResourceId: props.ImageUri || 'container-build',\n StackId: event.StackId,\n RequestId: event.RequestId,\n LogicalResourceId: event.LogicalResourceId,\n Data: {},\n };\n\n try {\n if (requestType === 'Delete') {\n response.Data = {};\n await sendResponse(event, response);\n return;\n }\n\n // Start CodeBuild\n const startResult = await codebuild.send(new StartBuildCommand({\n projectName: props.ProjectName,\n sourceTypeOverride: 'S3',\n sourceLocationOverride: props.SourceBucket + '/' + props.SourceKey,\n environmentVariablesOverride: [\n { name: 'ECR_REGISTRY', value: props.EcrRegistry, type: 'PLAINTEXT' },\n { name: 'IMAGE_URI', value: props.ImageUri, type: 'PLAINTEXT' },\n { name: 'DOCKERFILE_PATH', value: props.DockerfilePath, type: 'PLAINTEXT' },\n ],\n }));\n\n const buildId = startResult.build.id;\n console.log('Started build:', buildId);\n\n // Poll until complete (14 minutes max to stay within Lambda's 15-minute timeout)\n const maxWaitMs = 14 * 60 * 1000;\n const start = Date.now();\n while (Date.now() - start < maxWaitMs) {\n const result = await codebuild.send(new BatchGetBuildsCommand({ ids: [buildId] }));\n const build = result.builds[0];\n if (build.buildStatus !== 'IN_PROGRESS') {\n if (build.buildStatus === 'SUCCEEDED') {\n response.Data = { ContainerUri: props.ImageUri };\n await sendResponse(event, response);\n return;\n } else {\n const logsUrl = build.logs && build.logs.deepLink ? build.logs.deepLink : 'Check CloudWatch Logs';\n response.Status = 'FAILED';\n response.Reason = 'CodeBuild build failed. Status: ' + build.buildStatus + '. Logs: ' + logsUrl;\n await sendResponse(event, response);\n return;\n }\n }\n await new Promise(r => setTimeout(r, 10000));\n }\n\n response.Status = 'FAILED';\n response.Reason = 'Build timed out after 14 minutes';\n await sendResponse(event, response);\n } catch (err) {\n response.Status = 'FAILED';\n response.Reason = err.message || 'Unknown error';\n await sendResponse(event, response);\n }\n};\n\nasync function sendResponse(event, response) {\n const https = require('https');\n const responseBody = JSON.stringify(response);\n const parsedUrl = new URL(event.ResponseURL);\n const options = {\n hostname: parsedUrl.hostname,\n port: 443,\n path: parsedUrl.pathname + parsedUrl.search,\n method: 'PUT',\n headers: { 'content-type': '', 'content-length': responseBody.length },\n };\n return new Promise((resolve, reject) => {\n const req = https.request(options, resolve);\n req.on('error', reject);\n req.write(responseBody);\n req.end();\n });\n}\n";
|
|
21
|
+
export declare const CONTAINER_BUILD_HANDLER_CODE = "\nconst { CodeBuildClient, StartBuildCommand, BatchGetBuildsCommand } = require('@aws-sdk/client-codebuild');\nconst codebuild = new CodeBuildClient();\n\nexports.handler = async function(event, context) {\n const props = event.ResourceProperties;\n const requestType = event.RequestType;\n\n // Build the response object\n const response = {\n Status: 'SUCCESS',\n PhysicalResourceId: props.ImageUri || 'container-build',\n StackId: event.StackId,\n RequestId: event.RequestId,\n LogicalResourceId: event.LogicalResourceId,\n Data: {},\n };\n\n try {\n if (requestType === 'Delete') {\n response.Data = {};\n await sendResponse(event, response);\n return;\n }\n\n // Docker build args: forward each as its own build environment variable and reference it with\n // '--build-arg NAME' (no value), so docker inherits the value from the environment. This keeps\n // arbitrary values off the shell command line (no quoting/word-splitting hazards). BUILD_ARG_FLAGS\n // is the space-separated flag list the buildspec interpolates; it is empty when there are no args.\n const buildArgs = props.BuildArgs ? JSON.parse(props.BuildArgs) : {};\n const buildArgNames = Object.keys(buildArgs);\n const buildArgEnv = buildArgNames.map(name => ({ name, value: String(buildArgs[name]), type: 'PLAINTEXT' }));\n const buildArgFlags = buildArgNames.map(name => '--build-arg ' + name).join(' ');\n\n // Start CodeBuild\n const startResult = await codebuild.send(new StartBuildCommand({\n projectName: props.ProjectName,\n sourceTypeOverride: 'S3',\n sourceLocationOverride: props.SourceBucket + '/' + props.SourceKey,\n environmentVariablesOverride: [\n { name: 'ECR_REGISTRY', value: props.EcrRegistry, type: 'PLAINTEXT' },\n { name: 'IMAGE_URI', value: props.ImageUri, type: 'PLAINTEXT' },\n { name: 'DOCKERFILE_PATH', value: props.DockerfilePath, type: 'PLAINTEXT' },\n { name: 'BUILD_ARG_FLAGS', value: buildArgFlags, type: 'PLAINTEXT' },\n ...buildArgEnv,\n ],\n }));\n\n const buildId = startResult.build.id;\n console.log('Started build:', buildId);\n\n // Poll until complete (14 minutes max to stay within Lambda's 15-minute timeout)\n const maxWaitMs = 14 * 60 * 1000;\n const start = Date.now();\n while (Date.now() - start < maxWaitMs) {\n const result = await codebuild.send(new BatchGetBuildsCommand({ ids: [buildId] }));\n const build = result.builds[0];\n if (build.buildStatus !== 'IN_PROGRESS') {\n if (build.buildStatus === 'SUCCEEDED') {\n response.Data = { ContainerUri: props.ImageUri };\n await sendResponse(event, response);\n return;\n } else {\n const logsUrl = build.logs && build.logs.deepLink ? build.logs.deepLink : 'Check CloudWatch Logs';\n response.Status = 'FAILED';\n response.Reason = 'CodeBuild build failed. Status: ' + build.buildStatus + '. Logs: ' + logsUrl;\n await sendResponse(event, response);\n return;\n }\n }\n await new Promise(r => setTimeout(r, 10000));\n }\n\n response.Status = 'FAILED';\n response.Reason = 'Build timed out after 14 minutes';\n await sendResponse(event, response);\n } catch (err) {\n response.Status = 'FAILED';\n response.Reason = err.message || 'Unknown error';\n await sendResponse(event, response);\n }\n};\n\nasync function sendResponse(event, response) {\n const https = require('https');\n const responseBody = JSON.stringify(response);\n const parsedUrl = new URL(event.ResponseURL);\n const options = {\n hostname: parsedUrl.hostname,\n port: 443,\n path: parsedUrl.pathname + parsedUrl.search,\n method: 'PUT',\n headers: { 'content-type': '', 'content-length': responseBody.length },\n };\n return new Promise((resolve, reject) => {\n const req = https.request(options, resolve);\n req.on('error', reject);\n req.write(responseBody);\n req.end();\n });\n}\n";
|
|
19
22
|
//# sourceMappingURL=container-build-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container-build-handler.d.ts","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/container-build-handler.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"container-build-handler.d.ts","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/container-build-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,4BAA4B,09HAqGxC,CAAC"}
|
|
@@ -17,6 +17,9 @@ exports.CONTAINER_BUILD_HANDLER_CODE = void 0;
|
|
|
17
17
|
* - EcrRegistry: ECR registry URL
|
|
18
18
|
* - ImageUri: Target image URI (repo:tag)
|
|
19
19
|
* - DockerfilePath: Path to Dockerfile in the source
|
|
20
|
+
* - BuildArgs: (optional) JSON object of docker build args ({ NAME: "value" }). Each entry is passed
|
|
21
|
+
* to CodeBuild as its own environment variable and referenced by `docker build --build-arg NAME`,
|
|
22
|
+
* so values are inherited from the environment rather than interpolated onto the command line.
|
|
20
23
|
*/
|
|
21
24
|
exports.CONTAINER_BUILD_HANDLER_CODE = `
|
|
22
25
|
const { CodeBuildClient, StartBuildCommand, BatchGetBuildsCommand } = require('@aws-sdk/client-codebuild');
|
|
@@ -43,6 +46,15 @@ exports.handler = async function(event, context) {
|
|
|
43
46
|
return;
|
|
44
47
|
}
|
|
45
48
|
|
|
49
|
+
// Docker build args: forward each as its own build environment variable and reference it with
|
|
50
|
+
// '--build-arg NAME' (no value), so docker inherits the value from the environment. This keeps
|
|
51
|
+
// arbitrary values off the shell command line (no quoting/word-splitting hazards). BUILD_ARG_FLAGS
|
|
52
|
+
// is the space-separated flag list the buildspec interpolates; it is empty when there are no args.
|
|
53
|
+
const buildArgs = props.BuildArgs ? JSON.parse(props.BuildArgs) : {};
|
|
54
|
+
const buildArgNames = Object.keys(buildArgs);
|
|
55
|
+
const buildArgEnv = buildArgNames.map(name => ({ name, value: String(buildArgs[name]), type: 'PLAINTEXT' }));
|
|
56
|
+
const buildArgFlags = buildArgNames.map(name => '--build-arg ' + name).join(' ');
|
|
57
|
+
|
|
46
58
|
// Start CodeBuild
|
|
47
59
|
const startResult = await codebuild.send(new StartBuildCommand({
|
|
48
60
|
projectName: props.ProjectName,
|
|
@@ -52,6 +64,8 @@ exports.handler = async function(event, context) {
|
|
|
52
64
|
{ name: 'ECR_REGISTRY', value: props.EcrRegistry, type: 'PLAINTEXT' },
|
|
53
65
|
{ name: 'IMAGE_URI', value: props.ImageUri, type: 'PLAINTEXT' },
|
|
54
66
|
{ name: 'DOCKERFILE_PATH', value: props.DockerfilePath, type: 'PLAINTEXT' },
|
|
67
|
+
{ name: 'BUILD_ARG_FLAGS', value: buildArgFlags, type: 'PLAINTEXT' },
|
|
68
|
+
...buildArgEnv,
|
|
55
69
|
],
|
|
56
70
|
}));
|
|
57
71
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container-build-handler.js","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/container-build-handler.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"container-build-handler.js","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/container-build-handler.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACU,QAAA,4BAA4B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqG3C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Gateway.d.ts","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/mcp/Gateway.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAA0B,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAKrG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAClG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAA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uBAAuB,CAAC;IAC/C,6DAA6D;IAC7D,QAAQ,CAAC,YAAY,CAAC,EAAE,qBAAqB,CAAC;IAC9C,qCAAqC;IACrC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAC7C,mEAAmE;IACnE,QAAQ,CAAC,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;CACvE;AAED;;;;;;;;GAQG;AACH,qBAAa,OAAQ,SAAQ,SAAS;IACpC,SAAgB,UAAU,EAAE,gBAAgB,CAAC,UAAU,CAAC;IACxD,SAAgB,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC;IAChC,SAAgB,QAAQ,gCAAuC;IAC/D,SAAgB,eAAe,uCAAsC;IACrE,SAAgB,cAAc,yDAAwD;IAEtF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAA0B;IACvD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;IACrC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAA8C;gBAElE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY;IA6L7D;;;OAGG;IACI,WAAW,CAAC,SAAS,EAAE,GAAG,CAAC,eAAe,GAAG,IAAI;IAMxD;;;;OAIG;IACH,OAAO,CAAC,0BAA0B;IAelC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAoD7B;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAquB5B"}
|
|
@@ -241,8 +241,14 @@ class Gateway extends constructs_1.Construct {
|
|
|
241
241
|
* Otherwise, configures MCP with SEMANTIC search type.
|
|
242
242
|
*/
|
|
243
243
|
buildProtocolConfiguration(gateway) {
|
|
244
|
+
// 'SEMANTIC' is the only value CloudFormation accepts for Mcp.SearchType.
|
|
245
|
+
// To disable semantic search we must omit ProtocolConfiguration entirely —
|
|
246
|
+
// emitting 'NONE' produces a template that CloudFormation rejects.
|
|
247
|
+
if (gateway.enableSemanticSearch === false) {
|
|
248
|
+
return undefined;
|
|
249
|
+
}
|
|
244
250
|
return {
|
|
245
|
-
mcp: { searchType:
|
|
251
|
+
mcp: { searchType: 'SEMANTIC' },
|
|
246
252
|
};
|
|
247
253
|
}
|
|
248
254
|
/**
|
|
@@ -343,6 +349,10 @@ class Gateway extends constructs_1.Construct {
|
|
|
343
349
|
? [{ credentialProviderType: 'GATEWAY_IAM_ROLE' }]
|
|
344
350
|
: undefined),
|
|
345
351
|
});
|
|
352
|
+
// The gateway service validates the role's permissions synchronously at
|
|
353
|
+
// CreateGatewayTarget time, so the target must be created after the role's
|
|
354
|
+
// DefaultPolicy. Depending on the role transitively includes its DefaultPolicy.
|
|
355
|
+
cfnTarget.node.addDependency(this.role);
|
|
346
356
|
this.gatewayTargets.set(targetName, cfnTarget);
|
|
347
357
|
return;
|
|
348
358
|
}
|
|
@@ -397,6 +407,14 @@ class Gateway extends constructs_1.Construct {
|
|
|
397
407
|
},
|
|
398
408
|
credentialProviderConfigurations,
|
|
399
409
|
});
|
|
410
|
+
// The gateway service validates lambda:InvokeFunction synchronously at
|
|
411
|
+
// CreateGatewayTarget time. That grant lives on the role's DefaultPolicy
|
|
412
|
+
// (a separate AWS::IAM::Policy), so the target must be created after it —
|
|
413
|
+
// depending on the role transitively includes its DefaultPolicy. Without
|
|
414
|
+
// this, CloudFormation could create the target before the policy attached,
|
|
415
|
+
// yielding a 400 "role lacks permission to invoke Lambda" and a rollback
|
|
416
|
+
// the CDK toolkit then surfaced as an opaque "NoStack" error.
|
|
417
|
+
cfnTarget.node.addDependency(this.role);
|
|
400
418
|
this.gatewayTargets.set(targetName, cfnTarget);
|
|
401
419
|
return;
|
|
402
420
|
}
|
|
@@ -443,6 +461,7 @@ class Gateway extends constructs_1.Construct {
|
|
|
443
461
|
kbDependencies.push(kbConstruct);
|
|
444
462
|
cfnConfigurations.push({
|
|
445
463
|
Name: config.name,
|
|
464
|
+
...(config.description && { Description: config.description }),
|
|
446
465
|
ParameterValues: { ...pv, knowledgeBaseId: resolvedId },
|
|
447
466
|
...(config.parameterOverrides && {
|
|
448
467
|
ParameterOverrides: config.parameterOverrides.map(o => ({
|
|
@@ -471,6 +490,7 @@ class Gateway extends constructs_1.Construct {
|
|
|
471
490
|
}));
|
|
472
491
|
cfnConfigurations.push({
|
|
473
492
|
Name: config.name,
|
|
493
|
+
...(config.description && { Description: config.description }),
|
|
474
494
|
ParameterValues: { ...pv, retrievers: resolvedRetrievers },
|
|
475
495
|
...(config.parameterOverrides && {
|
|
476
496
|
ParameterOverrides: config.parameterOverrides.map(o => ({
|
|
@@ -485,6 +505,7 @@ class Gateway extends constructs_1.Construct {
|
|
|
485
505
|
// Pass through any other configuration entry as-is
|
|
486
506
|
cfnConfigurations.push({
|
|
487
507
|
Name: config.name,
|
|
508
|
+
...(config.description && { Description: config.description }),
|
|
488
509
|
...(pv && { ParameterValues: pv }),
|
|
489
510
|
...(config.parameterOverrides && {
|
|
490
511
|
ParameterOverrides: config.parameterOverrides.map(o => ({
|
|
@@ -571,6 +592,9 @@ class Gateway extends constructs_1.Construct {
|
|
|
571
592
|
Configurations: [
|
|
572
593
|
{
|
|
573
594
|
Name: 'WebSearch',
|
|
595
|
+
...(target.configurations?.[0]?.description && {
|
|
596
|
+
Description: target.configurations[0].description,
|
|
597
|
+
}),
|
|
574
598
|
ParameterValues: parameterValues,
|
|
575
599
|
},
|
|
576
600
|
],
|
|
@@ -790,6 +814,11 @@ class Gateway extends constructs_1.Construct {
|
|
|
790
814
|
actions: ['bedrock-agentcore:InvokeAgentRuntime'],
|
|
791
815
|
resources: [runtimeArn, `${runtimeArn}/runtime-endpoint/*`],
|
|
792
816
|
}));
|
|
817
|
+
// The gateway service validates the role's InvokeAgentRuntime permission
|
|
818
|
+
// synchronously at CreateGatewayTarget time. That grant lives on the role's
|
|
819
|
+
// DefaultPolicy, so the target must be created after it — depending on the
|
|
820
|
+
// role transitively includes its DefaultPolicy.
|
|
821
|
+
cfnTarget.node.addDependency(this.role);
|
|
793
822
|
// Store the target reference for output generation
|
|
794
823
|
this.gatewayTargets.set(targetName, cfnTarget);
|
|
795
824
|
return;
|