@aws/agentcore-cdk 0.1.0-alpha.1 → 0.1.0-alpha.3

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.
Files changed (71) hide show
  1. package/dist/cdk/constructs/bundling/container/ContainerSourceAsset.d.ts +24 -0
  2. package/dist/cdk/constructs/bundling/container/ContainerSourceAsset.d.ts.map +1 -0
  3. package/dist/cdk/constructs/bundling/container/ContainerSourceAsset.js +32 -0
  4. package/dist/cdk/constructs/bundling/container/ContainerSourceAsset.js.map +1 -0
  5. package/dist/cdk/constructs/bundling/container/index.d.ts +2 -0
  6. package/dist/cdk/constructs/bundling/container/index.d.ts.map +1 -0
  7. package/dist/cdk/constructs/bundling/container/index.js +6 -0
  8. package/dist/cdk/constructs/bundling/container/index.js.map +1 -0
  9. package/dist/cdk/constructs/bundling/index.d.ts +2 -0
  10. package/dist/cdk/constructs/bundling/index.d.ts.map +1 -1
  11. package/dist/cdk/constructs/bundling/index.js +5 -1
  12. package/dist/cdk/constructs/bundling/index.js.map +1 -1
  13. package/dist/cdk/constructs/components/container/AgentEcrRepository.d.ts +25 -0
  14. package/dist/cdk/constructs/components/container/AgentEcrRepository.d.ts.map +1 -0
  15. package/dist/cdk/constructs/components/container/AgentEcrRepository.js +74 -0
  16. package/dist/cdk/constructs/components/container/AgentEcrRepository.js.map +1 -0
  17. package/dist/cdk/constructs/components/container/ContainerBuildProject.d.ts +31 -0
  18. package/dist/cdk/constructs/components/container/ContainerBuildProject.d.ts.map +1 -0
  19. package/dist/cdk/constructs/components/container/ContainerBuildProject.js +124 -0
  20. package/dist/cdk/constructs/components/container/ContainerBuildProject.js.map +1 -0
  21. package/dist/cdk/constructs/components/container/ContainerImageBuilder.d.ts +40 -0
  22. package/dist/cdk/constructs/components/container/ContainerImageBuilder.d.ts.map +1 -0
  23. package/dist/cdk/constructs/components/container/ContainerImageBuilder.js +90 -0
  24. package/dist/cdk/constructs/components/container/ContainerImageBuilder.js.map +1 -0
  25. package/dist/cdk/constructs/components/container/container-build-handler.d.ts +19 -0
  26. package/dist/cdk/constructs/components/container/container-build-handler.d.ts.map +1 -0
  27. package/dist/cdk/constructs/components/container/container-build-handler.js +113 -0
  28. package/dist/cdk/constructs/components/container/container-build-handler.js.map +1 -0
  29. package/dist/cdk/constructs/components/container/index.d.ts +4 -0
  30. package/dist/cdk/constructs/components/container/index.d.ts.map +1 -0
  31. package/dist/cdk/constructs/components/container/index.js +10 -0
  32. package/dist/cdk/constructs/components/container/index.js.map +1 -0
  33. package/dist/cdk/constructs/components/index.d.ts +1 -0
  34. package/dist/cdk/constructs/components/index.d.ts.map +1 -1
  35. package/dist/cdk/constructs/components/index.js +1 -0
  36. package/dist/cdk/constructs/components/index.js.map +1 -1
  37. package/dist/cdk/constructs/components/primitives/index.d.ts +1 -1
  38. package/dist/cdk/constructs/components/primitives/index.d.ts.map +1 -1
  39. package/dist/cdk/constructs/components/primitives/index.js +1 -2
  40. package/dist/cdk/constructs/components/primitives/index.js.map +1 -1
  41. package/dist/cdk/constructs/components/primitives/runtime/AgentCoreRuntime.d.ts +8 -2
  42. package/dist/cdk/constructs/components/primitives/runtime/AgentCoreRuntime.d.ts.map +1 -1
  43. package/dist/cdk/constructs/components/primitives/runtime/AgentCoreRuntime.js +61 -18
  44. package/dist/cdk/constructs/components/primitives/runtime/AgentCoreRuntime.js.map +1 -1
  45. package/dist/cdk/constructs/components/primitives/runtime/index.d.ts +0 -1
  46. package/dist/cdk/constructs/components/primitives/runtime/index.d.ts.map +1 -1
  47. package/dist/cdk/constructs/components/primitives/runtime/index.js +1 -3
  48. package/dist/cdk/constructs/components/primitives/runtime/index.js.map +1 -1
  49. package/dist/cdk/constructs/index.d.ts +1 -1
  50. package/dist/cdk/constructs/index.d.ts.map +1 -1
  51. package/dist/cdk/constructs/index.js +1 -2
  52. package/dist/cdk/constructs/index.js.map +1 -1
  53. package/dist/cdk/constructs/l3/AgentEnvironment.d.ts.map +1 -1
  54. package/dist/cdk/constructs/l3/AgentEnvironment.js +44 -11
  55. package/dist/cdk/constructs/l3/AgentEnvironment.js.map +1 -1
  56. package/dist/cdk/index.d.ts +1 -1
  57. package/dist/cdk/index.d.ts.map +1 -1
  58. package/dist/cdk/index.js +1 -2
  59. package/dist/cdk/index.js.map +1 -1
  60. package/dist/index.d.ts +1 -1
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +1 -2
  63. package/dist/index.js.map +1 -1
  64. package/dist/schema/schemas/agent-env.d.ts.map +1 -1
  65. package/dist/schema/schemas/agent-env.js +7 -1
  66. package/dist/schema/schemas/agent-env.js.map +1 -1
  67. package/package.json +7 -7
  68. package/dist/cdk/constructs/components/primitives/runtime/AgentCoreRuntimeRole.d.ts +0 -24
  69. package/dist/cdk/constructs/components/primitives/runtime/AgentCoreRuntimeRole.d.ts.map +0 -1
  70. package/dist/cdk/constructs/components/primitives/runtime/AgentCoreRuntimeRole.js +0 -39
  71. package/dist/cdk/constructs/components/primitives/runtime/AgentCoreRuntimeRole.js.map +0 -1
