@aws/agentcore-cdk 0.1.0-alpha.42 → 0.1.0-alpha.44
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/README.md +22 -0
- package/dist/cdk/constructs/components/container/ContainerBuildProject.d.ts +32 -8
- package/dist/cdk/constructs/components/container/ContainerBuildProject.d.ts.map +1 -1
- package/dist/cdk/constructs/components/container/ContainerBuildProject.js +105 -11
- package/dist/cdk/constructs/components/container/ContainerBuildProject.js.map +1 -1
- package/dist/cdk/constructs/components/container/ContainerImageBuilder.d.ts +9 -0
- package/dist/cdk/constructs/components/container/ContainerImageBuilder.d.ts.map +1 -1
- package/dist/cdk/constructs/components/container/ContainerImageBuilder.js +10 -0
- package/dist/cdk/constructs/components/container/ContainerImageBuilder.js.map +1 -1
- package/dist/cdk/constructs/components/mcp/Gateway.d.ts.map +1 -1
- package/dist/cdk/constructs/components/mcp/Gateway.js +122 -82
- package/dist/cdk/constructs/components/mcp/Gateway.js.map +1 -1
- package/dist/cdk/constructs/components/mcp/connector-defaults.js +4 -4
- package/dist/cdk/constructs/components/mcp/connector-defaults.js.map +1 -1
- package/dist/cdk/constructs/components/primitives/config-bundle/AgentCoreConfigBundle.d.ts.map +1 -1
- package/dist/cdk/constructs/components/primitives/config-bundle/AgentCoreConfigBundle.js +1 -0
- package/dist/cdk/constructs/components/primitives/config-bundle/AgentCoreConfigBundle.js.map +1 -1
- package/dist/cdk/constructs/l3/AgentCoreHarnessEnvironment.d.ts.map +1 -1
- package/dist/cdk/constructs/l3/AgentCoreHarnessEnvironment.js +7 -1
- package/dist/cdk/constructs/l3/AgentCoreHarnessEnvironment.js.map +1 -1
- package/dist/cdk/constructs/l3/AgentEnvironment.d.ts.map +1 -1
- package/dist/cdk/constructs/l3/AgentEnvironment.js +8 -2
- package/dist/cdk/constructs/l3/AgentEnvironment.js.map +1 -1
- package/dist/schema/constants.d.ts +6 -0
- package/dist/schema/constants.d.ts.map +1 -1
- package/dist/schema/constants.js +16 -1
- package/dist/schema/constants.js.map +1 -1
- package/dist/schema/schemas/agent-env.d.ts +2 -0
- package/dist/schema/schemas/agent-env.d.ts.map +1 -1
- package/dist/schema/schemas/agent-env.js +25 -5
- package/dist/schema/schemas/agent-env.js.map +1 -1
- package/dist/schema/schemas/agentcore-project.d.ts +22 -10
- package/dist/schema/schemas/agentcore-project.d.ts.map +1 -1
- package/dist/schema/schemas/agentcore-project.js +11 -7
- package/dist/schema/schemas/agentcore-project.js.map +1 -1
- package/dist/schema/schemas/auth.d.ts.map +1 -1
- package/dist/schema/schemas/auth.js +11 -8
- package/dist/schema/schemas/auth.js.map +1 -1
- package/dist/schema/schemas/mcp.d.ts +34 -20
- package/dist/schema/schemas/mcp.d.ts.map +1 -1
- package/dist/schema/schemas/mcp.js +17 -187
- package/dist/schema/schemas/mcp.js.map +1 -1
- package/dist/schema/schemas/primitives/config-bundle.d.ts +1 -0
- package/dist/schema/schemas/primitives/config-bundle.d.ts.map +1 -1
- package/dist/schema/schemas/primitives/config-bundle.js +5 -0
- package/dist/schema/schemas/primitives/config-bundle.js.map +1 -1
- package/dist/schema/schemas/primitives/harness.d.ts +1 -0
- package/dist/schema/schemas/primitives/harness.d.ts.map +1 -1
- package/dist/schema/schemas/primitives/harness.js +17 -0
- package/dist/schema/schemas/primitives/harness.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -59,6 +59,28 @@ L3 construct for MCP gateways and tools.
|
|
|
59
59
|
|
|
60
60
|
Individual agent environment construct.
|
|
61
61
|
|
|
62
|
+
### Container builds in a VPC
|
|
63
|
+
|
|
64
|
+
When a Container-build agent (or harness) sets `networkMode: VPC`, the build infrastructure — the orchestrator Lambda
|
|
65
|
+
and the shared CodeBuild project — is placed in the same VPC as the runtime, using `networkConfig.subnets` and
|
|
66
|
+
`networkConfig.securityGroups`. CodeBuild additionally requires `networkConfig.vpcId` (its API cannot infer the VPC from
|
|
67
|
+
subnets); it is required only for Container builds in VPC mode.
|
|
68
|
+
|
|
69
|
+
All Container agents and harnesses in a single project must build in the same VPC — the CodeBuild project is shared per
|
|
70
|
+
stack and synthesis fails fast on a mismatch. Container builds in VPC mode allow at most 5 security groups (a CodeBuild
|
|
71
|
+
limit), vs 16 for the runtime.
|
|
72
|
+
|
|
73
|
+
**Network prerequisites.** Private subnets must be able to reach the services the build uses, or the build will hang
|
|
74
|
+
until timeout:
|
|
75
|
+
|
|
76
|
+
- The build Lambda calls CodeBuild (`StartBuild`/`BatchGetBuilds`) and must reach the CloudFormation response endpoint
|
|
77
|
+
(S3).
|
|
78
|
+
- CodeBuild must reach ECR (api + dkr), S3 (source asset), CloudWatch Logs, STS, and any registry the Dockerfile pulls
|
|
79
|
+
base images from.
|
|
80
|
+
|
|
81
|
+
Provide a NAT gateway or VPC endpoints for: ECR (api, dkr), S3 (gateway), CloudWatch Logs, CodeBuild, and STS — plus
|
|
82
|
+
egress for public base-image pulls.
|
|
83
|
+
|
|
62
84
|
## Standalone Usage
|
|
63
85
|
|
|
64
86
|
These constructs can be used independently without the CLI:
|
|
@@ -2,12 +2,31 @@ import * as codebuild from 'aws-cdk-lib/aws-codebuild';
|
|
|
2
2
|
import type * as ecr from 'aws-cdk-lib/aws-ecr';
|
|
3
3
|
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
4
4
|
import { Construct } from 'constructs';
|
|
5
|
+
export interface BuildNetworkConfig {
|
|
6
|
+
readonly vpcId: string;
|
|
7
|
+
readonly subnets: string[];
|
|
8
|
+
readonly securityGroups: string[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Build the VPC network config for a container build from a spec's networkMode + networkConfig,
|
|
12
|
+
* or `undefined` for a public (non-VPC) build. Fails fast for direct CDK construct consumers (the
|
|
13
|
+
* CLI's Zod schema already rejects these upstream):
|
|
14
|
+
* - a Container build in VPC mode needs an explicit vpcId (CodeBuild can't infer it from subnets);
|
|
15
|
+
* - CodeBuild allows at most 5 security groups.
|
|
16
|
+
*
|
|
17
|
+
* `label` names the offending agent/harness in the error (e.g. `Agent "foo"`).
|
|
18
|
+
*/
|
|
19
|
+
export declare function toBuildNetwork(label: string, networkMode: string | undefined, networkConfig: {
|
|
20
|
+
vpcId?: string;
|
|
21
|
+
subnets: string[];
|
|
22
|
+
securityGroups: string[];
|
|
23
|
+
} | undefined): BuildNetworkConfig | undefined;
|
|
5
24
|
/**
|
|
6
|
-
*
|
|
25
|
+
* Shared CodeBuild project for building container images.
|
|
7
26
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
27
|
+
* Created once per distinct network config at the stack level (see getOrCreate) and reused across
|
|
28
|
+
* every agent/harness container build that shares that config. The project uses a privileged ARM64
|
|
29
|
+
* environment with Docker layer caching.
|
|
11
30
|
*
|
|
12
31
|
* The buildspec expects environment variables:
|
|
13
32
|
* - ECR_REGISTRY: The ECR registry URL
|
|
@@ -16,13 +35,18 @@ import { Construct } from 'constructs';
|
|
|
16
35
|
*/
|
|
17
36
|
export declare class ContainerBuildProject extends Construct {
|
|
18
37
|
/**
|
|
19
|
-
* Returns the
|
|
20
|
-
*
|
|
38
|
+
* Returns the shared ContainerBuildProject for the given stack and network config, creating it on
|
|
39
|
+
* first request. There is one project per distinct network config: all container builds that share
|
|
40
|
+
* a config (the common case — same VPC, or all public) reuse a single CodeBuild project, while
|
|
41
|
+
* builds needing different VPCs/subnets/SGs each get their own. Container builds are independent
|
|
42
|
+
* (each is triggered by its own custom resource), so this is purely a project-reuse optimization —
|
|
43
|
+
* there is no requirement that they share a VPC.
|
|
21
44
|
*/
|
|
22
|
-
static getOrCreate(scope: Construct): ContainerBuildProject;
|
|
45
|
+
static getOrCreate(scope: Construct, networkConfig?: BuildNetworkConfig): ContainerBuildProject;
|
|
23
46
|
readonly project: codebuild.Project;
|
|
24
47
|
readonly role: iam.Role;
|
|
25
|
-
|
|
48
|
+
readonly networkConfig?: BuildNetworkConfig;
|
|
49
|
+
constructor(scope: Construct, id: string, networkConfig?: BuildNetworkConfig);
|
|
26
50
|
/**
|
|
27
51
|
* Grant the build project permission to push to a specific ECR repository.
|
|
28
52
|
*/
|
|
@@ -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;
|
|
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;;;;;;;;;;;GAWG;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;IA2G5E;;OAEG;IACI,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI;CAGtD"}
|
|
@@ -34,16 +34,50 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.ContainerBuildProject = void 0;
|
|
37
|
+
exports.toBuildNetwork = toBuildNetwork;
|
|
37
38
|
const cdk = __importStar(require("aws-cdk-lib"));
|
|
38
39
|
const codebuild = __importStar(require("aws-cdk-lib/aws-codebuild"));
|
|
39
40
|
const iam = __importStar(require("aws-cdk-lib/aws-iam"));
|
|
40
41
|
const constructs_1 = require("constructs");
|
|
42
|
+
const crypto_1 = require("crypto");
|
|
41
43
|
/**
|
|
42
|
-
*
|
|
44
|
+
* CodeBuild caps a project's VPC config at 5 security groups. We enforce it here (in addition to the
|
|
45
|
+
* CLI's Zod schema) because direct CDK construct consumers bypass the schema — otherwise a 6-SG
|
|
46
|
+
* config synthesizes cleanly and only fails at deploy time when CodeBuild's CreateProject rejects it.
|
|
47
|
+
*/
|
|
48
|
+
const MAX_BUILD_SECURITY_GROUPS = 5;
|
|
49
|
+
/**
|
|
50
|
+
* Build the VPC network config for a container build from a spec's networkMode + networkConfig,
|
|
51
|
+
* or `undefined` for a public (non-VPC) build. Fails fast for direct CDK construct consumers (the
|
|
52
|
+
* CLI's Zod schema already rejects these upstream):
|
|
53
|
+
* - a Container build in VPC mode needs an explicit vpcId (CodeBuild can't infer it from subnets);
|
|
54
|
+
* - CodeBuild allows at most 5 security groups.
|
|
43
55
|
*
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
* `label` names the offending agent/harness in the error (e.g. `Agent "foo"`).
|
|
57
|
+
*/
|
|
58
|
+
function toBuildNetwork(label, networkMode, networkConfig) {
|
|
59
|
+
if (networkMode !== 'VPC' || !networkConfig)
|
|
60
|
+
return undefined;
|
|
61
|
+
if (!networkConfig.vpcId) {
|
|
62
|
+
throw new Error(`${label}: networkConfig.vpcId is required for a container build in VPC mode. ` +
|
|
63
|
+
`CodeBuild's CreateProject API cannot infer the VPC from subnets alone.`);
|
|
64
|
+
}
|
|
65
|
+
if (networkConfig.securityGroups.length > MAX_BUILD_SECURITY_GROUPS) {
|
|
66
|
+
throw new Error(`${label}: a container build in VPC mode allows at most ${MAX_BUILD_SECURITY_GROUPS} security groups ` +
|
|
67
|
+
`(CodeBuild limit), but ${networkConfig.securityGroups.length} were provided.`);
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
vpcId: networkConfig.vpcId,
|
|
71
|
+
subnets: networkConfig.subnets,
|
|
72
|
+
securityGroups: networkConfig.securityGroups,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Shared CodeBuild project for building container images.
|
|
77
|
+
*
|
|
78
|
+
* Created once per distinct network config at the stack level (see getOrCreate) and reused across
|
|
79
|
+
* every agent/harness container build that shares that config. The project uses a privileged ARM64
|
|
80
|
+
* environment with Docker layer caching.
|
|
47
81
|
*
|
|
48
82
|
* The buildspec expects environment variables:
|
|
49
83
|
* - ECR_REGISTRY: The ECR registry URL
|
|
@@ -52,22 +86,31 @@ const constructs_1 = require("constructs");
|
|
|
52
86
|
*/
|
|
53
87
|
class ContainerBuildProject extends constructs_1.Construct {
|
|
54
88
|
/**
|
|
55
|
-
* Returns the
|
|
56
|
-
*
|
|
89
|
+
* Returns the shared ContainerBuildProject for the given stack and network config, creating it on
|
|
90
|
+
* first request. There is one project per distinct network config: all container builds that share
|
|
91
|
+
* a config (the common case — same VPC, or all public) reuse a single CodeBuild project, while
|
|
92
|
+
* builds needing different VPCs/subnets/SGs each get their own. Container builds are independent
|
|
93
|
+
* (each is triggered by its own custom resource), so this is purely a project-reuse optimization —
|
|
94
|
+
* there is no requirement that they share a VPC.
|
|
57
95
|
*/
|
|
58
|
-
static getOrCreate(scope) {
|
|
96
|
+
static getOrCreate(scope, networkConfig) {
|
|
59
97
|
const stack = cdk.Stack.of(scope);
|
|
60
|
-
|
|
98
|
+
// The public (no-VPC) build keeps the original fixed id so existing deployed container stacks see
|
|
99
|
+
// no resource replacement on upgrade. VPC builds are net-new, so a config-derived id suffix has no
|
|
100
|
+
// migration impact; distinct configs get distinct projects instead of the old hard conflict.
|
|
101
|
+
const id = networkConfig ? `ContainerBuildProject-${networkConfigHash(networkConfig)}` : 'ContainerBuildProject';
|
|
61
102
|
const existing = stack.node.tryFindChild(id);
|
|
62
103
|
if (existing) {
|
|
63
104
|
return existing;
|
|
64
105
|
}
|
|
65
|
-
return new ContainerBuildProject(stack, id);
|
|
106
|
+
return new ContainerBuildProject(stack, id, networkConfig);
|
|
66
107
|
}
|
|
67
108
|
project;
|
|
68
109
|
role;
|
|
69
|
-
|
|
110
|
+
networkConfig;
|
|
111
|
+
constructor(scope, id, networkConfig) {
|
|
70
112
|
super(scope, id);
|
|
113
|
+
this.networkConfig = networkConfig;
|
|
71
114
|
const partition = cdk.Stack.of(this).partition;
|
|
72
115
|
const region = cdk.Stack.of(this).region;
|
|
73
116
|
const account = cdk.Stack.of(this).account;
|
|
@@ -88,7 +131,11 @@ class ContainerBuildProject extends constructs_1.Construct {
|
|
|
88
131
|
// policies that reference the project name, which would create a circular
|
|
89
132
|
// dependency when we add DependsOn below.
|
|
90
133
|
this.project = new codebuild.Project(this, 'ContainerBuildProject', {
|
|
91
|
-
|
|
134
|
+
// Public build keeps the original name (no migration churn); per-config VPC builds get a stable
|
|
135
|
+
// hash suffix so multiple projects in one stack don't collide on the physical name.
|
|
136
|
+
projectName: networkConfig
|
|
137
|
+
? `${cdk.Stack.of(this).stackName}-container-builder-${networkConfigHash(networkConfig)}`
|
|
138
|
+
: `${cdk.Stack.of(this).stackName}-container-builder`,
|
|
92
139
|
role: iam.Role.fromRoleArn(this, 'BuildProjectRole', this.role.roleArn, { mutable: false }),
|
|
93
140
|
environment: {
|
|
94
141
|
buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2023_STANDARD_3_0,
|
|
@@ -115,6 +162,40 @@ class ContainerBuildProject extends constructs_1.Construct {
|
|
|
115
162
|
},
|
|
116
163
|
}),
|
|
117
164
|
});
|
|
165
|
+
if (networkConfig) {
|
|
166
|
+
const cfnProject = this.project.node.defaultChild;
|
|
167
|
+
cfnProject.vpcConfig = {
|
|
168
|
+
vpcId: networkConfig.vpcId,
|
|
169
|
+
subnets: networkConfig.subnets,
|
|
170
|
+
securityGroupIds: networkConfig.securityGroups,
|
|
171
|
+
};
|
|
172
|
+
// The L1 override above bypasses CDK's automatic ENI-permission grant (which
|
|
173
|
+
// only fires when a full ec2.IVpc is passed to the L2 prop). The project also
|
|
174
|
+
// uses an imported immutable role, so we add the EC2 permissions CodeBuild
|
|
175
|
+
// needs to create its VPC network interface to the real (mutable) role.
|
|
176
|
+
this.role.addToPolicy(new iam.PolicyStatement({
|
|
177
|
+
actions: [
|
|
178
|
+
'ec2:CreateNetworkInterface',
|
|
179
|
+
'ec2:DescribeNetworkInterfaces',
|
|
180
|
+
'ec2:DeleteNetworkInterface',
|
|
181
|
+
'ec2:DescribeSubnets',
|
|
182
|
+
'ec2:DescribeSecurityGroups',
|
|
183
|
+
'ec2:DescribeDhcpOptions',
|
|
184
|
+
'ec2:DescribeVpcs',
|
|
185
|
+
],
|
|
186
|
+
resources: ['*'],
|
|
187
|
+
}));
|
|
188
|
+
this.role.addToPolicy(new iam.PolicyStatement({
|
|
189
|
+
actions: ['ec2:CreateNetworkInterfacePermission'],
|
|
190
|
+
resources: [`arn:${partition}:ec2:${region}:${account}:network-interface/*`],
|
|
191
|
+
conditions: {
|
|
192
|
+
StringEquals: {
|
|
193
|
+
'ec2:AuthorizedService': 'codebuild.amazonaws.com',
|
|
194
|
+
'ec2:Subnet': networkConfig.subnets.map(s => `arn:${partition}:ec2:${region}:${account}:subnet/${s}`),
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
118
199
|
this.project.node.addDependency(this.role);
|
|
119
200
|
}
|
|
120
201
|
/**
|
|
@@ -125,4 +206,17 @@ class ContainerBuildProject extends constructs_1.Construct {
|
|
|
125
206
|
}
|
|
126
207
|
}
|
|
127
208
|
exports.ContainerBuildProject = ContainerBuildProject;
|
|
209
|
+
/**
|
|
210
|
+
* Stable 8-char hash of a network config, used to give each distinct config its own project id and
|
|
211
|
+
* physical name. Order-independent (subnets/SGs are sorted) so two consumers that pass the same set
|
|
212
|
+
* in a different order share one project. Mirrors the hashing approach in AgentCoreKnowledgeBase.
|
|
213
|
+
*/
|
|
214
|
+
function networkConfigHash(c) {
|
|
215
|
+
const canonical = JSON.stringify({
|
|
216
|
+
vpcId: c.vpcId,
|
|
217
|
+
subnets: [...c.subnets].sort(),
|
|
218
|
+
securityGroups: [...c.securityGroups].sort(),
|
|
219
|
+
});
|
|
220
|
+
return (0, crypto_1.createHash)('sha256').update(canonical).digest('hex').slice(0, 8);
|
|
221
|
+
}
|
|
128
222
|
//# sourceMappingURL=ContainerBuildProject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContainerBuildProject.js","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/ContainerBuildProject.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ContainerBuildProject.js","sourceRoot":"","sources":["../../../../../src/cdk/constructs/components/container/ContainerBuildProject.ts"],"names":[],"mappings":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AAW,CAAC,UAA2B;QAC5C,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CACF;AA3ID,sDA2IC;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"}
|
|
@@ -22,6 +22,15 @@ export interface ContainerImageBuilderProps {
|
|
|
22
22
|
* @default 'Dockerfile'
|
|
23
23
|
*/
|
|
24
24
|
dockerfile: string;
|
|
25
|
+
/**
|
|
26
|
+
* VPC placement for the build Lambda. When present the Lambda is created in
|
|
27
|
+
* these subnets/security groups. Lambda infers the VPC from the subnets, so
|
|
28
|
+
* no VpcId is needed here (unlike CodeBuild).
|
|
29
|
+
*/
|
|
30
|
+
networkConfig?: {
|
|
31
|
+
subnets: string[];
|
|
32
|
+
securityGroups: string[];
|
|
33
|
+
};
|
|
25
34
|
}
|
|
26
35
|
/**
|
|
27
36
|
* Custom resource that triggers a CodeBuild build at deploy time to build and push
|
|
@@ -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;AAEvC,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;
|
|
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;AAEvC,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;;;;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;CAqD5E"}
|
|
@@ -63,6 +63,16 @@ class ContainerImageBuilder extends constructs_1.Construct {
|
|
|
63
63
|
timeout: cdk.Duration.minutes(15),
|
|
64
64
|
memorySize: 256,
|
|
65
65
|
});
|
|
66
|
+
if (props.networkConfig) {
|
|
67
|
+
const cfnFn = handler.node.defaultChild;
|
|
68
|
+
cfnFn.vpcConfig = {
|
|
69
|
+
subnetIds: props.networkConfig.subnets,
|
|
70
|
+
securityGroupIds: props.networkConfig.securityGroups,
|
|
71
|
+
};
|
|
72
|
+
// The L1 override bypasses CDK's automatic VPC-access grant; attach the
|
|
73
|
+
// managed policy that lets the Lambda manage its ENI in the VPC.
|
|
74
|
+
handler.role?.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSLambdaVPCAccessExecutionRole'));
|
|
75
|
+
}
|
|
66
76
|
// Grant Lambda permission to trigger builds and read results
|
|
67
77
|
handler.addToRolePolicy(new iam.PolicyStatement({
|
|
68
78
|
actions: ['codebuild:StartBuild', 'codebuild:BatchGetBuilds'],
|
|
@@ -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;AAgCvC;;;;;;;;;;;GAWG;AACH,MAAa,qBAAsB,SAAQ,sBAAS;IAClC,YAAY,CAAS;IAErC,YAAY,KAAg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c,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;IAQlC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAoD7B;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAysB5B"}
|
|
@@ -172,7 +172,17 @@ class Gateway extends constructs_1.Construct {
|
|
|
172
172
|
.map(t => this.credentials?.[t.outboundAuth.credentialName]?.credentialProviderArn)
|
|
173
173
|
.filter((arn) => !!arn);
|
|
174
174
|
this.addToPolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
175
|
-
|
|
175
|
+
// On-behalf-of (TOKEN_EXCHANGE) OAuth targets exchange the caller's identity for a
|
|
176
|
+
// downstream token, which requires the ...ForJWT / ...ForUserId workload-token variants
|
|
177
|
+
// in addition to the base GetWorkloadAccessToken. Granting all three matches the harness
|
|
178
|
+
// and payment-manager roles (AgentCoreHarnessRole, AgentCorePaymentManager); omitting the
|
|
179
|
+
// ForJWT variant makes gateway-initiated OBO fail with AccessDenied inside AgentCore Identity.
|
|
180
|
+
actions: [
|
|
181
|
+
'bedrock-agentcore:GetResourceOauth2Token',
|
|
182
|
+
'bedrock-agentcore:GetWorkloadAccessToken',
|
|
183
|
+
'bedrock-agentcore:GetWorkloadAccessTokenForJWT',
|
|
184
|
+
'bedrock-agentcore:GetWorkloadAccessTokenForUserId',
|
|
185
|
+
],
|
|
176
186
|
resources: [
|
|
177
187
|
`arn:${partition}:bedrock-agentcore:${stack.region}:${stack.account}:workload-identity-directory/default`,
|
|
178
188
|
`arn:${partition}:bedrock-agentcore:${stack.region}:${stack.account}:workload-identity-directory/default/workload-identity/${this.cfnGateway.attrGatewayIdentifier}`,
|
|
@@ -390,8 +400,8 @@ class Gateway extends constructs_1.Construct {
|
|
|
390
400
|
this.gatewayTargets.set(targetName, cfnTarget);
|
|
391
401
|
return;
|
|
392
402
|
}
|
|
393
|
-
// Handle connector-typed targets (managed-service backed: KB
|
|
394
|
-
if (target.targetType === 'connector' && target.connectorId) {
|
|
403
|
+
// Handle connector-typed targets (managed-service backed: KB retrieve + agentic-retrieve)
|
|
404
|
+
if (target.targetType === 'connector' && target.connectorId === 'bedrock-knowledge-bases') {
|
|
395
405
|
const defaults = connector_defaults_1.CONNECTOR_DEFAULTS[target.connectorId];
|
|
396
406
|
const stack = cdk.Stack.of(this);
|
|
397
407
|
// Real KB IDs match ^[A-Z0-9]{10}$; KB names start with a letter and may
|
|
@@ -412,103 +422,133 @@ class Gateway extends constructs_1.Construct {
|
|
|
412
422
|
}
|
|
413
423
|
return { resolvedId: kb.knowledgeBaseId, kbConstruct: kb, arn: kb.knowledgeBaseArn };
|
|
414
424
|
};
|
|
415
|
-
const
|
|
416
|
-
// Service assumes the gateway role and signs the bedrock-agent-runtime
|
|
417
|
-
// call with it; without bedrock:Retrieve, every connector invocation
|
|
418
|
-
// gets AccessDenied at runtime.
|
|
425
|
+
const grantKbPermissions = (kbArn) => {
|
|
419
426
|
this.addToPolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
420
|
-
actions: ['bedrock:Retrieve'],
|
|
427
|
+
actions: ['bedrock:GetKnowledgeBase', 'bedrock:Retrieve'],
|
|
421
428
|
resources: [kbArn],
|
|
422
429
|
}));
|
|
423
430
|
};
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
},
|
|
449
|
-
});
|
|
450
|
-
// The raw CfnResource has no typed `attrTargetId`; attach one so the
|
|
451
|
-
// target can be stored in `gatewayTargets` and surfaced as a CfnOutput
|
|
452
|
-
// by AgentCoreMcp (same shim as the httpRuntime branch).
|
|
453
|
-
return Object.assign(rawTarget, {
|
|
454
|
-
attrTargetId: rawTarget.getAtt('TargetId').toString(),
|
|
455
|
-
});
|
|
456
|
-
};
|
|
457
|
-
// Single-KB retrieve: bedrock-knowledge-bases.
|
|
458
|
-
if (target.connectorId === 'bedrock-knowledge-bases') {
|
|
459
|
-
if (!target.knowledgeBaseId) {
|
|
460
|
-
throw new Error(`Connector target "${targetName}" (bedrock-knowledge-bases) is missing knowledgeBaseId`);
|
|
461
|
-
}
|
|
462
|
-
const { resolvedId, kbConstruct, arn } = resolveKbReference(target.knowledgeBaseId);
|
|
463
|
-
grantRetrieve(arn);
|
|
464
|
-
const cfnTarget = buildCfnTarget({ knowledgeBaseId: resolvedId });
|
|
465
|
-
cfnTarget.node.addDependency(this.cfnGateway);
|
|
466
|
-
if (kbConstruct)
|
|
467
|
-
cfnTarget.node.addDependency(kbConstruct);
|
|
468
|
-
this.gatewayTargets.set(targetName, cfnTarget);
|
|
469
|
-
return;
|
|
470
|
-
}
|
|
471
|
-
// Multi-KB orchestrated retrieve: bedrock-agentic-retrieve. ParameterValues
|
|
472
|
-
// carries a retrievers[] array; one entry per bound KB. Foundation model is
|
|
473
|
-
// intentionally omitted — the agent supplies it at tool-call time.
|
|
474
|
-
if (target.connectorId === 'bedrock-agentic-retrieve') {
|
|
475
|
-
if (!target.knowledgeBaseIds || target.knowledgeBaseIds.length === 0) {
|
|
476
|
-
throw new Error(`Connector target "${targetName}" (bedrock-agentic-retrieve) requires a non-empty knowledgeBaseIds[]`);
|
|
431
|
+
// Resolve KB references within each configuration entry's parameterValues.
|
|
432
|
+
// The configurations array may contain Retrieve and/or AgenticRetrieveStream entries.
|
|
433
|
+
const configurations = target.configurations ?? [];
|
|
434
|
+
const kbDependencies = [];
|
|
435
|
+
// Build resolved CFN Configurations array
|
|
436
|
+
const cfnConfigurations = [];
|
|
437
|
+
for (const config of configurations) {
|
|
438
|
+
const pv = config.parameterValues;
|
|
439
|
+
if (config.name === 'Retrieve' && pv?.knowledgeBaseId) {
|
|
440
|
+
const { resolvedId, kbConstruct, arn } = resolveKbReference(pv.knowledgeBaseId);
|
|
441
|
+
grantKbPermissions(arn);
|
|
442
|
+
if (kbConstruct)
|
|
443
|
+
kbDependencies.push(kbConstruct);
|
|
444
|
+
cfnConfigurations.push({
|
|
445
|
+
Name: config.name,
|
|
446
|
+
ParameterValues: { ...pv, knowledgeBaseId: resolvedId },
|
|
447
|
+
...(config.parameterOverrides && {
|
|
448
|
+
ParameterOverrides: config.parameterOverrides.map(o => ({
|
|
449
|
+
Path: o.path,
|
|
450
|
+
...(o.description && { Description: o.description }),
|
|
451
|
+
...(o.visible !== undefined && { Visible: o.visible }),
|
|
452
|
+
})),
|
|
453
|
+
}),
|
|
454
|
+
});
|
|
477
455
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
456
|
+
else if (config.name === 'AgenticRetrieveStream' && Array.isArray(pv?.retrievers)) {
|
|
457
|
+
const retrievers = pv.retrievers;
|
|
458
|
+
const kbIds = retrievers.map(r => r.configuration.knowledgeBase.knowledgeBaseId);
|
|
459
|
+
const resolved = kbIds.map(value => resolveKbReference(value));
|
|
460
|
+
for (const r of resolved) {
|
|
461
|
+
grantKbPermissions(r.arn);
|
|
462
|
+
if (r.kbConstruct)
|
|
463
|
+
kbDependencies.push(r.kbConstruct);
|
|
464
|
+
}
|
|
465
|
+
this.addToPolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
466
|
+
actions: ['bedrock:AgenticRetrieveStream'],
|
|
467
|
+
resources: ['*'],
|
|
468
|
+
}));
|
|
469
|
+
const resolvedRetrievers = resolved.map(r => ({
|
|
470
|
+
configuration: { knowledgeBase: { knowledgeBaseId: r.resolvedId } },
|
|
471
|
+
}));
|
|
472
|
+
cfnConfigurations.push({
|
|
473
|
+
Name: config.name,
|
|
474
|
+
ParameterValues: { ...pv, retrievers: resolvedRetrievers },
|
|
475
|
+
...(config.parameterOverrides && {
|
|
476
|
+
ParameterOverrides: config.parameterOverrides.map(o => ({
|
|
477
|
+
Path: o.path,
|
|
478
|
+
...(o.description && { Description: o.description }),
|
|
479
|
+
...(o.visible !== undefined && { Visible: o.visible }),
|
|
480
|
+
})),
|
|
481
|
+
}),
|
|
482
|
+
});
|
|
481
483
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
484
|
+
else {
|
|
485
|
+
// Pass through any other configuration entry as-is
|
|
486
|
+
cfnConfigurations.push({
|
|
487
|
+
Name: config.name,
|
|
488
|
+
...(pv && { ParameterValues: pv }),
|
|
489
|
+
...(config.parameterOverrides && {
|
|
490
|
+
ParameterOverrides: config.parameterOverrides.map(o => ({
|
|
491
|
+
Path: o.path,
|
|
492
|
+
...(o.description && { Description: o.description }),
|
|
493
|
+
...(o.visible !== undefined && { Visible: o.visible }),
|
|
494
|
+
})),
|
|
495
|
+
}),
|
|
496
|
+
});
|
|
490
497
|
}
|
|
491
|
-
this.gatewayTargets.set(targetName, cfnTarget);
|
|
492
|
-
return;
|
|
493
498
|
}
|
|
494
|
-
|
|
499
|
+
// Derive the Enabled list from the configuration names
|
|
500
|
+
const enabled = cfnConfigurations.map(c => c.Name);
|
|
501
|
+
// CfnResource escape hatch: the typed L1 (CfnGatewayTarget) doesn't
|
|
502
|
+
// model the Connector branch under TargetConfiguration.Mcp yet.
|
|
503
|
+
const rawTarget = new cdk.CfnResource(this, (0, logical_ids_1.toPascalId)('Target', targetName), {
|
|
504
|
+
type: 'AWS::BedrockAgentCore::GatewayTarget',
|
|
505
|
+
properties: {
|
|
506
|
+
GatewayIdentifier: this.cfnGateway.attrGatewayIdentifier,
|
|
507
|
+
Name: targetName,
|
|
508
|
+
Description: `${defaults.label} target: ${targetName}`,
|
|
509
|
+
CredentialProviderConfigurations: [{ CredentialProviderType: 'GATEWAY_IAM_ROLE' }],
|
|
510
|
+
TargetConfiguration: {
|
|
511
|
+
Mcp: {
|
|
512
|
+
Connector: {
|
|
513
|
+
Source: { ConnectorId: target.connectorId },
|
|
514
|
+
Enabled: enabled,
|
|
515
|
+
Configurations: cfnConfigurations,
|
|
516
|
+
},
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
},
|
|
520
|
+
});
|
|
521
|
+
const cfnTarget = Object.assign(rawTarget, {
|
|
522
|
+
attrTargetId: rawTarget.getAtt('TargetId').toString(),
|
|
523
|
+
});
|
|
524
|
+
cfnTarget.node.addDependency(this.cfnGateway);
|
|
525
|
+
const defaultPolicy = this.role.node.tryFindChild('DefaultPolicy');
|
|
526
|
+
if (defaultPolicy)
|
|
527
|
+
cfnTarget.node.addDependency(defaultPolicy);
|
|
528
|
+
for (const kb of kbDependencies) {
|
|
529
|
+
cfnTarget.node.addDependency(kb);
|
|
530
|
+
}
|
|
531
|
+
this.gatewayTargets.set(targetName, cfnTarget);
|
|
532
|
+
return;
|
|
495
533
|
}
|
|
496
534
|
// Amazon Web Search target. ConnectorId='web-search', optional domain
|
|
497
535
|
// exclusion list. Gateway role needs InvokeWebSearch on the aws-owned tool ARN.
|
|
498
|
-
if (target.targetType === '
|
|
536
|
+
if (target.targetType === 'connector' && target.connectorId === 'web-search') {
|
|
499
537
|
const stack = cdk.Stack.of(this);
|
|
500
538
|
// The aws-owned web-search tool ARN is published in commercial regions
|
|
501
539
|
// only today. `stack.partition` will template aws-cn / aws-us-gov
|
|
502
540
|
// correctly, but the resource itself doesn't exist there — first
|
|
503
541
|
// tools/call would fail at runtime. Warn at synth so users know.
|
|
504
542
|
if (!cdk.Token.isUnresolved(stack.partition) && stack.partition !== 'aws') {
|
|
505
|
-
cdk.Annotations.of(this).addWarning(`
|
|
543
|
+
cdk.Annotations.of(this).addWarning(`web-search connector target "${targetName}" is being synthesized in partition "${stack.partition}", but ` +
|
|
506
544
|
`the underlying \`aws:tool/web-search.v1\` resource is currently only published in the commercial ` +
|
|
507
545
|
`(aws) partition. Tool invocations will fail at runtime in this partition.`);
|
|
508
546
|
}
|
|
509
547
|
const parameterValues = {};
|
|
510
|
-
|
|
511
|
-
|
|
548
|
+
const firstConfig = target.configurations?.[0];
|
|
549
|
+
const domainFilter = firstConfig?.parameterValues?.domainFilter;
|
|
550
|
+
if (domainFilter?.exclude && domainFilter.exclude.length > 0) {
|
|
551
|
+
parameterValues.domainFilter = { exclude: domainFilter.exclude };
|
|
512
552
|
}
|
|
513
553
|
this.addToPolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
514
554
|
actions: ['bedrock-agentcore:InvokeWebSearch'],
|
|
@@ -546,12 +586,12 @@ class Gateway extends constructs_1.Construct {
|
|
|
546
586
|
attrTargetId: rawTarget.getAtt('TargetId').toString(),
|
|
547
587
|
});
|
|
548
588
|
cfnTarget.node.addDependency(this.cfnGateway);
|
|
549
|
-
// Dependency on the gateway role ensures the InvokeWebSearch IAM grant
|
|
550
|
-
// is attached before the target is created, so the gateway service has
|
|
551
|
-
// the permission needed to invoke the connector on first call.
|
|
552
589
|
if (this.role instanceof aws_cdk_lib_1.aws_iam.Role) {
|
|
553
590
|
cfnTarget.node.addDependency(this.role);
|
|
554
591
|
}
|
|
592
|
+
const wsDefaultPolicy = this.role.node.tryFindChild('DefaultPolicy');
|
|
593
|
+
if (wsDefaultPolicy)
|
|
594
|
+
cfnTarget.node.addDependency(wsDefaultPolicy);
|
|
555
595
|
this.gatewayTargets.set(targetName, cfnTarget);
|
|
556
596
|
return;
|
|
557
597
|
}
|