serverless-bedrock-agentcore-plugin 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +43 -16
- package/package.json +1 -1
- package/src/compilers/runtime.js +23 -0
- package/src/validators/schema.js +51 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Resource-based policy support for AgentCore Runtime
|
|
13
|
+
- Enable cross-account access to agent runtimes
|
|
14
|
+
- Standard IAM policy document format
|
|
15
|
+
- Support for multiple principals and statements
|
|
16
|
+
- New example: `cross-account-access` demonstrating resource policy usage
|
|
17
|
+
- Schema validation for `resourcePolicy` configuration
|
|
18
|
+
- Test coverage for resource policy builder functions
|
|
19
|
+
|
|
10
20
|
## [0.2.0] - 2025-12-19
|
|
11
21
|
|
|
12
22
|
### Added
|
package/README.md
CHANGED
|
@@ -87,29 +87,56 @@ agents:
|
|
|
87
87
|
- X-User-Id
|
|
88
88
|
- X-Session-Id
|
|
89
89
|
- Authorization
|
|
90
|
+
# Optional: Resource-based policy for cross-account access
|
|
91
|
+
resourcePolicy:
|
|
92
|
+
Version: '2012-10-17'
|
|
93
|
+
Statement:
|
|
94
|
+
- Sid: AllowCrossAccountInvoke
|
|
95
|
+
Effect: Allow
|
|
96
|
+
Principal:
|
|
97
|
+
AWS: arn:aws:iam::123456789012:role/MyRole
|
|
98
|
+
Action:
|
|
99
|
+
- bedrock-agentcore:InvokeAgentRuntime
|
|
100
|
+
Resource: '*'
|
|
90
101
|
```
|
|
91
102
|
|
|
92
|
-
| Property | Required
|
|
93
|
-
| ------------------------------------------------ |
|
|
94
|
-
| `type` | Yes
|
|
95
|
-
| `artifact.docker.path` | Yes\*
|
|
96
|
-
| `artifact.docker.file` | No
|
|
97
|
-
| `artifact.docker.repository` | No
|
|
98
|
-
| `artifact.containerImage` | Yes\*
|
|
99
|
-
| `protocol` | No
|
|
100
|
-
| `network.networkMode` | No
|
|
101
|
-
| `authorizer.customJwtAuthorizer` | No
|
|
102
|
-
| `authorizer.customJwtAuthorizer.discoveryUrl` | Yes\*\*
|
|
103
|
-
| `authorizer.customJwtAuthorizer.allowedAudience` | No
|
|
104
|
-
| `authorizer.customJwtAuthorizer.allowedClients` | No
|
|
105
|
-
| `requestHeaders.allowlist` | No
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
103
|
+
| Property | Required | Description |
|
|
104
|
+
| ------------------------------------------------ | --------- | ---------------------------------------- |
|
|
105
|
+
| `type` | Yes | `runtime` |
|
|
106
|
+
| `artifact.docker.path` | Yes\* | Docker build context path |
|
|
107
|
+
| `artifact.docker.file` | No | Dockerfile name (default: Dockerfile) |
|
|
108
|
+
| `artifact.docker.repository` | No | ECR repository name |
|
|
109
|
+
| `artifact.containerImage` | Yes\* | Pre-built container image URI |
|
|
110
|
+
| `protocol` | No | `HTTP`, `MCP`, or `A2A` |
|
|
111
|
+
| `network.networkMode` | No | `PUBLIC` or `VPC` |
|
|
112
|
+
| `authorizer.customJwtAuthorizer` | No | JWT authorizer config (omit for no auth) |
|
|
113
|
+
| `authorizer.customJwtAuthorizer.discoveryUrl` | Yes\*\* | OIDC discovery URL |
|
|
114
|
+
| `authorizer.customJwtAuthorizer.allowedAudience` | No | Array of allowed audience values |
|
|
115
|
+
| `authorizer.customJwtAuthorizer.allowedClients` | No | Array of allowed client IDs |
|
|
116
|
+
| `requestHeaders.allowlist` | No | Headers to pass to runtime (max 20) |
|
|
117
|
+
| `resourcePolicy` | No | Resource-based policy (IAM policy doc) |
|
|
118
|
+
| `resourcePolicy.Statement` | Yes\*\*\* | Array of policy statements |
|
|
119
|
+
| `description` | No | Runtime description |
|
|
120
|
+
| `roleArn` | No | Custom IAM role ARN |
|
|
108
121
|
|
|
109
122
|
\*Either `artifact.docker` or `artifact.containerImage` is required
|
|
110
123
|
|
|
111
124
|
\*\*Required when using `customJwtAuthorizer`
|
|
112
125
|
|
|
126
|
+
\*\*\*Required when using `resourcePolicy`
|
|
127
|
+
|
|
128
|
+
#### Resource-Based Policies
|
|
129
|
+
|
|
130
|
+
Resource-based policies allow you to grant cross-account or cross-principal access to invoke your AgentCore runtime. This is useful when you need to allow another AWS account or service to invoke your agent.
|
|
131
|
+
|
|
132
|
+
Example use cases:
|
|
133
|
+
|
|
134
|
+
- **Cross-account access**: Allow an ECS task in another account to invoke your agent
|
|
135
|
+
- **Service-to-service**: Grant specific IAM roles permission to invoke the runtime
|
|
136
|
+
- **Multi-tenant architectures**: Control access across different AWS accounts
|
|
137
|
+
|
|
138
|
+
The `resourcePolicy` follows standard IAM policy document format with `Version` (defaults to `2012-10-17`) and `Statement` array.
|
|
139
|
+
|
|
113
140
|
### Memory
|
|
114
141
|
|
|
115
142
|
Store conversation history with semantic search and summarization.
|
package/package.json
CHANGED
package/src/compilers/runtime.js
CHANGED
|
@@ -182,6 +182,26 @@ function buildRequestHeaderConfiguration(requestHeaders) {
|
|
|
182
182
|
};
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Build resource-based policy for the runtime
|
|
187
|
+
* Allows cross-account or cross-principal access to invoke the agent
|
|
188
|
+
*
|
|
189
|
+
* @param {Object} resourcePolicy - The resource policy configuration from serverless.yml
|
|
190
|
+
* @returns {Object|null} CloudFormation ResourcePolicy or null
|
|
191
|
+
*/
|
|
192
|
+
function buildResourcePolicy(resourcePolicy) {
|
|
193
|
+
if (!resourcePolicy || !resourcePolicy.Statement || resourcePolicy.Statement.length === 0) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// CloudFormation expects the policy as a JSON object
|
|
198
|
+
// The policy should be in standard IAM policy document format
|
|
199
|
+
return {
|
|
200
|
+
Version: resourcePolicy.Version || '2012-10-17',
|
|
201
|
+
Statement: resourcePolicy.Statement,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
185
205
|
/**
|
|
186
206
|
* Compile a Runtime resource to CloudFormation
|
|
187
207
|
*
|
|
@@ -203,6 +223,7 @@ function compileRuntime(name, config, context, tags) {
|
|
|
203
223
|
const protocolConfig = buildProtocolConfiguration(config.protocol);
|
|
204
224
|
const envVars = buildEnvironmentVariables(config.environment);
|
|
205
225
|
const requestHeaderConfig = buildRequestHeaderConfiguration(config.requestHeaders);
|
|
226
|
+
const resourcePolicy = buildResourcePolicy(config.resourcePolicy);
|
|
206
227
|
|
|
207
228
|
return {
|
|
208
229
|
Type: 'AWS::BedrockAgentCore::Runtime',
|
|
@@ -217,6 +238,7 @@ function compileRuntime(name, config, context, tags) {
|
|
|
217
238
|
...(protocolConfig && { ProtocolConfiguration: protocolConfig }),
|
|
218
239
|
...(envVars && { EnvironmentVariables: envVars }),
|
|
219
240
|
...(requestHeaderConfig && { RequestHeaderConfiguration: requestHeaderConfig }),
|
|
241
|
+
...(resourcePolicy && { ResourcePolicy: resourcePolicy }),
|
|
220
242
|
...(Object.keys(tags).length > 0 && { Tags: tags }),
|
|
221
243
|
},
|
|
222
244
|
};
|
|
@@ -231,4 +253,5 @@ module.exports = {
|
|
|
231
253
|
buildProtocolConfiguration,
|
|
232
254
|
buildEnvironmentVariables,
|
|
233
255
|
buildRequestHeaderConfiguration,
|
|
256
|
+
buildResourcePolicy,
|
|
234
257
|
};
|
package/src/validators/schema.js
CHANGED
|
@@ -101,6 +101,57 @@ function defineAgentsSchema(serverless) {
|
|
|
101
101
|
maxConcurrency: { type: 'number' },
|
|
102
102
|
},
|
|
103
103
|
},
|
|
104
|
+
resourcePolicy: {
|
|
105
|
+
type: 'object',
|
|
106
|
+
properties: {
|
|
107
|
+
Version: { type: 'string' },
|
|
108
|
+
Statement: {
|
|
109
|
+
type: 'array',
|
|
110
|
+
items: {
|
|
111
|
+
type: 'object',
|
|
112
|
+
properties: {
|
|
113
|
+
Sid: { type: 'string' },
|
|
114
|
+
Effect: {
|
|
115
|
+
type: 'string',
|
|
116
|
+
enum: ['Allow', 'Deny'],
|
|
117
|
+
},
|
|
118
|
+
Principal: { type: 'object' },
|
|
119
|
+
Action: {
|
|
120
|
+
oneOf: [
|
|
121
|
+
{ type: 'string' },
|
|
122
|
+
{
|
|
123
|
+
type: 'array',
|
|
124
|
+
items: { type: 'string' },
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
Resource: {
|
|
129
|
+
oneOf: [
|
|
130
|
+
{ type: 'string' },
|
|
131
|
+
{
|
|
132
|
+
type: 'array',
|
|
133
|
+
items: { type: 'string' },
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
Condition: { type: 'object' },
|
|
138
|
+
},
|
|
139
|
+
required: ['Effect', 'Principal', 'Action'],
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
required: ['Statement'],
|
|
144
|
+
},
|
|
145
|
+
requestHeaders: {
|
|
146
|
+
type: 'object',
|
|
147
|
+
properties: {
|
|
148
|
+
allowlist: {
|
|
149
|
+
type: 'array',
|
|
150
|
+
items: { type: 'string' },
|
|
151
|
+
maxItems: 20,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
104
155
|
endpoints: {
|
|
105
156
|
type: 'array',
|
|
106
157
|
items: {
|