@@ -0,0 +1,24 @@
1
+ import type { AgentEnvSpec } from '../../../../schema';
2
+ import { Asset } from 'aws-cdk-lib/aws-s3-assets';
3
+ import { Construct } from 'constructs';
4
+ export interface ContainerSourceAssetProps {
5
+ /**
6
+ * The agent configuration containing code location details.
7
+ */
8
+ readonly config: AgentEnvSpec;
9
+ }
10
+ /**
11
+ * Packages the agent source directory (including Dockerfile) as an S3 asset for CodeBuild.
12
+ *
13
+ * Unlike BundledCodeZipAsset which packages code into a zip with dependencies,
14
+ * this simply uploads the source directory as-is. CodeBuild will use the Dockerfile
15
+ * within the source to build the container image.
16
+ */
17
+ export declare class ContainerSourceAsset extends Construct {
18
+ /**
19
+ * The underlying CDK Asset containing the source directory.
20
+ */
21
+ readonly asset: Asset;
22
+ constructor(scope: Construct, id: string, props: ContainerSourceAssetProps);
23
+ }
24
+ //# sourceMappingURL=ContainerSourceAsset.d.ts.map
@@ -0,0 +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;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC/B;AAED;;;;;;GAMG;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;CAa3E"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContainerSourceAsset = void 0;
4
+ const lib_1 = require("../../../../lib");
5
+ const aws_s3_assets_1 = require("aws-cdk-lib/aws-s3-assets");
6
+ const constructs_1 = require("constructs");
7
+ /**
8
+ * Packages the agent source directory (including Dockerfile) as an S3 asset for CodeBuild.
9
+ *
10
+ * Unlike BundledCodeZipAsset which packages code into a zip with dependencies,
11
+ * this simply uploads the source directory as-is. CodeBuild will use the Dockerfile
12
+ * within the source to build the container image.
13
+ */
14
+ class ContainerSourceAsset extends constructs_1.Construct {
15
+ /**
16
+ * The underlying CDK Asset containing the source directory.
17
+ */
18
+ asset;
19
+ constructor(scope, id, props) {
20
+ super(scope, id);
21
+ const configRoot = (0, lib_1.findConfigRoot)();
22
+ if (!configRoot) {
23
+ throw new Error('Could not find .agentcore directory. Ensure you are running from within an AgentCore project.');
24
+ }
25
+ const resolvedCodeLocation = (0, lib_1.resolveCodeLocation)(props.config.codeLocation, configRoot);
26
+ this.asset = new aws_s3_assets_1.Asset(this, 'SourceAsset', {
27
+ path: resolvedCodeLocation,
28
+ });
29
+ }
30
+ }
31
+ exports.ContainerSourceAsset = ContainerSourceAsset;
32
+ //# sourceMappingURL=ContainerSourceAsset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContainerSourceAsset.js","sourceRoot":"","sources":["../../../../../src/cdk/constructs/bundling/container/ContainerSourceAsset.ts"],"names":[],"mappings":";;;AAAA,yCAAsE;AAEtE,6DAAkD;AAClD,2CAAuC;AASvC;;;;;;GAMG;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,oBAAoB,GAAG,IAAA,yBAAmB,EAAC,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QAExF,IAAI,CAAC,KAAK,GAAG,IAAI,qBAAK,CAAC,IAAI,EAAE,aAAa,EAAE;YAC1C,IAAI,EAAE,oBAAoB;SAC3B,CAAC,CAAC;IACL,CAAC;CACF;AAnBD,oDAmBC"}
@@ -0,0 +1,2 @@
1
+ export { ContainerSourceAsset, type ContainerSourceAssetProps } from './ContainerSourceAsset';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/cdk/constructs/bundling/container/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,KAAK,yBAAyB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContainerSourceAsset = void 0;
4
+ var ContainerSourceAsset_1 = require("./ContainerSourceAsset");
5
+ Object.defineProperty(exports, "ContainerSourceAsset", { enumerable: true, get: function () { return ContainerSourceAsset_1.ContainerSourceAsset; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/cdk/constructs/bundling/container/index.ts"],"names":[],"mappings":";;;AAAA,+DAA8F;AAArF,4HAAA,oBAAoB,OAAA"}
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * Organization:
5
5
  * - zip/ - Code zip assets for CodeZip runtime
6
+ * - container/ - Source assets for Container runtime
6
7
  */
7
8
  export { BundledCodeZipAsset, type BundledCodeZipAssetProps, type PackageResult } from './zip';
8
9
  export { PythonBundledCodeZipAsset } from './zip';
10
+ export { ContainerSourceAsset, type ContainerSourceAssetProps } from './container';
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cdk/constructs/bundling/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,mBAAmB,EAAE,KAAK,wBAAwB,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAC/F,OAAO,EAAE,yBAAyB,EAAE,MAAM,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cdk/constructs/bundling/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,mBAAmB,EAAE,KAAK,wBAAwB,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAC/F,OAAO,EAAE,yBAAyB,EAAE,MAAM,OAAO,CAAC;AAGlD,OAAO,EAAE,oBAAoB,EAAE,KAAK,yBAAyB,EAAE,MAAM,aAAa,CAAC"}
@@ -4,12 +4,16 @@
4
4
  *
5
5
  * Organization:
6
6
  * - zip/ - Code zip assets for CodeZip runtime
7
+ * - container/ - Source assets for Container runtime
7
8
  */
8
9
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.PythonBundledCodeZipAsset = exports.BundledCodeZipAsset = void 0;
10
+ exports.ContainerSourceAsset = exports.PythonBundledCodeZipAsset = exports.BundledCodeZipAsset = void 0;
10
11
  // Zip/CodeZip bundling
11
12
  var zip_1 = require("./zip");
12
13
  Object.defineProperty(exports, "BundledCodeZipAsset", { enumerable: true, get: function () { return zip_1.BundledCodeZipAsset; } });
13
14
  var zip_2 = require("./zip");
14
15
  Object.defineProperty(exports, "PythonBundledCodeZipAsset", { enumerable: true, get: function () { return zip_2.PythonBundledCodeZipAsset; } });
16
+ // Container bundling
17
+ var container_1 = require("./container");
18
+ Object.defineProperty(exports, "ContainerSourceAsset", { enumerable: true, get: function () { return container_1.ContainerSourceAsset; } });
15
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/cdk/constructs/bundling/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,uBAAuB;AACvB,6BAA+F;AAAtF,0GAAA,mBAAmB,OAAA;AAC5B,6BAAkD;AAAzC,gHAAA,yBAAyB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/cdk/constructs/bundling/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,uBAAuB;AACvB,6BAA+F;AAAtF,0GAAA,mBAAmB,OAAA;AAC5B,6BAAkD;AAAzC,gHAAA,yBAAyB,OAAA;AAElC,qBAAqB;AACrB,yCAAmF;AAA1E,iHAAA,oBAAoB,OAAA"}
@@ -0,0 +1,25 @@
1
+ import * as ecr from 'aws-cdk-lib/aws-ecr';
2
+ import * as kms from 'aws-cdk-lib/aws-kms';
3
+ import { Construct } from 'constructs';
4
+ export interface AgentEcrRepositoryProps {
5
+ /**
6
+ * The project name used as prefix for the repository name.
7
+ */
8
+ projectName: string;
9
+ /**
10
+ * The agent name used as suffix for the repository name.
11
+ */
12
+ agentName: string;
13
+ }
14
+ /**
15
+ * Creates an ECR repository for storing agent container images.
16
+ *
17
+ * The repository name follows the pattern: {projectName}/{agentName} (lowercased).
18
+ * Includes lifecycle rules to keep the last 10 images and enables image scanning.
19
+ */
20
+ export declare class AgentEcrRepository extends Construct {
21
+ readonly repository: ecr.Repository;
22
+ readonly encryptionKey: kms.Key;
23
+ constructor(scope: Construct, id: string, props: AgentEcrRepositoryProps);
24
+ }
25
+ //# sourceMappingURL=AgentEcrRepository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentEcrRepository.d.ts","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/AgentEcrRepository.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,qBAAa,kBAAmB,SAAQ,SAAS;IAC/C,SAAgB,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC;IAC3C,SAAgB,aAAa,EAAE,GAAG,CAAC,GAAG,CAAC;gBAE3B,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,uBAAuB;CAwBzE"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.AgentEcrRepository = void 0;
37
+ const cdk = __importStar(require("aws-cdk-lib"));
38
+ const ecr = __importStar(require("aws-cdk-lib/aws-ecr"));
39
+ const kms = __importStar(require("aws-cdk-lib/aws-kms"));
40
+ const constructs_1 = require("constructs");
41
+ /**
42
+ * Creates an ECR repository for storing agent container images.
43
+ *
44
+ * The repository name follows the pattern: {projectName}/{agentName} (lowercased).
45
+ * Includes lifecycle rules to keep the last 10 images and enables image scanning.
46
+ */
47
+ class AgentEcrRepository extends constructs_1.Construct {
48
+ repository;
49
+ encryptionKey;
50
+ constructor(scope, id, props) {
51
+ super(scope, id);
52
+ this.encryptionKey = new kms.Key(this, 'EncryptionKey', {
53
+ description: `ECR encryption key for ${props.projectName}/${props.agentName}`,
54
+ enableKeyRotation: true,
55
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
56
+ });
57
+ this.repository = new ecr.Repository(this, 'Repository', {
58
+ repositoryName: `${props.projectName}/${props.agentName}`.toLowerCase(),
59
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
60
+ emptyOnDelete: true,
61
+ lifecycleRules: [
62
+ {
63
+ maxImageCount: 10,
64
+ description: 'Keep last 10 images',
65
+ },
66
+ ],
67
+ imageScanOnPush: true,
68
+ encryption: ecr.RepositoryEncryption.KMS,
69
+ encryptionKey: this.encryptionKey,
70
+ });
71
+ }
72
+ }
73
+ exports.AgentEcrRepository = AgentEcrRepository;
74
+ //# sourceMappingURL=AgentEcrRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentEcrRepository.js","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/AgentEcrRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AACnC,yDAA2C;AAC3C,yDAA2C;AAC3C,2CAAuC;AAcvC;;;;;GAKG;AACH,MAAa,kBAAmB,SAAQ,sBAAS;IAC/B,UAAU,CAAiB;IAC3B,aAAa,CAAU;IAEvC,YAAY,KAAgB,EAAE,EAAU,EAAE,KAA8B;QACtE,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAEjB,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,eAAe,EAAE;YACtD,WAAW,EAAE,0BAA0B,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,SAAS,EAAE;YAC7E,iBAAiB,EAAE,IAAI;YACvB,aAAa,EAAE,GAAG,CAAC,aAAa,CAAC,OAAO;SACzC,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE;YACvD,cAAc,EAAE,GAAG,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC,WAAW,EAAE;YACvE,aAAa,EAAE,GAAG,CAAC,aAAa,CAAC,OAAO;YACxC,aAAa,EAAE,IAAI;YACnB,cAAc,EAAE;gBACd;oBACE,aAAa,EAAE,EAAE;oBACjB,WAAW,EAAE,qBAAqB;iBACnC;aACF;YACD,eAAe,EAAE,IAAI;YACrB,UAAU,EAAE,GAAG,CAAC,oBAAoB,CAAC,GAAG;YACxC,aAAa,EAAE,IAAI,CAAC,aAAa;SAClC,CAAC,CAAC;IACL,CAAC;CACF;AA5BD,gDA4BC"}
@@ -0,0 +1,31 @@
1
+ import * as codebuild from 'aws-cdk-lib/aws-codebuild';
2
+ import type * as ecr from 'aws-cdk-lib/aws-ecr';
3
+ import * as iam from 'aws-cdk-lib/aws-iam';
4
+ import { Construct } from 'constructs';
5
+ /**
6
+ * Singleton CodeBuild project for building container images.
7
+ *
8
+ * Creates a shared CodeBuild project at the stack level that can be reused
9
+ * across multiple agent container builds. The project uses a privileged
10
+ * ARM64 environment with Docker layer caching.
11
+ *
12
+ * The buildspec expects environment variables:
13
+ * - ECR_REGISTRY: The ECR registry URL
14
+ * - IMAGE_URI: The full image URI (repo:tag)
15
+ * - DOCKERFILE_PATH: Path to the Dockerfile within the source
16
+ */
17
+ export declare class ContainerBuildProject extends Construct {
18
+ /**
19
+ * Returns the singleton ContainerBuildProject for the given stack.
20
+ * Creates a new one if it doesn't exist yet.
21
+ */
22
+ static getOrCreate(scope: Construct): ContainerBuildProject;
23
+ readonly project: codebuild.Project;
24
+ readonly role: iam.Role;
25
+ constructor(scope: Construct, id: string);
26
+ /**
27
+ * Grant the build project permission to push to a specific ECR repository.
28
+ */
29
+ grantPushTo(repository: ecr.IRepository): void;
30
+ }
31
+ //# sourceMappingURL=ContainerBuildProject.d.ts.map
@@ -0,0 +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;AAEvC;;;;;;;;;;;GAWG;AACH,qBAAa,qBAAsB,SAAQ,SAAS;IAClD;;;OAGG;WACW,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,qBAAqB;IAUlE,SAAgB,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC;IAC3C,SAAgB,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC;gBAEnB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM;IAyDxC;;OAEG;IACI,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI;CAGtD"}
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ContainerBuildProject = void 0;
37
+ const cdk = __importStar(require("aws-cdk-lib"));
38
+ const codebuild = __importStar(require("aws-cdk-lib/aws-codebuild"));
39
+ const iam = __importStar(require("aws-cdk-lib/aws-iam"));
40
+ const constructs_1 = require("constructs");
41
+ /**
42
+ * Singleton CodeBuild project for building container images.
43
+ *
44
+ * Creates a shared CodeBuild project at the stack level that can be reused
45
+ * across multiple agent container builds. The project uses a privileged
46
+ * ARM64 environment with Docker layer caching.
47
+ *
48
+ * The buildspec expects environment variables:
49
+ * - ECR_REGISTRY: The ECR registry URL
50
+ * - IMAGE_URI: The full image URI (repo:tag)
51
+ * - DOCKERFILE_PATH: Path to the Dockerfile within the source
52
+ */
53
+ class ContainerBuildProject extends constructs_1.Construct {
54
+ /**
55
+ * Returns the singleton ContainerBuildProject for the given stack.
56
+ * Creates a new one if it doesn't exist yet.
57
+ */
58
+ static getOrCreate(scope) {
59
+ const stack = cdk.Stack.of(scope);
60
+ const id = 'ContainerBuildProject';
61
+ const existing = stack.node.tryFindChild(id);
62
+ if (existing) {
63
+ return existing;
64
+ }
65
+ return new ContainerBuildProject(stack, id);
66
+ }
67
+ project;
68
+ role;
69
+ constructor(scope, id) {
70
+ super(scope, id);
71
+ const partition = cdk.Stack.of(this).partition;
72
+ const region = cdk.Stack.of(this).region;
73
+ const account = cdk.Stack.of(this).account;
74
+ this.role = new iam.Role(this, 'ContainerBuildExecutionRole', {
75
+ assumedBy: new iam.ServicePrincipal('codebuild.amazonaws.com'),
76
+ });
77
+ // ECR auth token (must be * per AWS API — does not support resource-level permissions)
78
+ this.role.addToPolicy(new iam.PolicyStatement({
79
+ actions: ['ecr:GetAuthorizationToken'],
80
+ resources: ['*'],
81
+ }));
82
+ // CloudWatch Logs for build logs
83
+ this.role.addToPolicy(new iam.PolicyStatement({
84
+ actions: ['logs:CreateLogGroup', 'logs:CreateLogStream', 'logs:PutLogEvents'],
85
+ resources: [`arn:${partition}:logs:${region}:${account}:log-group:/aws/codebuild/*`],
86
+ }));
87
+ this.project = new codebuild.Project(this, 'ContainerBuildProject', {
88
+ projectName: `${cdk.Stack.of(this).stackName}-container-builder`,
89
+ role: this.role,
90
+ environment: {
91
+ buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2023_STANDARD_3_0,
92
+ computeType: codebuild.ComputeType.SMALL,
93
+ privileged: true,
94
+ },
95
+ timeout: cdk.Duration.minutes(30),
96
+ cache: codebuild.Cache.local(codebuild.LocalCacheMode.DOCKER_LAYER),
97
+ buildSpec: codebuild.BuildSpec.fromObject({
98
+ version: '0.2',
99
+ phases: {
100
+ pre_build: {
101
+ commands: [
102
+ 'echo "Logging in to Amazon ECR..."',
103
+ 'aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $ECR_REGISTRY',
104
+ ],
105
+ },
106
+ build: {
107
+ commands: ['echo "Building container image..."', 'docker build -t $IMAGE_URI -f $DOCKERFILE_PATH .'],
108
+ },
109
+ post_build: {
110
+ commands: ['echo "Pushing image to ECR..."', 'docker push $IMAGE_URI', 'echo "Image pushed: $IMAGE_URI"'],
111
+ },
112
+ },
113
+ }),
114
+ });
115
+ }
116
+ /**
117
+ * Grant the build project permission to push to a specific ECR repository.
118
+ */
119
+ grantPushTo(repository) {
120
+ repository.grantPullPush(this.role);
121
+ }
122
+ }
123
+ exports.ContainerBuildProject = ContainerBuildProject;
124
+ //# sourceMappingURL=ContainerBuildProject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContainerBuildProject.js","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/ContainerBuildProject.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,40 @@
1
+ import type { ContainerSourceAsset } from '../../bundling/container/ContainerSourceAsset';
2
+ import type { AgentEcrRepository } from './AgentEcrRepository';
3
+ import type { ContainerBuildProject } from './ContainerBuildProject';
4
+ import { Construct } from 'constructs';
5
+ export interface ContainerImageBuilderProps {
6
+ /**
7
+ * The shared CodeBuild project used for building container images.
8
+ */
9
+ buildProject: ContainerBuildProject;
10
+ /**
11
+ * The S3 asset containing the source directory with Dockerfile.
12
+ */
13
+ sourceAsset: ContainerSourceAsset;
14
+ /**
15
+ * The ECR repository to push the built image to.
16
+ */
17
+ repository: AgentEcrRepository;
18
+ /**
19
+ * Path to the Dockerfile within the source directory.
20
+ * @default 'Dockerfile'
21
+ */
22
+ dockerfile: string;
23
+ }
24
+ /**
25
+ * Custom resource that triggers a CodeBuild build at deploy time to build and push
26
+ * a container image to ECR.
27
+ *
28
+ * Uses an inline Lambda function that:
29
+ * 1. Starts a CodeBuild build with the source asset and ECR target
30
+ * 2. Polls for build completion
31
+ * 3. Returns the container URI as a CloudFormation output
32
+ *
33
+ * The image tag is derived from the source asset hash, ensuring rebuilds only
34
+ * happen when source code changes.
35
+ */
36
+ export declare class ContainerImageBuilder extends Construct {
37
+ readonly containerUri: string;
38
+ constructor(scope: Construct, id: string, props: ContainerImageBuilderProps);
39
+ }
40
+ //# sourceMappingURL=ContainerImageBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContainerImageBuilder.d.ts","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/ContainerImageBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AAC1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAKrE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,YAAY,EAAE,qBAAqB,CAAC;IAEpC;;OAEG;IACH,WAAW,EAAE,oBAAoB,CAAC;IAElC;;OAEG;IACH,UAAU,EAAE,kBAAkB,CAAC;IAE/B;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;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;CAwC5E"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ContainerImageBuilder = void 0;
37
+ const container_build_handler_1 = require("./container-build-handler");
38
+ const cdk = __importStar(require("aws-cdk-lib"));
39
+ const iam = __importStar(require("aws-cdk-lib/aws-iam"));
40
+ const lambda = __importStar(require("aws-cdk-lib/aws-lambda"));
41
+ const constructs_1 = require("constructs");
42
+ /**
43
+ * Custom resource that triggers a CodeBuild build at deploy time to build and push
44
+ * a container image to ECR.
45
+ *
46
+ * Uses an inline Lambda function that:
47
+ * 1. Starts a CodeBuild build with the source asset and ECR target
48
+ * 2. Polls for build completion
49
+ * 3. Returns the container URI as a CloudFormation output
50
+ *
51
+ * The image tag is derived from the source asset hash, ensuring rebuilds only
52
+ * happen when source code changes.
53
+ */
54
+ class ContainerImageBuilder extends constructs_1.Construct {
55
+ containerUri;
56
+ constructor(scope, id, props) {
57
+ super(scope, id);
58
+ const { buildProject, sourceAsset, repository, dockerfile } = props;
59
+ const handler = new lambda.Function(this, 'ContainerBuildHandler', {
60
+ runtime: lambda.Runtime.NODEJS_20_X,
61
+ handler: 'index.handler',
62
+ code: lambda.Code.fromInline(container_build_handler_1.CONTAINER_BUILD_HANDLER_CODE),
63
+ timeout: cdk.Duration.minutes(15),
64
+ memorySize: 256,
65
+ });
66
+ // Grant Lambda permission to trigger builds and read results
67
+ handler.addToRolePolicy(new iam.PolicyStatement({
68
+ actions: ['codebuild:StartBuild', 'codebuild:BatchGetBuilds'],
69
+ resources: [buildProject.project.projectArn],
70
+ }));
71
+ // Image tag based on source asset hash for cache invalidation
72
+ const imageTag = sourceAsset.asset.assetHash;
73
+ const imageUri = `${repository.repository.repositoryUri}:${imageTag}`;
74
+ const cr = new cdk.CustomResource(this, 'ContainerBuildTrigger', {
75
+ serviceToken: handler.functionArn,
76
+ properties: {
77
+ ProjectName: buildProject.project.projectName,
78
+ SourceBucket: sourceAsset.asset.s3BucketName,
79
+ SourceKey: sourceAsset.asset.s3ObjectKey,
80
+ ImageUri: imageUri,
81
+ DockerfilePath: dockerfile,
82
+ EcrRegistry: `${cdk.Aws.ACCOUNT_ID}.dkr.ecr.${cdk.Aws.REGION}.amazonaws.com`,
83
+ SourceHash: sourceAsset.asset.assetHash,
84
+ },
85
+ });
86
+ this.containerUri = cr.getAttString('ContainerUri');
87
+ }
88
+ }
89
+ exports.ContainerImageBuilder = ContainerImageBuilder;
90
+ //# sourceMappingURL=ContainerImageBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContainerImageBuilder.js","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/ContainerImageBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,uEAAyE;AACzE,iDAAmC;AACnC,yDAA2C;AAC3C,+DAAiD;AACjD,2CAAuC;AAyBvC;;;;;;;;;;;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,GAAG,KAAK,CAAC;QAEpE,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,6DAA6D;QAC7D,OAAO,CAAC,eAAe,CACrB,IAAI,GAAG,CAAC,eAAe,CAAC;YACtB,OAAO,EAAE,CAAC,sBAAsB,EAAE,0BAA0B,CAAC;YAC7D,SAAS,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC;SAC7C,CAAC,CACH,CAAC;QAEF,8DAA8D;QAC9D,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC;QAC7C,MAAM,QAAQ,GAAG,GAAG,UAAU,CAAC,UAAU,CAAC,aAAa,IAAI,QAAQ,EAAE,CAAC;QAEtE,MAAM,EAAE,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE;YAC/D,YAAY,EAAE,OAAO,CAAC,WAAW;YACjC,UAAU,EAAE;gBACV,WAAW,EAAE,YAAY,CAAC,OAAO,CAAC,WAAW;gBAC7C,YAAY,EAAE,WAAW,CAAC,KAAK,CAAC,YAAY;gBAC5C,SAAS,EAAE,WAAW,CAAC,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,gBAAgB;gBAC5E,UAAU,EAAE,WAAW,CAAC,KAAK,CAAC,SAAS;aACxC;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IACtD,CAAC;CACF;AA3CD,sDA2CC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Inline Lambda handler code for triggering CodeBuild container image builds.
3
+ *
4
+ * This is deployed via lambda.Code.fromInline() as a CloudFormation Custom Resource handler.
5
+ * It starts a CodeBuild build, polls for completion, and returns the container URI.
6
+ *
7
+ * Stored as a string constant (not a standalone .js file) because this library is
8
+ * consumed as an npm package — __dirname / fromAsset paths won't resolve correctly
9
+ * in consumer projects.
10
+ *
11
+ * Custom Resource properties:
12
+ * - ProjectName: CodeBuild project name
13
+ * - SourceBucket/SourceKey: S3 location of the source code
14
+ * - EcrRegistry: ECR registry URL
15
+ * - ImageUri: Target image URI (repo:tag)
16
+ * - DockerfilePath: Path to Dockerfile in the source
17
+ */
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 url = require('url');\n const responseBody = JSON.stringify(response);\n const parsedUrl = url.parse(event.ResponseURL);\n const options = {\n hostname: parsedUrl.hostname,\n port: 443,\n path: parsedUrl.path,\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
+ //# sourceMappingURL=container-build-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container-build-handler.d.ts","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/container-build-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,4BAA4B,upGA2FxC,CAAC"}