@aws/nx-plugin 1.0.0-rc.90 → 1.0.0-rc.92

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 (111) hide show
  1. package/LICENSE-THIRD-PARTY +2 -2
  2. package/migrations.json +32 -27
  3. package/package.json +4 -4
  4. package/src/infra/app/__snapshots__/generator.spec.ts.snap +3 -3
  5. package/src/internal/test-matrix/generator.js +28 -0
  6. package/src/internal/test-matrix/generator.js.map +1 -1
  7. package/src/migrations/latest/react-website-unique-dev-ports/metadata.json +3 -0
  8. package/src/migrations/latest/react-website-unique-dev-ports/migration.js +79 -0
  9. package/src/migrations/latest/react-website-unique-dev-ports/migration.js.map +1 -0
  10. package/src/migrations/v1.0.0-rc.87/0001-add-destroy-sandbox-target/migration.js.map +1 -0
  11. package/src/migrations/v1.0.0-rc.87/0002-terraform-rdb-proxy-iam-connect-grant/migration.js.map +1 -0
  12. package/src/migrations/v1.0.0-rc.88/0001-python-version-drop-exact-patch/migration.d.ts +6 -0
  13. package/src/migrations/v1.0.0-rc.88/0001-python-version-drop-exact-patch/migration.js.map +1 -0
  14. package/src/migrations/v1.0.0-rc.88/0002-react-website-nx-react-express-override/migration.js.map +1 -0
  15. package/src/migrations/v1.0.0-rc.89/0001-nx-parallel-default/migration.js.map +1 -0
  16. package/src/preset/__snapshots__/generator.spec.ts.snap +2 -2
  17. package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +2 -2
  18. package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +1 -1
  19. package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +91 -116
  20. package/src/py/agent/files/package/main.py.template +13 -0
  21. package/src/py/agent/generator.d.ts +6 -1
  22. package/src/py/agent/generator.js +82 -45
  23. package/src/py/agent/generator.js.map +1 -1
  24. package/src/py/agent/schema.d.js.map +1 -1
  25. package/src/py/agent/schema.d.ts +2 -1
  26. package/src/py/agent/schema.json +2 -2
  27. package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +66 -115
  28. package/src/py/mcp-server/files/package/main.py.template +13 -0
  29. package/src/py/mcp-server/generator.d.ts +6 -1
  30. package/src/py/mcp-server/generator.js +79 -43
  31. package/src/py/mcp-server/generator.js.map +1 -1
  32. package/src/py/mcp-server/schema.d.js.map +1 -1
  33. package/src/py/mcp-server/schema.d.ts +2 -1
  34. package/src/py/mcp-server/schema.json +2 -2
  35. package/src/py/rdb/__snapshots__/generator.spec.ts.snap +14 -61
  36. package/src/ts/agent/__snapshots__/generator.spec.ts.snap +78 -115
  37. package/src/ts/agent/generator.d.ts +26 -1
  38. package/src/ts/agent/generator.js +71 -45
  39. package/src/ts/agent/generator.js.map +1 -1
  40. package/src/ts/agent/schema.d.js.map +1 -1
  41. package/src/ts/agent/schema.d.ts +2 -1
  42. package/src/ts/agent/schema.json +2 -2
  43. package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +65 -114
  44. package/src/ts/mcp-server/generator.d.ts +26 -1
  45. package/src/ts/mcp-server/generator.js +66 -38
  46. package/src/ts/mcp-server/generator.js.map +1 -1
  47. package/src/ts/mcp-server/schema.d.js.map +1 -1
  48. package/src/ts/mcp-server/schema.d.ts +2 -1
  49. package/src/ts/mcp-server/schema.json +2 -2
  50. package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +16 -110
  51. package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +12 -10
  52. package/src/ts/react-website/app/generator.js +16 -0
  53. package/src/ts/react-website/app/generator.js.map +1 -1
  54. package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +1 -1
  55. package/src/ts/react-website/cognito-auth/generator.js +14 -2
  56. package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
  57. package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +25 -6
  58. package/src/utils/agent-core-constructs/agent-core-constructs.js +36 -7
  59. package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
  60. package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +20 -4
  61. package/src/utils/agent-core-constructs/files/terraform/app/agent-core/__nameKebabCase__/__nameKebabCase__.tf.template +34 -1
  62. package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +51 -112
  63. package/src/utils/agent-core-constructs/files/terraform/core/agent-core-code/runtime.tf.template +204 -0
  64. package/src/utils/agent-core-constructs/files/terraform/core/agent-core-container/runtime.tf.template +235 -0
  65. package/src/utils/agent-core-packaging.d.ts +119 -0
  66. package/src/utils/agent-core-packaging.js +131 -0
  67. package/src/utils/agent-core-packaging.js.map +1 -0
  68. package/src/utils/agent-core-runtime-resolution.d.ts +35 -0
  69. package/src/utils/agent-core-runtime-resolution.js +68 -0
  70. package/src/utils/agent-core-runtime-resolution.js.map +1 -0
  71. package/src/utils/files/terraform/src/core/asset-ecr/asset-ecr.tf.template +137 -0
  72. package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +1 -1
  73. package/src/utils/identity-constructs/files/terraform/core/user-identity/identity/identity.tf.template +1 -4
  74. package/src/utils/identity-constructs/identity-constructs.d.ts +22 -2
  75. package/src/utils/identity-constructs/identity-constructs.js +75 -5
  76. package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
  77. package/src/utils/port.d.ts +5 -0
  78. package/src/utils/port.js +1 -1
  79. package/src/utils/port.js.map +1 -1
  80. package/src/utils/rdb-constructs/files/terraform/app/dbs/__nameKebabCase__/__nameKebabCase__.tf.template +12 -59
  81. package/src/utils/versions.d.ts +51 -31
  82. package/src/utils/versions.js +48 -31
  83. package/src/utils/versions.js.map +1 -1
  84. package/src/migrations/latest/add-destroy-sandbox-target/migration.js.map +0 -1
  85. package/src/migrations/latest/nx-parallel-default/migration.js.map +0 -1
  86. package/src/migrations/latest/python-version-drop-exact-patch/migration.js.map +0 -1
  87. package/src/migrations/latest/react-website-nx-react-express-override/migration.js.map +0 -1
  88. package/src/migrations/latest/terraform-rdb-proxy-iam-connect-grant/migration.js.map +0 -1
  89. /package/src/migrations/latest/{add-destroy-sandbox-target → react-website-unique-dev-ports}/migration.d.ts +0 -0
  90. /package/src/migrations/{latest/add-destroy-sandbox-target → v1.0.0-rc.87/0001-add-destroy-sandbox-target}/metadata.json +0 -0
  91. /package/src/migrations/{latest/python-version-drop-exact-patch → v1.0.0-rc.87/0001-add-destroy-sandbox-target}/migration.d.ts +0 -0
  92. /package/src/migrations/{latest/add-destroy-sandbox-target → v1.0.0-rc.87/0001-add-destroy-sandbox-target}/migration.js +0 -0
  93. /package/src/migrations/{latest/terraform-rdb-proxy-iam-connect-grant → v1.0.0-rc.87/0002-terraform-rdb-proxy-iam-connect-grant}/__snapshots__/migration.spec.ts.snap +0 -0
  94. /package/src/migrations/{latest/terraform-rdb-proxy-iam-connect-grant → v1.0.0-rc.87/0002-terraform-rdb-proxy-iam-connect-grant}/metadata.json +0 -0
  95. /package/src/migrations/{latest/terraform-rdb-proxy-iam-connect-grant → v1.0.0-rc.87/0002-terraform-rdb-proxy-iam-connect-grant}/migration.d.ts +0 -0
  96. /package/src/migrations/{latest/terraform-rdb-proxy-iam-connect-grant → v1.0.0-rc.87/0002-terraform-rdb-proxy-iam-connect-grant}/migration.js +0 -0
  97. /package/src/migrations/{latest/python-version-drop-exact-patch → v1.0.0-rc.88/0001-python-version-drop-exact-patch}/metadata.json +0 -0
  98. /package/src/migrations/{latest/python-version-drop-exact-patch → v1.0.0-rc.88/0001-python-version-drop-exact-patch}/migration.js +0 -0
  99. /package/src/migrations/{latest/react-website-nx-react-express-override → v1.0.0-rc.88/0002-react-website-nx-react-express-override}/metadata.json +0 -0
  100. /package/src/migrations/{latest/react-website-nx-react-express-override → v1.0.0-rc.88/0002-react-website-nx-react-express-override}/migration.d.ts +0 -0
  101. /package/src/migrations/{latest/react-website-nx-react-express-override → v1.0.0-rc.88/0002-react-website-nx-react-express-override}/migration.js +0 -0
  102. /package/src/migrations/{latest/nx-parallel-default → v1.0.0-rc.89/0001-nx-parallel-default}/metadata.json +0 -0
  103. /package/src/migrations/{latest/nx-parallel-default → v1.0.0-rc.89/0001-nx-parallel-default}/migration.d.ts +0 -0
  104. /package/src/migrations/{latest/nx-parallel-default → v1.0.0-rc.89/0001-nx-parallel-default}/migration.js +0 -0
  105. /package/src/ts/mcp-server/files/{http.ts.template → app/http.ts.template} +0 -0
  106. /package/src/ts/mcp-server/files/{index.ts.template → app/index.ts.template} +0 -0
  107. /package/src/ts/mcp-server/files/{resources → app/resources}/sample-guidance.ts.template +0 -0
  108. /package/src/ts/mcp-server/files/{server.ts.template → app/server.ts.template} +0 -0
  109. /package/src/ts/mcp-server/files/{stdio.ts.template → app/stdio.ts.template} +0 -0
  110. /package/src/ts/mcp-server/files/{tools → app/tools}/divide.ts.template +0 -0
  111. /package/src/ts/mcp-server/files/{Dockerfile.template → deploy/Dockerfile.template} +0 -0
