@aws/nx-plugin 1.0.0-rc.67 → 1.0.0-rc.69
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 +1 -0
- package/generators.json +7 -0
- package/migrations.json +6 -1
- package/package.json +1 -1
- package/src/agentcore-harness/__snapshots__/generator.spec.ts.snap +238 -0
- package/src/agentcore-harness/files/project/README.md.template +83 -0
- package/src/agentcore-harness/files/project/scripts/chat.ts.template +99 -0
- package/src/agentcore-harness/files/project/src/PROMPT.md.template +16 -0
- package/src/agentcore-harness/generator.d.ts +62 -0
- package/src/agentcore-harness/generator.js +158 -0
- package/src/agentcore-harness/generator.js.map +1 -0
- package/src/agentcore-harness/schema.d.js +8 -0
- package/src/agentcore-harness/schema.d.js.map +1 -0
- package/src/agentcore-harness/schema.d.ts +17 -0
- package/src/agentcore-harness/schema.json +53 -0
- package/src/migrations/latest/translate-script-whole-file-writes/files/build-system-prompt.ts.fixture +23 -0
- package/src/migrations/latest/translate-script-whole-file-writes/files/build-user-prompt.ts.fixture +96 -0
- package/src/migrations/latest/translate-script-whole-file-writes/files/config-path.ts.fixture +1 -0
- package/src/migrations/latest/translate-script-whole-file-writes/files/file-to-translate.ts.fixture +10 -0
- package/src/migrations/latest/translate-script-whole-file-writes/files/get-files-to-translate.ts.fixture +96 -0
- package/src/migrations/latest/translate-script-whole-file-writes/files/header.ts.fixture +15 -0
- package/src/migrations/latest/translate-script-whole-file-writes/files/log.ts.fixture +18 -0
- package/src/migrations/latest/translate-script-whole-file-writes/files/main-call.ts.fixture +6 -0
- package/src/migrations/latest/translate-script-whole-file-writes/files/main.ts.fixture +79 -0
- package/src/migrations/latest/translate-script-whole-file-writes/files/project-root.ts.fixture +1 -0
- package/src/migrations/latest/translate-script-whole-file-writes/files/run-with-concurrency.ts.fixture +57 -0
- package/src/migrations/latest/translate-script-whole-file-writes/files/scripts-dir.ts.fixture +1 -0
- package/src/migrations/latest/translate-script-whole-file-writes/files/translate-file-for-language.ts.fixture +61 -0
- package/src/migrations/latest/translate-script-whole-file-writes/grit/already-migrated.grit +1 -0
- package/src/migrations/latest/translate-script-whole-file-writes/grit/build-system-prompt.grit +6 -0
- package/src/migrations/latest/translate-script-whole-file-writes/grit/build-user-prompt.grit +6 -0
- package/src/migrations/latest/translate-script-whole-file-writes/grit/config-path.grit +1 -0
- package/src/migrations/latest/translate-script-whole-file-writes/grit/file-to-translate.grit +11 -0
- package/src/migrations/latest/translate-script-whole-file-writes/grit/get-files-to-translate.grit +7 -0
- package/src/migrations/latest/translate-script-whole-file-writes/grit/log.grit +3 -0
- package/src/migrations/latest/translate-script-whole-file-writes/grit/main-call.grit +1 -0
- package/src/migrations/latest/translate-script-whole-file-writes/grit/main.grit +8 -0
- package/src/migrations/latest/translate-script-whole-file-writes/grit/project-root.grit +1 -0
- package/src/migrations/latest/translate-script-whole-file-writes/grit/run-with-concurrency.grit +6 -0
- package/src/migrations/latest/translate-script-whole-file-writes/grit/translate-file-for-language.grit +6 -0
- package/src/migrations/latest/translate-script-whole-file-writes/metadata.json +3 -0
- package/src/migrations/latest/translate-script-whole-file-writes/migration.d.ts +2 -0
- package/src/migrations/latest/translate-script-whole-file-writes/migration.js +103 -0
- package/src/migrations/latest/translate-script-whole-file-writes/migration.js.map +1 -0
- package/src/migrations/latest/translate-script-whole-file-writes/test-fixtures/released-script-first.ts.fixture +430 -0
- package/src/migrations/latest/translate-script-whole-file-writes/test-fixtures/released-script.ts.fixture +431 -0
- package/src/preset/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/ts/astro-docs/files/translation/scripts/translate.ts.template +269 -148
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +25 -0
- package/src/utils/agent-core-constructs/agent-core-constructs.js +59 -0
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/agent-core-constructs/files/cdk/app/agentcore-harness/__nameKebabCase__/__nameKebabCase__.ts.template +366 -0
- package/src/utils/agent-core-constructs/files/terraform/app/agentcore-harness/__nameKebabCase__/__nameKebabCase__.tf.template +282 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
terraform {
|
|
2
|
+
required_version = ">= 1.0"
|
|
3
|
+
|
|
4
|
+
required_providers {
|
|
5
|
+
aws = {
|
|
6
|
+
source = "hashicorp/aws"
|
|
7
|
+
version = "<%- awsProviderVersion %>"
|
|
8
|
+
}
|
|
9
|
+
random = {
|
|
10
|
+
source = "hashicorp/random"
|
|
11
|
+
version = "<%- randomProviderVersion %>"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
variable "model_id" {
|
|
17
|
+
description = "Amazon Bedrock model or inference profile used by default."
|
|
18
|
+
type = string
|
|
19
|
+
default = "global.anthropic.claude-sonnet-4-6"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
variable "model_resource_arns" {
|
|
23
|
+
description = "Bedrock model and inference-profile ARNs the execution role may invoke. Defaults to every foundation model plus this account's Bedrock resources in the deployment region; replace with narrower ARNs to restrict baseline model access."
|
|
24
|
+
type = set(string)
|
|
25
|
+
default = null
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
variable "additional_execution_role_policy_statements" {
|
|
29
|
+
description = "Additional least-privilege IAM policy statements required by configured optional capabilities (e.g. customer-owned Gateways, memory, custom browsers or code interpreters, skills, secrets). Sid and Condition are optional; null fields are omitted from the rendered policy."
|
|
30
|
+
type = list(object({
|
|
31
|
+
Sid = optional(string)
|
|
32
|
+
Effect = string
|
|
33
|
+
Action = list(string)
|
|
34
|
+
Resource = list(string)
|
|
35
|
+
Condition = optional(any)
|
|
36
|
+
}))
|
|
37
|
+
default = []
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
data "aws_caller_identity" "current" {}
|
|
41
|
+
data "aws_partition" "current" {}
|
|
42
|
+
data "aws_region" "current" {}
|
|
43
|
+
|
|
44
|
+
resource "random_id" "unique_suffix" {
|
|
45
|
+
byte_length = 4
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
locals {
|
|
49
|
+
account_id = data.aws_caller_identity.current.account_id
|
|
50
|
+
partition = data.aws_partition.current.partition
|
|
51
|
+
region = data.aws_region.current.region
|
|
52
|
+
|
|
53
|
+
# Capped at 31 characters so the suffix keeps the deployed Harness name
|
|
54
|
+
# within its 40-character limit.
|
|
55
|
+
harness_name_prefix = "<%- harnessNamePrefix %>"
|
|
56
|
+
harness_name = "${local.harness_name_prefix}_${random_id.unique_suffix.hex}"
|
|
57
|
+
|
|
58
|
+
# Set var.model_resource_arns to narrow the default model access.
|
|
59
|
+
model_resource_arns = var.model_resource_arns != null ? var.model_resource_arns : [
|
|
60
|
+
"arn:${local.partition}:bedrock:*::foundation-model/*",
|
|
61
|
+
"arn:${local.partition}:bedrock:${local.region}:${local.account_id}:*",
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
resource "aws_iam_role" "execution_role" {
|
|
66
|
+
name = "${local.harness_name_prefix}-HarnessRole-${random_id.unique_suffix.hex}"
|
|
67
|
+
|
|
68
|
+
assume_role_policy = jsonencode({
|
|
69
|
+
Version = "2012-10-17"
|
|
70
|
+
Statement = [{
|
|
71
|
+
Effect = "Allow"
|
|
72
|
+
Principal = {
|
|
73
|
+
Service = "bedrock-agentcore.amazonaws.com"
|
|
74
|
+
}
|
|
75
|
+
Action = "sts:AssumeRole"
|
|
76
|
+
Condition = {
|
|
77
|
+
StringEquals = {
|
|
78
|
+
"aws:SourceAccount" = local.account_id
|
|
79
|
+
}
|
|
80
|
+
ArnLike = {
|
|
81
|
+
"aws:SourceArn" = "arn:${local.partition}:bedrock-agentcore:${local.region}:${local.account_id}:*"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}]
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
# Baseline permissions per the AgentCore Harness security guidance; extend for
|
|
89
|
+
# customer-owned resources via var.additional_execution_role_policy_statements.
|
|
90
|
+
# https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/harness-security.html
|
|
91
|
+
resource "aws_iam_role_policy" "execution_role" {
|
|
92
|
+
name = "${local.harness_name_prefix}-HarnessPolicy"
|
|
93
|
+
role = aws_iam_role.execution_role.id
|
|
94
|
+
|
|
95
|
+
policy = jsonencode({
|
|
96
|
+
Version = "2012-10-17"
|
|
97
|
+
Statement = concat([
|
|
98
|
+
{
|
|
99
|
+
Sid = "BedrockModelInvocation"
|
|
100
|
+
Effect = "Allow"
|
|
101
|
+
Action = [
|
|
102
|
+
"bedrock:InvokeModel",
|
|
103
|
+
"bedrock:InvokeModelWithResponseStream",
|
|
104
|
+
]
|
|
105
|
+
Resource = local.model_resource_arns
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
#checkov:skip=CKV_AWS_355:EcrPublicTokenAccess requires a wildcard resource; ecr-public:GetAuthorizationToken has no resource-level permission
|
|
109
|
+
Sid = "EcrPublicTokenAccess"
|
|
110
|
+
Effect = "Allow"
|
|
111
|
+
Action = ["ecr-public:GetAuthorizationToken"]
|
|
112
|
+
Resource = ["*"]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
#checkov:skip=CKV_AWS_355:StsForEcrPublicPull requires a wildcard resource; sts:GetServiceBearerToken has no resource-level permission
|
|
116
|
+
Sid = "StsForEcrPublicPull"
|
|
117
|
+
Effect = "Allow"
|
|
118
|
+
Action = ["sts:GetServiceBearerToken"]
|
|
119
|
+
Resource = ["*"]
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
#checkov:skip=CKV_AWS_355:XRayTracingAccess requires a wildcard resource; the X-Ray segment and sampling APIs have no resource-level permission
|
|
123
|
+
#checkov:skip=CKV_AWS_290:XRayTracingAccess requires a wildcard resource; the X-Ray segment and sampling APIs have no resource-level permission
|
|
124
|
+
Sid = "XRayTracingAccess"
|
|
125
|
+
Effect = "Allow"
|
|
126
|
+
Action = [
|
|
127
|
+
"xray:PutTraceSegments",
|
|
128
|
+
"xray:PutTelemetryRecords",
|
|
129
|
+
"xray:GetSamplingRules",
|
|
130
|
+
"xray:GetSamplingTargets",
|
|
131
|
+
]
|
|
132
|
+
Resource = ["*"]
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
Sid = "CloudWatchLogsGroup"
|
|
136
|
+
Effect = "Allow"
|
|
137
|
+
Action = [
|
|
138
|
+
"logs:CreateLogGroup",
|
|
139
|
+
"logs:DescribeLogStreams",
|
|
140
|
+
]
|
|
141
|
+
Resource = [
|
|
142
|
+
"arn:${local.partition}:logs:${local.region}:${local.account_id}:log-group:/aws/bedrock-agentcore/runtimes/*",
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
Sid = "CloudWatchLogsDescribeGroups"
|
|
147
|
+
Effect = "Allow"
|
|
148
|
+
Action = ["logs:DescribeLogGroups"]
|
|
149
|
+
Resource = ["arn:${local.partition}:logs:${local.region}:${local.account_id}:log-group:*"]
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
Sid = "CloudWatchLogsStream"
|
|
153
|
+
Effect = "Allow"
|
|
154
|
+
Action = [
|
|
155
|
+
"logs:CreateLogStream",
|
|
156
|
+
"logs:PutLogEvents",
|
|
157
|
+
]
|
|
158
|
+
Resource = [
|
|
159
|
+
"arn:${local.partition}:logs:${local.region}:${local.account_id}:log-group:/aws/bedrock-agentcore/runtimes/*:log-stream:*",
|
|
160
|
+
]
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
#checkov:skip=CKV_AWS_355:CloudWatchMetricsPublish requires a wildcard resource; cloudwatch:PutMetricData is scoped by the namespace condition instead
|
|
164
|
+
#checkov:skip=CKV_AWS_290:CloudWatchMetricsPublish requires a wildcard resource; cloudwatch:PutMetricData is scoped by the namespace condition instead
|
|
165
|
+
Sid = "CloudWatchMetricsPublish"
|
|
166
|
+
Effect = "Allow"
|
|
167
|
+
Action = ["cloudwatch:PutMetricData"]
|
|
168
|
+
Resource = ["*"]
|
|
169
|
+
Condition = {
|
|
170
|
+
StringEquals = {
|
|
171
|
+
"cloudwatch:namespace" = "bedrock-agentcore"
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
Sid = "AgentCoreWorkloadIdentity"
|
|
177
|
+
Effect = "Allow"
|
|
178
|
+
Action = [
|
|
179
|
+
"bedrock-agentcore:GetWorkloadAccessToken",
|
|
180
|
+
"bedrock-agentcore:GetWorkloadAccessTokenForJWT",
|
|
181
|
+
]
|
|
182
|
+
Resource = [
|
|
183
|
+
"arn:${local.partition}:bedrock-agentcore:${local.region}:${local.account_id}:workload-identity-directory/default",
|
|
184
|
+
"arn:${local.partition}:bedrock-agentcore:${local.region}:${local.account_id}:workload-identity-directory/default/workload-identity/harness_${local.harness_name}-*",
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
# The service names the managed memory from the harness name plus a
|
|
188
|
+
# generated suffix, so this scopes to that prefix.
|
|
189
|
+
{
|
|
190
|
+
Sid = "AgentCoreManagedMemory"
|
|
191
|
+
Effect = "Allow"
|
|
192
|
+
Action = [
|
|
193
|
+
"bedrock-agentcore:CreateEvent",
|
|
194
|
+
"bedrock-agentcore:DeleteEvent",
|
|
195
|
+
"bedrock-agentcore:GetEvent",
|
|
196
|
+
"bedrock-agentcore:ListEvents",
|
|
197
|
+
"bedrock-agentcore:RetrieveMemoryRecords",
|
|
198
|
+
]
|
|
199
|
+
Resource = [
|
|
200
|
+
"arn:${local.partition}:bedrock-agentcore:${local.region}:${local.account_id}:memory/${local.harness_name}-*",
|
|
201
|
+
]
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
Sid = "AgentCoreBrowserDefault"
|
|
205
|
+
Effect = "Allow"
|
|
206
|
+
Action = [
|
|
207
|
+
"bedrock-agentcore:StartBrowserSession",
|
|
208
|
+
"bedrock-agentcore:StopBrowserSession",
|
|
209
|
+
"bedrock-agentcore:GetBrowserSession",
|
|
210
|
+
"bedrock-agentcore:ListBrowserSessions",
|
|
211
|
+
"bedrock-agentcore:UpdateBrowserStream",
|
|
212
|
+
"bedrock-agentcore:ConnectBrowserAutomationStream",
|
|
213
|
+
"bedrock-agentcore:ConnectBrowserLiveViewStream",
|
|
214
|
+
]
|
|
215
|
+
Resource = [
|
|
216
|
+
"arn:${local.partition}:bedrock-agentcore:${local.region}:aws:browser/*",
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
Sid = "AgentCoreCodeInterpreterDefault"
|
|
221
|
+
Effect = "Allow"
|
|
222
|
+
Action = [
|
|
223
|
+
"bedrock-agentcore:StartCodeInterpreterSession",
|
|
224
|
+
"bedrock-agentcore:StopCodeInterpreterSession",
|
|
225
|
+
"bedrock-agentcore:GetCodeInterpreterSession",
|
|
226
|
+
"bedrock-agentcore:ListCodeInterpreterSessions",
|
|
227
|
+
"bedrock-agentcore:InvokeCodeInterpreter",
|
|
228
|
+
]
|
|
229
|
+
Resource = [
|
|
230
|
+
"arn:${local.partition}:bedrock-agentcore:${local.region}:aws:code-interpreter/*",
|
|
231
|
+
]
|
|
232
|
+
},
|
|
233
|
+
], [
|
|
234
|
+
# Null Sid/Condition fields are dropped from the rendered policy.
|
|
235
|
+
for statement in var.additional_execution_role_policy_statements :
|
|
236
|
+
{ for key, value in statement : key => value if value != null }
|
|
237
|
+
])
|
|
238
|
+
})
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
# Omitting authorizer_configuration uses IAM inbound authorization; add a
|
|
242
|
+
# custom_jwt_authorizer block to change that.
|
|
243
|
+
resource "aws_bedrockagentcore_harness" "this" {
|
|
244
|
+
harness_name = local.harness_name
|
|
245
|
+
execution_role_arn = aws_iam_role.execution_role.arn
|
|
246
|
+
|
|
247
|
+
model {
|
|
248
|
+
bedrock_model_config {
|
|
249
|
+
model_id = var.model_id
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
# Read at plan time; the walk up from path.module reaches the workspace root.
|
|
254
|
+
system_prompt {
|
|
255
|
+
text = file("${path.module}/../../../../../../../<%- promptPathFromTerraform %>")
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
depends_on = [aws_iam_role_policy.execution_role]
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
module "add_harness_arn_to_runtime_config" {
|
|
262
|
+
source = "../../../core/runtime-config/entry"
|
|
263
|
+
|
|
264
|
+
namespace = "agentcore"
|
|
265
|
+
key = "harnesses"
|
|
266
|
+
value = { "<%- nameClassName %>" = aws_bedrockagentcore_harness.this.arn }
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
output "harness_id" {
|
|
270
|
+
description = "ID of the Amazon Bedrock AgentCore Harness"
|
|
271
|
+
value = aws_bedrockagentcore_harness.this.harness_id
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
output "harness_arn" {
|
|
275
|
+
description = "ARN of the Amazon Bedrock AgentCore Harness"
|
|
276
|
+
value = aws_bedrockagentcore_harness.this.arn
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
output "execution_role_arn" {
|
|
280
|
+
description = "ARN of the IAM role assumed by the Harness"
|
|
281
|
+
value = aws_iam_role.execution_role.arn
|
|
282
|
+
}
|