@@ -0,0 +1,204 @@
1
+ terraform {
2
+ required_version = ">= 1.0"
3
+
4
+ required_providers {
5
+ aws = {
6
+ source = "hashicorp/aws"
7
+ version = "<%- awsProviderVersion %>"
8
+ }
9
+ archive = {
10
+ source = "hashicorp/archive"
11
+ version = "<%- archiveProviderVersion %>"
12
+ }
13
+ }
14
+ }
15
+
16
+ # Code packaging for an AgentCore Runtime: archives the built package, stages it
17
+ # in the shared asset bucket, and delegates the runtime itself to the generic
18
+ # `agent-core` module. Swap this module for `agent-core-container` to deploy a
19
+ # container image instead — the inputs below are the only difference.
20
+
21
+ variable "agent_runtime_name" {
22
+ description = "Name of the agent runtime"
23
+ type = string
24
+ }
25
+
26
+ variable "code_dir" {
27
+ description = "Directory holding the packaged agent code, archived and staged in the asset bucket"
28
+ type = string
29
+ }
30
+
31
+ variable "code_runtime" {
32
+ description = "Managed language runtime executing the packaged code (e.g. NODE_22, PYTHON_3_14)"
33
+ type = string
34
+ }
35
+
36
+ variable "code_entry_point" {
37
+ description = "Entry point file within the packaged code, run by the managed runtime"
38
+ type = string
39
+ }
40
+
41
+ variable "asset_bucket_name" {
42
+ description = "Name of the shared asset S3 bucket used to stage the agent code zip. Instantiate the `core/asset-bucket` module once per deployment and pass its `bucket_name` output here."
43
+ type = string
44
+ }
45
+
46
+ variable "asset_bucket_arn" {
47
+ description = "ARN of the shared asset S3 bucket, used to scope the runtime's read grant to the staged object."
48
+ type = string
49
+ }
50
+
51
+ variable "server_protocol" {
52
+ description = "Server protocol for the agent runtime (HTTP, MCP, or A2A)"
53
+ type = string
54
+ default = "HTTP"
55
+ }
56
+
57
+ variable "authorizer_configuration" {
58
+ description = "Authorization configuration for authenticating incoming requests"
59
+ type = object({
60
+ custom_jwt_authorizer = optional(object({
61
+ discovery_url = string
62
+ allowed_audience = optional(list(string))
63
+ allowed_clients = optional(list(string))
64
+ }))
65
+ })
66
+ default = null
67
+ }
68
+
69
+ variable "env" {
70
+ description = "Environment variables to pass to the agent core runtime"
71
+ type = map(string)
72
+ default = {}
73
+ }
74
+
75
+ variable "additional_iam_policy_statements" {
76
+ description = "Additional IAM policy statements to attach to the agent core runtime role"
77
+ type = list(object({
78
+ Effect = string
79
+ Action = list(string)
80
+ Resource = list(string)
81
+ }))
82
+ default = []
83
+ }
84
+
85
+ variable "enable_vpc" {
86
+ description = "Run the agent core runtime inside a VPC. Set alongside vpc_id/subnet_ids."
87
+ type = bool
88
+ default = false
89
+ }
90
+
91
+ variable "vpc_id" {
92
+ description = "VPC ID to run the agent core runtime in. Required when enable_vpc is true."
93
+ type = string
94
+ default = null
95
+ }
96
+
97
+ variable "subnet_ids" {
98
+ description = "Subnet IDs to run the agent core runtime in. Required when enable_vpc is true."
99
+ type = list(string)
100
+ default = null
101
+ }
102
+
103
+ variable "tags" {
104
+ description = "Tags to apply to resources"
105
+ type = map(string)
106
+ default = {}
107
+ }
108
+
109
+ data "archive_file" "agent_core_code" {
110
+ type = "zip"
111
+ source_dir = var.code_dir
112
+ output_path = "${var.code_dir}.zip"
113
+ }
114
+
115
+ # Keyed on the hex digest rather than `output_base64sha256`, whose `/` and `=`
116
+ # characters would read as a key prefix and leave the object unresolvable.
117
+ resource "aws_s3_object" "agent_core_code" {
118
+ bucket = var.asset_bucket_name
119
+ key = "agent-core/${var.agent_runtime_name}/${data.archive_file.agent_core_code.output_sha256}.zip"
120
+ source = data.archive_file.agent_core_code.output_path
121
+ source_hash = data.archive_file.agent_core_code.output_base64sha256
122
+ etag = data.archive_file.agent_core_code.output_md5
123
+
124
+ tags = var.tags
125
+ }
126
+
127
+ module "runtime" {
128
+ source = "../agent-core"
129
+
130
+ agent_runtime_name = var.agent_runtime_name
131
+ server_protocol = var.server_protocol
132
+ authorizer_configuration = var.authorizer_configuration
133
+ env = var.env
134
+ enable_vpc = var.enable_vpc
135
+ vpc_id = var.vpc_id
136
+ subnet_ids = var.subnet_ids
137
+ tags = var.tags
138
+
139
+ code_configuration = {
140
+ # The `opentelemetry-instrument` prefix auto-instruments with the AWS Distro
141
+ # for OpenTelemetry packaged alongside the code.
142
+ # https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/observability-configure.html
143
+ entry_point = ["opentelemetry-instrument", var.code_entry_point]
144
+ runtime = var.code_runtime
145
+ s3_bucket = aws_s3_object.agent_core_code.bucket
146
+ s3_key = aws_s3_object.agent_core_code.key
147
+ }
148
+
149
+ # The runtime downloads the package, so grant it read access to the object.
150
+ additional_iam_policy_statements = concat([
151
+ {
152
+ Effect = "Allow"
153
+ Action = [
154
+ "s3:GetObject",
155
+ "s3:GetObjectVersion"
156
+ ]
157
+ Resource = [
158
+ "${var.asset_bucket_arn}/agent-core/${var.agent_runtime_name}/*"
159
+ ]
160
+ }
161
+ ], var.additional_iam_policy_statements)
162
+
163
+ artifact_dependencies = [aws_s3_object.agent_core_code]
164
+ }
165
+
166
+ output "agent_core_runtime_role_arn" {
167
+ description = "ARN of the Agent Core Runtime IAM role"
168
+ value = module.runtime.agent_core_runtime_role_arn
169
+ }
170
+
171
+ output "agent_core_runtime_role_name" {
172
+ description = "Name of the Agent Core Runtime IAM role"
173
+ value = module.runtime.agent_core_runtime_role_name
174
+ }
175
+
176
+ output "agent_runtime_name" {
177
+ description = "Name of the deployed agent runtime"
178
+ value = module.runtime.agent_runtime_name
179
+ }
180
+
181
+ output "agent_core_runtime_arn" {
182
+ description = "ARN of the Bedrock Agent Core runtime. For MCP runtimes the value flows through the readiness probe, so consumers wait until the runtime serves MCP."
183
+ value = module.runtime.agent_core_runtime_arn
184
+ }
185
+
186
+ output "invocation_url" {
187
+ description = "HTTPS invocation URL of the runtime. MCP runtimes get the MCP endpoint (e.g. for use as a Gateway target endpoint), A2A runtimes the A2A endpoint (trailing slash required). For MCP runtimes the value flows through the readiness probe, so consumers wait until the runtime serves MCP."
188
+ value = module.runtime.invocation_url
189
+ }
190
+
191
+ output "agent_runtime_id" {
192
+ description = "ID of the Bedrock Agent Core runtime"
193
+ value = module.runtime.agent_runtime_id
194
+ }
195
+
196
+ output "agent_runtime_version" {
197
+ description = "Version of the Bedrock Agent Core runtime"
198
+ value = module.runtime.agent_runtime_version
199
+ }
200
+
201
+ output "security_group_id" {
202
+ description = "Security group ID of the agent core runtime, for use in ingress rules on resources it must reach (e.g. a database). Null unless enable_vpc is true."
203
+ value = module.runtime.security_group_id
204
+ }
@@ -0,0 +1,235 @@
1
+ terraform {
2
+ required_version = ">= 1.0"
3
+
4
+ required_providers {
5
+ aws = {
6
+ source = "hashicorp/aws"
7
+ version = "<%- awsProviderVersion %>"
8
+ }
9
+ external = {
10
+ source = "hashicorp/external"
11
+ version = "<%- externalProviderVersion %>"
12
+ }
13
+ null = {
14
+ source = "hashicorp/null"
15
+ version = "<%- nullProviderVersion %>"
16
+ }
17
+ }
18
+ }
19
+
20
+ # Container packaging for an AgentCore Runtime: publishes the built image to the
21
+ # shared asset registry, and delegates the runtime itself to the generic
22
+ # `agent-core` module. Swap this module for `agent-core-code` to deploy a code
23
+ # package instead — the inputs below are the only difference.
24
+
25
+ variable "agent_runtime_name" {
26
+ description = "Name of the agent runtime"
27
+ type = string
28
+ }
29
+
30
+ variable "docker_image_tag" {
31
+ description = "Name of the docker image tag to use as the agent core runtime"
32
+ type = string
33
+ }
34
+
35
+ variable "asset_ecr_repository_url" {
36
+ description = "URL of the shared asset ECR repository the runtime's image is published to. Instantiate the `core/asset-ecr` module once per deployment and pass its `repository_url` output here."
37
+ type = string
38
+ }
39
+
40
+ variable "asset_ecr_repository_arn" {
41
+ description = "ARN of the shared asset ECR repository (from `core/asset-ecr.repository_arn`), used to scope the runtime's image pull grant to it."
42
+ type = string
43
+ }
44
+
45
+ variable "server_protocol" {
46
+ description = "Server protocol for the agent runtime (HTTP, MCP, or A2A)"
47
+ type = string
48
+ default = "HTTP"
49
+ }
50
+
51
+ variable "authorizer_configuration" {
52
+ description = "Authorization configuration for authenticating incoming requests"
53
+ type = object({
54
+ custom_jwt_authorizer = optional(object({
55
+ discovery_url = string
56
+ allowed_audience = optional(list(string))
57
+ allowed_clients = optional(list(string))
58
+ }))
59
+ })
60
+ default = null
61
+ }
62
+
63
+ variable "env" {
64
+ description = "Environment variables to pass to the agent core runtime"
65
+ type = map(string)
66
+ default = {}
67
+ }
68
+
69
+ variable "additional_iam_policy_statements" {
70
+ description = "Additional IAM policy statements to attach to the agent core runtime role"
71
+ type = list(object({
72
+ Effect = string
73
+ Action = list(string)
74
+ Resource = list(string)
75
+ }))
76
+ default = []
77
+ }
78
+
79
+ variable "enable_vpc" {
80
+ description = "Run the agent core runtime inside a VPC. Set alongside vpc_id/subnet_ids."
81
+ type = bool
82
+ default = false
83
+ }
84
+
85
+ variable "vpc_id" {
86
+ description = "VPC ID to run the agent core runtime in. Required when enable_vpc is true."
87
+ type = string
88
+ default = null
89
+ }
90
+
91
+ variable "subnet_ids" {
92
+ description = "Subnet IDs to run the agent core runtime in. Required when enable_vpc is true."
93
+ type = list(string)
94
+ default = null
95
+ }
96
+
97
+ variable "tags" {
98
+ description = "Tags to apply to resources"
99
+ type = map(string)
100
+ default = {}
101
+ }
102
+
103
+ data "aws_region" "current" {}
104
+
105
+ locals {
106
+ aws_region = data.aws_region.current.id
107
+ }
108
+
109
+ # Data source to get container image digest
110
+ data "external" "docker_digest" {
111
+ program = ["sh", "-c", "echo '{\"digest\":\"'$(<%= containers %> inspect ${var.docker_image_tag} --format '{{.Id}}')'\"}' "]
112
+ }
113
+
114
+ locals {
115
+ # Content-based, immutable image tag derived from the local image digest
116
+ image_tag = "agent-core-${lower(var.agent_runtime_name)}-${replace(data.external.docker_digest.result.digest, "sha256:", "")}"
117
+ }
118
+
119
+ # Null resource for container image publish
120
+ resource "null_resource" "docker_publish" {
121
+ triggers = {
122
+ docker_digest = data.external.docker_digest.result.digest
123
+ repository_url = var.asset_ecr_repository_url
124
+ docker_image_tag = var.docker_image_tag
125
+ image_tag = local.image_tag
126
+ }
127
+
128
+ provisioner "local-exec" {
129
+ command = <<-EOT
130
+ # Get ECR login token
131
+ aws ecr get-login-password --region "$AWS_REGION" | <%= containers %> login --username AWS --password-stdin "$REPOSITORY_URL"
132
+
133
+ # Tag the image with the immutable content-based tag
134
+ <%= containers %> tag "$DOCKER_IMAGE_TAG" "$REPOSITORY_URL:$IMAGE_TAG"
135
+
136
+ # Push the image
137
+ <%= containers %> push "$REPOSITORY_URL:$IMAGE_TAG"
138
+ EOT
139
+ environment = {
140
+ AWS_REGION = local.aws_region
141
+ REPOSITORY_URL = self.triggers.repository_url
142
+ DOCKER_IMAGE_TAG = self.triggers.docker_image_tag
143
+ IMAGE_TAG = self.triggers.image_tag
144
+ }
145
+ }
146
+ }
147
+
148
+ module "runtime" {
149
+ source = "../agent-core"
150
+
151
+ agent_runtime_name = var.agent_runtime_name
152
+ server_protocol = var.server_protocol
153
+ authorizer_configuration = var.authorizer_configuration
154
+ env = var.env
155
+ enable_vpc = var.enable_vpc
156
+ vpc_id = var.vpc_id
157
+ subnet_ids = var.subnet_ids
158
+ tags = var.tags
159
+
160
+ container_configuration = {
161
+ container_uri = "${var.asset_ecr_repository_url}:${local.image_tag}"
162
+ }
163
+
164
+ # The runtime pulls the image, so grant it read access to the repository.
165
+ additional_iam_policy_statements = concat([
166
+ {
167
+ Sid = "ECRImageAccess"
168
+ Effect = "Allow"
169
+ Action = [
170
+ "ecr:BatchGetImage",
171
+ "ecr:GetDownloadUrlForLayer"
172
+ ]
173
+ Resource = [
174
+ var.asset_ecr_repository_arn
175
+ ]
176
+ },
177
+ {
178
+ Sid = "ECRTokenAccess"
179
+ Effect = "Allow"
180
+ Action = [
181
+ "ecr:GetAuthorizationToken"
182
+ ]
183
+ Resource = [
184
+ "*"
185
+ ]
186
+ }
187
+ ], var.additional_iam_policy_statements)
188
+
189
+ artifact_dependencies = [null_resource.docker_publish]
190
+ }
191
+
192
+ output "agent_core_runtime_role_arn" {
193
+ description = "ARN of the Agent Core Runtime IAM role"
194
+ value = module.runtime.agent_core_runtime_role_arn
195
+ }
196
+
197
+ output "agent_core_runtime_role_name" {
198
+ description = "Name of the Agent Core Runtime IAM role"
199
+ value = module.runtime.agent_core_runtime_role_name
200
+ }
201
+
202
+ output "agent_runtime_name" {
203
+ description = "Name of the deployed agent runtime"
204
+ value = module.runtime.agent_runtime_name
205
+ }
206
+
207
+ output "agent_core_runtime_arn" {
208
+ description = "ARN of the Bedrock Agent Core runtime. For MCP runtimes the value flows through the readiness probe, so consumers wait until the runtime serves MCP."
209
+ value = module.runtime.agent_core_runtime_arn
210
+ }
211
+
212
+ output "invocation_url" {
213
+ description = "HTTPS invocation URL of the runtime. MCP runtimes get the MCP endpoint (e.g. for use as a Gateway target endpoint), A2A runtimes the A2A endpoint (trailing slash required). For MCP runtimes the value flows through the readiness probe, so consumers wait until the runtime serves MCP."
214
+ value = module.runtime.invocation_url
215
+ }
216
+
217
+ output "agent_runtime_id" {
218
+ description = "ID of the Bedrock Agent Core runtime"
219
+ value = module.runtime.agent_runtime_id
220
+ }
221
+
222
+ output "agent_runtime_version" {
223
+ description = "Version of the Bedrock Agent Core runtime"
224
+ value = module.runtime.agent_runtime_version
225
+ }
226
+
227
+ output "security_group_id" {
228
+ description = "Security group ID of the agent core runtime, for use in ingress rules on resources it must reach (e.g. a database). Null unless enable_vpc is true."
229
+ value = module.runtime.security_group_id
230
+ }
231
+
232
+ output "container_uri" {
233
+ description = "URI of the published image the runtime runs, within the shared asset registry"
234
+ value = "${var.asset_ecr_repository_url}:${local.image_tag}"
235
+ }
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { type ProjectConfiguration, type Tree } from '@nx/devkit';
6
+ import { type DependencyDeclaration, type MustDeclare } from './declared-dependencies.js';
7
+ import { FS_DEPENDENCIES } from './fs.js';
8
+ /**
9
+ * How an AgentCore Runtime's artifact is packaged and hosted.
10
+ *
11
+ * `agentcore` uploads a `.zip` of the built code to S3 and runs it on an
12
+ * AgentCore managed language runtime, which skips the container build, ECR
13
+ * repository and image push entirely — the fastest build and deploy cycle.
14
+ * `agentcore-ecr` builds an arm64 container image and hosts it from ECR, for
15
+ * workloads needing OS-level control (e.g. native system libraries) or an
16
+ * established container pipeline.
17
+ */
18
+ export declare const AGENT_CORE_INFRA: readonly ["agentcore", "agentcore-ecr", "none"];
19
+ export type AgentCoreInfra = (typeof AGENT_CORE_INFRA)[number];
20
+ /** Whether the given infra option hosts on AgentCore Runtime at all. */
21
+ export declare const isAgentCoreHosted: (infra: AgentCoreInfra) => boolean;
22
+ /** Whether the given infra option builds and hosts a container image. */
23
+ export declare const isContainerHosted: (infra: AgentCoreInfra) => boolean;
24
+ /** The AgentCore managed runtime a TypeScript component targets. */
25
+ export declare const agentCoreNodeRuntime: () => string;
26
+ /** The AgentCore managed runtime a Python component targets. */
27
+ export declare const agentCorePythonRuntime: () => string;
28
+ /**
29
+ * Dependencies a caller must declare to add a code (`.zip`) packaging target.
30
+ *
31
+ * The TypeScript package target vendors the AWS Distro for OpenTelemetry into
32
+ * the package directory, so its version is declared here (spread through
33
+ * `ownedElsewhere` by callers, since the install targets the built package
34
+ * rather than any workspace manifest).
35
+ */
36
+ export declare const CODE_PACKAGE_DEPENDENCIES: readonly [{
37
+ readonly name: "ncp";
38
+ }, {
39
+ readonly name: "rimraf";
40
+ }, {
41
+ readonly name: "make-dir-cli";
42
+ }, {
43
+ readonly name: "cpy-cli";
44
+ }, {
45
+ readonly name: "@aws/aws-distro-opentelemetry-node-autoinstrumentation";
46
+ }];
47
+ export interface AddTypeScriptCodePackageTargetOptions {
48
+ /** Project configuration to add the target to (mutated in place). */
49
+ readonly project: ProjectConfiguration;
50
+ /** Name of the packaging target to add, e.g. `agent-package`. */
51
+ readonly targetName: string;
52
+ /** Name of the target producing the bundled `index.js`, depended on here. */
53
+ readonly bundleTargetName: string;
54
+ /** Directory holding the bundled `index.js`, relative to the workspace root. */
55
+ readonly bundleOutputDir: string;
56
+ /** Directory to assemble the deployable package in, relative to the workspace root. */
57
+ readonly packageOutputDir: string;
58
+ }
59
+ /**
60
+ * Add a target assembling the deployable code package for a TypeScript
61
+ * AgentCore Runtime.
62
+ *
63
+ * The package is the rolldown bundle plus a vendored AWS Distro for
64
+ * OpenTelemetry install. AgentCore rejects a code package with no OpenTelemetry
65
+ * dependencies present (`CREATE_FAILED`: "OpenTelemetry instrumentation
66
+ * executable not found"), so ADOT must ship inside the package rather than
67
+ * being installed at runtime — the `opentelemetry-instrument` entry point
68
+ * prefix resolves it from there.
69
+ *
70
+ * The install is scoped to the package directory with `--prefix` and
71
+ * `--no-save`, so it never touches the project's own manifest. `--omit=dev`
72
+ * keeps the package to what the runtime loads. ADOT is pure JavaScript with no
73
+ * native binaries, so the package is architecture independent even though
74
+ * AgentCore only runs arm64.
75
+ */
76
+ export declare const addTypeScriptCodePackageTarget: <const D extends DependencyDeclaration>(tree: Tree, options: AddTypeScriptCodePackageTargetOptions, declaration: D & MustDeclare<typeof CODE_PACKAGE_DEPENDENCIES, D>) => void;
77
+ export interface AddPythonCodePackageTargetOptions {
78
+ /** Project configuration to add the target to (mutated in place). */
79
+ readonly project: ProjectConfiguration;
80
+ /** Name of the packaging target to add, e.g. `agent-package`. */
81
+ readonly targetName: string;
82
+ /** Name of the arm64 bundle target, depended on here. */
83
+ readonly bundleTargetName: string;
84
+ /** Directory holding the arm64 bundle, relative to the workspace root. */
85
+ readonly bundleOutputDir: string;
86
+ /** Directory to assemble the deployable package in, relative to the workspace root. */
87
+ readonly packageOutputDir: string;
88
+ /**
89
+ * The project's source root, which is itself the module directory — copied
90
+ * into the package under {@link moduleName} so the agent's imports resolve.
91
+ */
92
+ readonly sourceRoot: string;
93
+ /** Python module name (the source root's last segment). */
94
+ readonly moduleName: string;
95
+ /**
96
+ * Path to the entry point script, relative to the workspace root. Copied to
97
+ * the package root, where AgentCore's `entryPoint` runs it.
98
+ */
99
+ readonly entryPointPath: string;
100
+ /** File name the entry point takes at the package root. */
101
+ readonly entryPointFileName: string;
102
+ }
103
+ /**
104
+ * Add a target assembling the deployable code package for a Python AgentCore
105
+ * Runtime.
106
+ *
107
+ * The package is the arm64 dependency bundle (which already carries
108
+ * `bin/opentelemetry-instrument` from `aws-opentelemetry-distro`, satisfying
109
+ * AgentCore's requirement that OpenTelemetry be present), the project's own
110
+ * module tree, and a root entry point script.
111
+ *
112
+ * The entry point sits at the package root rather than inside the module:
113
+ * AgentCore runs it as a file path, and Python gives a script run that way no
114
+ * parent package, so the agent's own `from .init import app` would raise
115
+ * `ImportError: attempted relative import with no known parent package`. The
116
+ * root script imports the module absolutely instead, which resolves those
117
+ * relative imports normally.
118
+ */
119
+ export declare const addPythonCodePackageTarget: <const D extends DependencyDeclaration>(tree: Tree, options: AddPythonCodePackageTargetOptions, declaration: D & MustDeclare<typeof FS_DEPENDENCIES, D>) => void;
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */ import { joinPathFragments } from "@nx/devkit";
5
+ import { forDependencies } from "./declared-dependencies.js";
6
+ import { FS_DEPENDENCIES, FsCommands } from "./fs.js";
7
+ import { addArtifactDependencyToTargets } from "./nx.js";
8
+ import { agentCoreRuntime, TS_VERSIONS } from "./versions.js";
9
+ /**
10
+ * How an AgentCore Runtime's artifact is packaged and hosted.
11
+ *
12
+ * `agentcore` uploads a `.zip` of the built code to S3 and runs it on an
13
+ * AgentCore managed language runtime, which skips the container build, ECR
14
+ * repository and image push entirely — the fastest build and deploy cycle.
15
+ * `agentcore-ecr` builds an arm64 container image and hosts it from ECR, for
16
+ * workloads needing OS-level control (e.g. native system libraries) or an
17
+ * established container pipeline.
18
+ */ export const AGENT_CORE_INFRA = [
19
+ 'agentcore',
20
+ 'agentcore-ecr',
21
+ 'none'
22
+ ];
23
+ /** Whether the given infra option hosts on AgentCore Runtime at all. */ export const isAgentCoreHosted = (infra)=>infra === 'agentcore' || infra === 'agentcore-ecr';
24
+ /** Whether the given infra option builds and hosts a container image. */ export const isContainerHosted = (infra)=>infra === 'agentcore-ecr';
25
+ /** The AgentCore managed runtime a TypeScript component targets. */ export const agentCoreNodeRuntime = ()=>agentCoreRuntime('node');
26
+ /** The AgentCore managed runtime a Python component targets. */ export const agentCorePythonRuntime = ()=>agentCoreRuntime('python');
27
+ /**
28
+ * Dependencies a caller must declare to add a code (`.zip`) packaging target.
29
+ *
30
+ * The TypeScript package target vendors the AWS Distro for OpenTelemetry into
31
+ * the package directory, so its version is declared here (spread through
32
+ * `ownedElsewhere` by callers, since the install targets the built package
33
+ * rather than any workspace manifest).
34
+ */ export const CODE_PACKAGE_DEPENDENCIES = [
35
+ ...FS_DEPENDENCIES,
36
+ {
37
+ name: '@aws/aws-distro-opentelemetry-node-autoinstrumentation'
38
+ }
39
+ ];
40
+ /**
41
+ * Add a target assembling the deployable code package for a TypeScript
42
+ * AgentCore Runtime.
43
+ *
44
+ * The package is the rolldown bundle plus a vendored AWS Distro for
45
+ * OpenTelemetry install. AgentCore rejects a code package with no OpenTelemetry
46
+ * dependencies present (`CREATE_FAILED`: "OpenTelemetry instrumentation
47
+ * executable not found"), so ADOT must ship inside the package rather than
48
+ * being installed at runtime — the `opentelemetry-instrument` entry point
49
+ * prefix resolves it from there.
50
+ *
51
+ * The install is scoped to the package directory with `--prefix` and
52
+ * `--no-save`, so it never touches the project's own manifest. `--omit=dev`
53
+ * keeps the package to what the runtime loads. ADOT is pure JavaScript with no
54
+ * native binaries, so the package is architecture independent even though
55
+ * AgentCore only runs arm64.
56
+ */ export const addTypeScriptCodePackageTarget = (tree, options, declaration)=>{
57
+ const { project, targetName, bundleTargetName, bundleOutputDir, packageOutputDir } = options;
58
+ const fs = new FsCommands(tree, forDependencies(declaration));
59
+ const adotVersion = TS_VERSIONS['@aws/aws-distro-opentelemetry-node-autoinstrumentation'];
60
+ project.targets ??= {};
61
+ project.targets[targetName] = {
62
+ cache: true,
63
+ inputs: [
64
+ 'default'
65
+ ],
66
+ outputs: [
67
+ `{workspaceRoot}/${packageOutputDir}`
68
+ ],
69
+ executor: 'nx:run-commands',
70
+ options: {
71
+ commands: [
72
+ fs.rm(packageOutputDir),
73
+ fs.mkdir(packageOutputDir),
74
+ fs.cp(joinPathFragments(bundleOutputDir, 'index.js'), joinPathFragments(packageOutputDir, 'index.js')),
75
+ `npm install --prefix ${packageOutputDir} --no-save --no-audit --no-fund --omit=dev @aws/aws-distro-opentelemetry-node-autoinstrumentation@${adotVersion}`
76
+ ],
77
+ parallel: false
78
+ },
79
+ dependsOn: [
80
+ bundleTargetName
81
+ ]
82
+ };
83
+ addArtifactDependencyToTargets(project, targetName);
84
+ };
85
+ /**
86
+ * Add a target assembling the deployable code package for a Python AgentCore
87
+ * Runtime.
88
+ *
89
+ * The package is the arm64 dependency bundle (which already carries
90
+ * `bin/opentelemetry-instrument` from `aws-opentelemetry-distro`, satisfying
91
+ * AgentCore's requirement that OpenTelemetry be present), the project's own
92
+ * module tree, and a root entry point script.
93
+ *
94
+ * The entry point sits at the package root rather than inside the module:
95
+ * AgentCore runs it as a file path, and Python gives a script run that way no
96
+ * parent package, so the agent's own `from .init import app` would raise
97
+ * `ImportError: attempted relative import with no known parent package`. The
98
+ * root script imports the module absolutely instead, which resolves those
99
+ * relative imports normally.
100
+ */ export const addPythonCodePackageTarget = (tree, options, declaration)=>{
101
+ const { project, targetName, bundleTargetName, bundleOutputDir, packageOutputDir, sourceRoot, moduleName, entryPointPath, entryPointFileName } = options;
102
+ const fs = new FsCommands(tree, forDependencies(declaration));
103
+ project.targets ??= {};
104
+ project.targets[targetName] = {
105
+ cache: true,
106
+ inputs: [
107
+ 'production',
108
+ '^production'
109
+ ],
110
+ outputs: [
111
+ `{workspaceRoot}/${packageOutputDir}`
112
+ ],
113
+ executor: 'nx:run-commands',
114
+ options: {
115
+ commands: [
116
+ fs.rm(packageOutputDir),
117
+ fs.mkdir(packageOutputDir),
118
+ fs.cp(bundleOutputDir, packageOutputDir),
119
+ fs.cp(sourceRoot, joinPathFragments(packageOutputDir, moduleName)),
120
+ fs.cp(entryPointPath, joinPathFragments(packageOutputDir, entryPointFileName))
121
+ ],
122
+ parallel: false
123
+ },
124
+ dependsOn: [
125
+ bundleTargetName
126
+ ]
127
+ };
128
+ addArtifactDependencyToTargets(project, targetName);
129
+ };
130
+
131
+ //# sourceMappingURL=agent-core-packaging.js.map