@aws/nx-plugin 1.0.0-rc.43 → 1.0.0-rc.45
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/LICENSE-THIRD-PARTY +121 -154
- package/generators.json +6 -0
- package/package.json +4 -4
- package/src/agentcore-gateway/files/cedar/policies/README.md +9 -0
- package/src/agentcore-gateway/files/cedar/policies/permit-all.cedar +15 -0
- package/src/agentcore-gateway/generator.js +12 -5
- package/src/agentcore-gateway/generator.js.map +1 -1
- package/src/agentcore-gateway/schema.d.js.map +1 -1
- package/src/agentcore-gateway/schema.d.ts +1 -1
- package/src/agentcore-gateway/schema.json +3 -2
- package/src/connection/generator.js +1 -1
- package/src/connection/generator.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +8 -8
- package/src/mcp-server/tools/general-guidance.js +1 -1
- package/src/mcp-server/tools/general-guidance.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +6 -3
- package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +7 -7
- package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +6 -6
- package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +2 -2
- package/src/py/agent/gateway-connection/generator.js +1 -1
- package/src/py/agent/gateway-connection/generator.js.map +1 -1
- package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +4 -8
- package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +12 -12
- package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/py/rdb/__snapshots__/generator.spec.ts.snap +21 -5
- package/src/py/rdb/files/Dockerfile.create-db-user.template +4 -0
- package/src/py/rdb/files/Dockerfile.migration.template +4 -0
- package/src/sdk/ts.d.ts +2 -0
- package/src/sdk/ts.js +2 -0
- package/src/sdk/ts.js.map +1 -1
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +7 -7
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +12 -12
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +7 -3
- package/src/ts/agent/files/deploy/Dockerfile.template +5 -1
- package/src/ts/agent/gateway-connection/generator.js +1 -1
- package/src/ts/agent/gateway-connection/generator.js.map +1 -1
- package/src/ts/agent/generator.js +6 -0
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/dcr-proxy/__snapshots__/generator.spec.ts.snap +982 -0
- package/src/ts/dcr-proxy/generator.d.ts +10 -0
- package/src/ts/dcr-proxy/generator.js +98 -0
- package/src/ts/dcr-proxy/generator.js.map +1 -0
- package/src/ts/dcr-proxy/schema.d.js +6 -0
- package/src/ts/dcr-proxy/schema.d.js.map +1 -0
- package/src/ts/dcr-proxy/schema.d.ts +13 -0
- package/src/ts/dcr-proxy/schema.json +44 -0
- package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +4 -8
- package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/mcp-server/files/Dockerfile.template +5 -1
- package/src/ts/mcp-server/generator.js +1 -0
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/nx-plugin/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/nx-plugin/files/mcp-server/resources/GENERAL_GUIDANCE.md.template +1 -1
- package/src/ts/nx-plugin/files/mcp-server/utils.ts.template +1 -1
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +11 -4
- package/src/ts/rdb/files/Dockerfile.template +7 -0
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +28 -28
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +2 -2
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +1 -0
- package/src/utils/agent-core-constructs/agent-core-constructs.js +2 -0
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/agent-core-constructs/files/cdk/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.ts.template +38 -3
- package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/agentcore-gateway.ts.template +13 -3
- package/src/utils/agent-core-constructs/files/terraform/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.tf.template +22 -1
- package/src/utils/commands.js +1 -1
- package/src/utils/commands.js.map +1 -1
- package/src/utils/dcr-proxy-constructs/dcr-proxy-constructs.d.ts +38 -0
- package/src/utils/dcr-proxy-constructs/dcr-proxy-constructs.js +93 -0
- package/src/utils/dcr-proxy-constructs/dcr-proxy-constructs.js.map +1 -0
- package/src/utils/dcr-proxy-constructs/files/cdk/app/dcr-proxies/__nameKebabCase__/__nameKebabCase__.ts.template +227 -0
- package/src/utils/dcr-proxy-constructs/files/project/src/handlers/authorization-server-metadata.ts.template +39 -0
- package/src/utils/dcr-proxy-constructs/files/project/src/handlers/authorize.ts.template +26 -0
- package/src/utils/dcr-proxy-constructs/files/project/src/handlers/mcp-proxy.ts.template +89 -0
- package/src/utils/dcr-proxy-constructs/files/project/src/handlers/protected-resource-metadata.ts.template +13 -0
- package/src/utils/dcr-proxy-constructs/files/project/src/handlers/register.ts.template +70 -0
- package/src/utils/dcr-proxy-constructs/files/project/src/handlers/token.ts.template +75 -0
- package/src/utils/dcr-proxy-constructs/files/terraform/app/dcr-proxies/__nameKebabCase__/__nameKebabCase__.tf.template +410 -0
- package/src/utils/docker.d.ts +4 -3
- package/src/utils/docker.js +11 -7
- package/src/utils/docker.js.map +1 -1
- package/src/utils/files/common/scripts/src/dynamodb/start-container.ts.template +1 -3
- package/src/utils/files/common/scripts/src/rdb/shared/start-container.ts.template +1 -3
- package/src/utils/format.d.ts +1 -1
- package/src/utils/format.js +3 -2
- package/src/utils/format.js.map +1 -1
- package/src/utils/init.js +4 -0
- package/src/utils/init.js.map +1 -1
- package/src/utils/versions.d.ts +53 -51
- package/src/utils/versions.js +53 -49
- package/src/utils/versions.js.map +1 -1
|
@@ -131,7 +131,7 @@ exports[`react-website generator > TailwindCSS integration > terraform iac > sho
|
|
|
131
131
|
required_providers {
|
|
132
132
|
aws = {
|
|
133
133
|
source = "hashicorp/aws"
|
|
134
|
-
version = "6.
|
|
134
|
+
version = "6.55.0"
|
|
135
135
|
configuration_aliases = [aws.us_east_1]
|
|
136
136
|
}
|
|
137
137
|
random = {
|
|
@@ -699,7 +699,7 @@ resource "null_resource" "upload_website_files" {
|
|
|
699
699
|
provisioner "local-exec" {
|
|
700
700
|
command = <<-EOT
|
|
701
701
|
cd "$ROOT_PATH"
|
|
702
|
-
uv run --with boto3==1.43.
|
|
702
|
+
uv run --with boto3==1.43.51 python3 -c "
|
|
703
703
|
import os
|
|
704
704
|
import sys
|
|
705
705
|
import boto3
|
|
@@ -822,7 +822,7 @@ resource "null_resource" "cloudfront_invalidation" {
|
|
|
822
822
|
|
|
823
823
|
provisioner "local-exec" {
|
|
824
824
|
command = <<-EOT
|
|
825
|
-
uv run --with boto3==1.43.
|
|
825
|
+
uv run --with boto3==1.43.51 python3 -c "
|
|
826
826
|
import boto3
|
|
827
827
|
import os
|
|
828
828
|
import sys
|
|
@@ -908,7 +908,7 @@ output "waf_web_acl_arn" {
|
|
|
908
908
|
required_providers {
|
|
909
909
|
aws = {
|
|
910
910
|
source = "hashicorp/aws"
|
|
911
|
-
version = "6.
|
|
911
|
+
version = "6.55.0"
|
|
912
912
|
configuration_aliases = [aws.us_east_1]
|
|
913
913
|
}
|
|
914
914
|
}
|
|
@@ -961,7 +961,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
961
961
|
|
|
962
962
|
exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > biome.json 1`] = `
|
|
963
963
|
"{
|
|
964
|
-
"$schema": "https://biomejs.dev/schemas/2.4
|
|
964
|
+
"$schema": "https://biomejs.dev/schemas/2.5.4/schema.json",
|
|
965
965
|
"root": true,
|
|
966
966
|
"formatter": {
|
|
967
967
|
"enabled": true,
|
|
@@ -986,7 +986,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
986
986
|
"linter": {
|
|
987
987
|
"enabled": true,
|
|
988
988
|
"rules": {
|
|
989
|
-
"
|
|
989
|
+
"preset": "none",
|
|
990
990
|
"correctness": {
|
|
991
991
|
"noUndeclaredDependencies": "warn"
|
|
992
992
|
}
|
|
@@ -1119,14 +1119,14 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
1119
1119
|
"{
|
|
1120
1120
|
"name": "@proj/source",
|
|
1121
1121
|
"dependencies": {
|
|
1122
|
-
"@cloudscape-design/board-components": "3.0.
|
|
1123
|
-
"@cloudscape-design/components": "3.0.
|
|
1122
|
+
"@cloudscape-design/board-components": "3.0.205",
|
|
1123
|
+
"@cloudscape-design/components": "3.0.1330",
|
|
1124
1124
|
"@cloudscape-design/global-styles": "1.0.62",
|
|
1125
1125
|
"aws-cdk-lib": "2.261.0",
|
|
1126
|
-
"constructs": "10.
|
|
1126
|
+
"constructs": "10.7.0",
|
|
1127
1127
|
"react": "19.2.7",
|
|
1128
1128
|
"react-dom": "19.2.7",
|
|
1129
|
-
"tailwindcss": "4.3.
|
|
1129
|
+
"tailwindcss": "4.3.3"
|
|
1130
1130
|
},
|
|
1131
1131
|
"devDependencies": {
|
|
1132
1132
|
"@nx/js": "23.1.0",
|
|
@@ -1135,7 +1135,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
1135
1135
|
"@nx/vitest": "23.1.0",
|
|
1136
1136
|
"@nx/web": "23.1.0",
|
|
1137
1137
|
"@swc/helpers": "~0.5.18",
|
|
1138
|
-
"@tailwindcss/vite": "4.3.
|
|
1138
|
+
"@tailwindcss/vite": "4.3.3",
|
|
1139
1139
|
"@testing-library/dom": "10.4.0",
|
|
1140
1140
|
"@testing-library/react": "16.3.0",
|
|
1141
1141
|
"@types/node": "26.1.1",
|
|
@@ -1147,7 +1147,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
1147
1147
|
"jiti": "2.4.2",
|
|
1148
1148
|
"jsdom": "^27.1.0",
|
|
1149
1149
|
"typescript": "~6.0.3",
|
|
1150
|
-
"vite": "8.1.
|
|
1150
|
+
"vite": "8.1.5",
|
|
1151
1151
|
"vitest": "4.1.10"
|
|
1152
1152
|
},
|
|
1153
1153
|
"type": "module"
|
|
@@ -2674,7 +2674,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
2674
2674
|
|
|
2675
2675
|
exports[`react-website generator > Tanstack router integration > should generate website with router correctly > biome.json 1`] = `
|
|
2676
2676
|
"{
|
|
2677
|
-
"$schema": "https://biomejs.dev/schemas/2.4
|
|
2677
|
+
"$schema": "https://biomejs.dev/schemas/2.5.4/schema.json",
|
|
2678
2678
|
"root": true,
|
|
2679
2679
|
"formatter": {
|
|
2680
2680
|
"enabled": true,
|
|
@@ -2699,7 +2699,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
2699
2699
|
"linter": {
|
|
2700
2700
|
"enabled": true,
|
|
2701
2701
|
"rules": {
|
|
2702
|
-
"
|
|
2702
|
+
"preset": "none",
|
|
2703
2703
|
"correctness": {
|
|
2704
2704
|
"noUndeclaredDependencies": "warn"
|
|
2705
2705
|
}
|
|
@@ -2832,15 +2832,15 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
2832
2832
|
"{
|
|
2833
2833
|
"name": "@proj/source",
|
|
2834
2834
|
"dependencies": {
|
|
2835
|
-
"@cloudscape-design/board-components": "3.0.
|
|
2836
|
-
"@cloudscape-design/components": "3.0.
|
|
2835
|
+
"@cloudscape-design/board-components": "3.0.205",
|
|
2836
|
+
"@cloudscape-design/components": "3.0.1330",
|
|
2837
2837
|
"@cloudscape-design/global-styles": "1.0.62",
|
|
2838
|
-
"@tanstack/react-router": "1.170.
|
|
2838
|
+
"@tanstack/react-router": "1.170.18",
|
|
2839
2839
|
"aws-cdk-lib": "2.261.0",
|
|
2840
|
-
"constructs": "10.
|
|
2840
|
+
"constructs": "10.7.0",
|
|
2841
2841
|
"react": "19.2.7",
|
|
2842
2842
|
"react-dom": "19.2.7",
|
|
2843
|
-
"tailwindcss": "4.3.
|
|
2843
|
+
"tailwindcss": "4.3.3"
|
|
2844
2844
|
},
|
|
2845
2845
|
"devDependencies": {
|
|
2846
2846
|
"@nx/js": "23.1.0",
|
|
@@ -2849,9 +2849,9 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
2849
2849
|
"@nx/vitest": "23.1.0",
|
|
2850
2850
|
"@nx/web": "23.1.0",
|
|
2851
2851
|
"@swc/helpers": "~0.5.18",
|
|
2852
|
-
"@tailwindcss/vite": "4.3.
|
|
2853
|
-
"@tanstack/router-generator": "1.167.
|
|
2854
|
-
"@tanstack/router-plugin": "1.168.
|
|
2852
|
+
"@tailwindcss/vite": "4.3.3",
|
|
2853
|
+
"@tanstack/router-generator": "1.167.21",
|
|
2854
|
+
"@tanstack/router-plugin": "1.168.22",
|
|
2855
2855
|
"@tanstack/router-utils": "1.162.2",
|
|
2856
2856
|
"@tanstack/virtual-file-routes": "1.162.0",
|
|
2857
2857
|
"@testing-library/dom": "10.4.0",
|
|
@@ -2865,7 +2865,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
2865
2865
|
"jiti": "2.4.2",
|
|
2866
2866
|
"jsdom": "^27.1.0",
|
|
2867
2867
|
"typescript": "~6.0.3",
|
|
2868
|
-
"vite": "8.1.
|
|
2868
|
+
"vite": "8.1.5",
|
|
2869
2869
|
"vitest": "4.1.10"
|
|
2870
2870
|
},
|
|
2871
2871
|
"type": "module"
|
|
@@ -5367,15 +5367,15 @@ root &&
|
|
|
5367
5367
|
|
|
5368
5368
|
exports[`react-website generator > should handle npm scope prefix correctly > scoped-dependencies 1`] = `
|
|
5369
5369
|
{
|
|
5370
|
-
"@cloudscape-design/board-components": "3.0.
|
|
5371
|
-
"@cloudscape-design/components": "3.0.
|
|
5370
|
+
"@cloudscape-design/board-components": "3.0.205",
|
|
5371
|
+
"@cloudscape-design/components": "3.0.1330",
|
|
5372
5372
|
"@cloudscape-design/global-styles": "1.0.62",
|
|
5373
|
-
"@tanstack/react-router": "1.170.
|
|
5373
|
+
"@tanstack/react-router": "1.170.18",
|
|
5374
5374
|
"aws-cdk-lib": "2.261.0",
|
|
5375
|
-
"constructs": "10.
|
|
5375
|
+
"constructs": "10.7.0",
|
|
5376
5376
|
"react": "19.2.7",
|
|
5377
5377
|
"react-dom": "19.2.7",
|
|
5378
|
-
"tailwindcss": "4.3.
|
|
5378
|
+
"tailwindcss": "4.3.3",
|
|
5379
5379
|
}
|
|
5380
5380
|
`;
|
|
5381
5381
|
|
|
@@ -6,7 +6,7 @@ exports[`cognito-auth generator terraform iac > should generate terraform files
|
|
|
6
6
|
required_providers {
|
|
7
7
|
aws = {
|
|
8
8
|
source = "hashicorp/aws"
|
|
9
|
-
version = "6.
|
|
9
|
+
version = "6.55.0"
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -63,7 +63,7 @@ resource "null_resource" "add_callback_url" {
|
|
|
63
63
|
|
|
64
64
|
provisioner "local-exec" {
|
|
65
65
|
command = <<-EOT
|
|
66
|
-
uv run --with boto3==1.43.
|
|
66
|
+
uv run --with boto3==1.43.51 python -c "
|
|
67
67
|
import boto3
|
|
68
68
|
import os
|
|
69
69
|
import sys
|
|
@@ -53,6 +53,7 @@ export interface AddAgentCoreGatewayInfraProps {
|
|
|
53
53
|
projectName: string;
|
|
54
54
|
projectDirectory: string;
|
|
55
55
|
cedarPolicy: boolean;
|
|
56
|
+
auth: AgentCoreAuth;
|
|
56
57
|
}
|
|
57
58
|
export declare const addAgentCoreGatewayInfra: (tree: Tree, options: AddAgentCoreGatewayInfraProps & IACProvider) => Promise<void>;
|
|
58
59
|
export {};
|
|
@@ -107,6 +107,7 @@ const addAgentCoreGatewayCDKInfra = async (tree, options)=>{
|
|
|
107
107
|
nameKebabCase: options.gatewayNameKebabCase,
|
|
108
108
|
projectDirectory: options.projectDirectory,
|
|
109
109
|
cedarPolicy: options.cedarPolicy,
|
|
110
|
+
auth: options.auth,
|
|
110
111
|
...esmVars(tree)
|
|
111
112
|
}, {
|
|
112
113
|
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
@@ -126,6 +127,7 @@ const addAgentCoreGatewayTerraformInfra = (tree, options)=>{
|
|
|
126
127
|
nameKebabCase: options.gatewayNameKebabCase,
|
|
127
128
|
projectDirectory: options.projectDirectory,
|
|
128
129
|
cedarPolicy: options.cedarPolicy,
|
|
130
|
+
auth: options.auth,
|
|
129
131
|
boto3Version: PY_VERSIONS.boto3,
|
|
130
132
|
httpxVersion: PY_VERSIONS.httpx,
|
|
131
133
|
mcpVersion: PY_VERSIONS.mcp,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/agent-core-constructs/agent-core-constructs.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type ProjectConfiguration,\n type Tree,\n updateJson,\n} from '@nx/devkit';\nimport { addStarExport } from '../ast';\nimport type { Containers } from '../containers';\nimport type { Iac } from '../iac';\nimport { esmVars } from '../module-format';\nimport { addDependencyToTargetIfNotPresent } from '../nx';\nimport {\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n SHARED_TERRAFORM_DIR,\n} from '../shared-constructs-constants';\nimport { PY_VERSIONS, terraformProviderVersions } from '../versions';\n\ntype IACProvider = { iac: Iac };\n\nexport type AgentCoreAuth = 'iam' | 'cognito';\n\nexport interface AddAgentCoreInfraProps {\n nameClassName: string;\n nameKebabCase: string;\n projectName: string;\n dockerImageTag: string;\n dockerOutputDir: string;\n appDirectory: string;\n serverProtocol: 'mcp' | 'http' | 'a2a';\n auth: AgentCoreAuth;\n containers: Containers;\n}\n\nconst addAgentCoreInfra = async (\n tree: Tree,\n options: AddAgentCoreInfraProps & { iac: Iac },\n) => {\n switch (options.iac) {\n case 'cdk':\n await addAgentCoreCDKInfra(tree, options);\n break;\n case 'terraform':\n addAgentCoreTerraformInfra(tree, options);\n break;\n }\n\n // Update shared constructs/terraform project configuration to depend on this project\n updateJson(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n options.iac === 'cdk' ? SHARED_CONSTRUCTS_DIR : SHARED_TERRAFORM_DIR,\n 'project.json',\n ),\n (config: ProjectConfiguration) => {\n addDependencyToTargetIfNotPresent(\n config,\n 'build',\n `${options.projectName}:build`,\n );\n return config;\n },\n );\n};\n\nconst addAgentCoreCDKInfra = async (\n tree: Tree,\n options: AddAgentCoreInfraProps,\n) => {\n // Generate app specific CDK construct\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'cdk', 'app', 'agent-core'),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n options.appDirectory,\n ),\n { ...options, ...esmVars(tree) },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n // Export app specific CDK construct\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n options.appDirectory,\n 'index.ts',\n ),\n `./${options.nameKebabCase}/${options.nameKebabCase}.js`,\n );\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'index.ts',\n ),\n `./${options.appDirectory}/index.js`,\n );\n};\n\nconst addAgentCoreTerraformInfra = (\n tree: Tree,\n options: AddAgentCoreInfraProps,\n) => {\n // Add the AgentCore shared module\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'terraform',\n 'core',\n 'agent-core',\n ),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_TERRAFORM_DIR,\n 'src',\n 'core',\n 'agent-core',\n ),\n {\n containers: options.containers,\n boto3Version: PY_VERSIONS.boto3,\n ...terraformProviderVersions(),\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n // Generate app specific agent core configuration\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'terraform',\n 'app',\n 'agent-core',\n ),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_TERRAFORM_DIR,\n 'src',\n 'app',\n options.appDirectory,\n ),\n options,\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n};\n\nexport interface AddMcpServerInfraProps {\n mcpServerNameClassName: string;\n mcpServerNameKebabCase: string;\n projectName: string;\n dockerImageTag: string;\n dockerOutputDir: string;\n auth: AgentCoreAuth;\n containers: Containers;\n}\n\n/**\n * Add an MCP server CDK construct\n */\nexport const addMcpServerInfra = async (\n tree: Tree,\n options: AddMcpServerInfraProps & IACProvider,\n) => {\n await addAgentCoreInfra(tree, {\n nameClassName: options.mcpServerNameClassName,\n nameKebabCase: options.mcpServerNameKebabCase,\n dockerImageTag: options.dockerImageTag,\n dockerOutputDir: options.dockerOutputDir,\n projectName: options.projectName,\n appDirectory: 'mcp-servers',\n serverProtocol: 'mcp',\n iac: options.iac,\n auth: options.auth,\n containers: options.containers,\n });\n};\n\nexport interface AddAgentInfraProps {\n agentNameClassName: string;\n agentNameKebabCase: string;\n projectName: string;\n dockerImageTag: string;\n dockerOutputDir: string;\n auth: AgentCoreAuth;\n serverProtocol?: 'http' | 'a2a';\n containers: Containers;\n}\n\n/**\n * Add an agent CDK construct\n */\nexport const addAgentInfra = async (\n tree: Tree,\n options: AddAgentInfraProps & IACProvider,\n) => {\n await addAgentCoreInfra(tree, {\n nameClassName: options.agentNameClassName,\n nameKebabCase: options.agentNameKebabCase,\n projectName: options.projectName,\n dockerImageTag: options.dockerImageTag,\n dockerOutputDir: options.dockerOutputDir,\n appDirectory: 'agents',\n serverProtocol: options.serverProtocol ?? 'http',\n iac: options.iac,\n auth: options.auth,\n containers: options.containers,\n });\n};\n\nexport interface AddAgentCoreGatewayInfraProps {\n gatewayNameClassName: string;\n gatewayNameKebabCase: string;\n projectName: string;\n projectDirectory: string;\n cedarPolicy: boolean;\n}\n\nexport const addAgentCoreGatewayInfra = async (\n tree: Tree,\n options: AddAgentCoreGatewayInfraProps & IACProvider,\n) => {\n switch (options.iac) {\n case 'cdk':\n await addAgentCoreGatewayCDKInfra(tree, options);\n break;\n case 'terraform':\n addAgentCoreGatewayTerraformInfra(tree, options);\n break;\n }\n\n updateJson(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n options.iac === 'cdk' ? SHARED_CONSTRUCTS_DIR : SHARED_TERRAFORM_DIR,\n 'project.json',\n ),\n (config: ProjectConfiguration) => {\n addDependencyToTargetIfNotPresent(\n config,\n 'build',\n `${options.projectName}:build`,\n );\n return config;\n },\n );\n};\n\nconst addAgentCoreGatewayCDKInfra = async (\n tree: Tree,\n options: AddAgentCoreGatewayInfraProps,\n) => {\n // Generic gateway construct (readiness probe, policy engine, Cedar policy\n // loading) shared by all gateways\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'cdk',\n 'core',\n 'agentcore-gateway',\n ),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'core',\n 'agentcore-gateway',\n ),\n { ...esmVars(tree) },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'cdk',\n 'app',\n 'agentcore-gateway',\n ),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'gateways',\n ),\n {\n nameClassName: options.gatewayNameClassName,\n nameKebabCase: options.gatewayNameKebabCase,\n projectDirectory: options.projectDirectory,\n cedarPolicy: options.cedarPolicy,\n ...esmVars(tree),\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'core',\n 'index.ts',\n ),\n './agentcore-gateway/agentcore-gateway.js',\n );\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'gateways',\n 'index.ts',\n ),\n `./${options.gatewayNameKebabCase}/${options.gatewayNameKebabCase}.js`,\n );\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'index.ts',\n ),\n './gateways/index.js',\n );\n};\n\nconst addAgentCoreGatewayTerraformInfra = (\n tree: Tree,\n options: AddAgentCoreGatewayInfraProps,\n) => {\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'terraform',\n 'core',\n 'agentcore-gateway',\n ),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_TERRAFORM_DIR,\n 'src',\n 'core',\n 'agentcore-gateway',\n ),\n { ...terraformProviderVersions() },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'terraform',\n 'app',\n 'agentcore-gateway',\n ),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_TERRAFORM_DIR,\n 'src',\n 'app',\n 'gateways',\n ),\n {\n nameClassName: options.gatewayNameClassName,\n nameKebabCase: options.gatewayNameKebabCase,\n projectDirectory: options.projectDirectory,\n cedarPolicy: options.cedarPolicy,\n boto3Version: PY_VERSIONS.boto3,\n httpxVersion: PY_VERSIONS.httpx,\n mcpVersion: PY_VERSIONS.mcp,\n ...terraformProviderVersions(),\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n // The Cedar render script is only needed when policies are enabled\n if (!options.cedarPolicy) {\n const renderScript = joinPathFragments(\n PACKAGES_DIR,\n SHARED_TERRAFORM_DIR,\n 'src',\n 'app',\n 'gateways',\n options.gatewayNameKebabCase,\n 'render-cedar.cjs',\n );\n if (tree.exists(renderScript)) {\n tree.delete(renderScript);\n }\n }\n};\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateJson","addStarExport","esmVars","addDependencyToTargetIfNotPresent","PACKAGES_DIR","SHARED_CONSTRUCTS_DIR","SHARED_TERRAFORM_DIR","PY_VERSIONS","terraformProviderVersions","addAgentCoreInfra","tree","options","iac","addAgentCoreCDKInfra","addAgentCoreTerraformInfra","config","projectName","dirname","appDirectory","overwriteStrategy","KeepExisting","nameKebabCase","containers","boto3Version","boto3","addMcpServerInfra","nameClassName","mcpServerNameClassName","mcpServerNameKebabCase","dockerImageTag","dockerOutputDir","serverProtocol","auth","addAgentInfra","agentNameClassName","agentNameKebabCase","addAgentCoreGatewayInfra","addAgentCoreGatewayCDKInfra","addAgentCoreGatewayTerraformInfra","gatewayNameClassName","gatewayNameKebabCase","projectDirectory","cedarPolicy","httpxVersion","httpx","mcpVersion","mcp","renderScript","exists","delete"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAGjBC,UAAU,QACL,aAAa;AACpB,SAASC,aAAa,QAAQ,YAAS;AAGvC,SAASC,OAAO,QAAQ,sBAAmB;AAC3C,SAASC,iCAAiC,QAAQ,WAAQ;AAC1D,SACEC,YAAY,EACZC,qBAAqB,EACrBC,oBAAoB,QACf,oCAAiC;AACxC,SAASC,WAAW,EAAEC,yBAAyB,QAAQ,iBAAc;AAkBrE,MAAMC,oBAAoB,OACxBC,MACAC;IAEA,OAAQA,QAAQC,GAAG;QACjB,KAAK;YACH,MAAMC,qBAAqBH,MAAMC;YACjC;QACF,KAAK;YACHG,2BAA2BJ,MAAMC;YACjC;IACJ;IAEA,qFAAqF;IACrFX,WACEU,MACAZ,kBACEM,cACAO,QAAQC,GAAG,KAAK,QAAQP,wBAAwBC,sBAChD,iBAEF,CAACS;QACCZ,kCACEY,QACA,SACA,GA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,GACA;QACEW,mBAAmBpB,kBAAkBqB,YAAY;IACnD;IAGF,mEAAmE;IACnE,IAAI,CAACT,QAAQ+B,WAAW,EAAE;QACxB,MAAMK,eAAejD,kBACnBM,cACAE,sBACA,OACA,OACA,YACAK,QAAQ6B,oBAAoB,EAC5B;QAEF,IAAI9B,KAAKsC,MAAM,CAACD,eAAe;YAC7BrC,KAAKuC,MAAM,CAACF;QACd;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/agent-core-constructs/agent-core-constructs.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type ProjectConfiguration,\n type Tree,\n updateJson,\n} from '@nx/devkit';\nimport { addStarExport } from '../ast';\nimport type { Containers } from '../containers';\nimport type { Iac } from '../iac';\nimport { esmVars } from '../module-format';\nimport { addDependencyToTargetIfNotPresent } from '../nx';\nimport {\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n SHARED_TERRAFORM_DIR,\n} from '../shared-constructs-constants';\nimport { PY_VERSIONS, terraformProviderVersions } from '../versions';\n\ntype IACProvider = { iac: Iac };\n\nexport type AgentCoreAuth = 'iam' | 'cognito';\n\nexport interface AddAgentCoreInfraProps {\n nameClassName: string;\n nameKebabCase: string;\n projectName: string;\n dockerImageTag: string;\n dockerOutputDir: string;\n appDirectory: string;\n serverProtocol: 'mcp' | 'http' | 'a2a';\n auth: AgentCoreAuth;\n containers: Containers;\n}\n\nconst addAgentCoreInfra = async (\n tree: Tree,\n options: AddAgentCoreInfraProps & { iac: Iac },\n) => {\n switch (options.iac) {\n case 'cdk':\n await addAgentCoreCDKInfra(tree, options);\n break;\n case 'terraform':\n addAgentCoreTerraformInfra(tree, options);\n break;\n }\n\n // Update shared constructs/terraform project configuration to depend on this project\n updateJson(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n options.iac === 'cdk' ? SHARED_CONSTRUCTS_DIR : SHARED_TERRAFORM_DIR,\n 'project.json',\n ),\n (config: ProjectConfiguration) => {\n addDependencyToTargetIfNotPresent(\n config,\n 'build',\n `${options.projectName}:build`,\n );\n return config;\n },\n );\n};\n\nconst addAgentCoreCDKInfra = async (\n tree: Tree,\n options: AddAgentCoreInfraProps,\n) => {\n // Generate app specific CDK construct\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'cdk', 'app', 'agent-core'),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n options.appDirectory,\n ),\n { ...options, ...esmVars(tree) },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n // Export app specific CDK construct\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n options.appDirectory,\n 'index.ts',\n ),\n `./${options.nameKebabCase}/${options.nameKebabCase}.js`,\n );\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'index.ts',\n ),\n `./${options.appDirectory}/index.js`,\n );\n};\n\nconst addAgentCoreTerraformInfra = (\n tree: Tree,\n options: AddAgentCoreInfraProps,\n) => {\n // Add the AgentCore shared module\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'terraform',\n 'core',\n 'agent-core',\n ),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_TERRAFORM_DIR,\n 'src',\n 'core',\n 'agent-core',\n ),\n {\n containers: options.containers,\n boto3Version: PY_VERSIONS.boto3,\n ...terraformProviderVersions(),\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n // Generate app specific agent core configuration\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'terraform',\n 'app',\n 'agent-core',\n ),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_TERRAFORM_DIR,\n 'src',\n 'app',\n options.appDirectory,\n ),\n options,\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n};\n\nexport interface AddMcpServerInfraProps {\n mcpServerNameClassName: string;\n mcpServerNameKebabCase: string;\n projectName: string;\n dockerImageTag: string;\n dockerOutputDir: string;\n auth: AgentCoreAuth;\n containers: Containers;\n}\n\n/**\n * Add an MCP server CDK construct\n */\nexport const addMcpServerInfra = async (\n tree: Tree,\n options: AddMcpServerInfraProps & IACProvider,\n) => {\n await addAgentCoreInfra(tree, {\n nameClassName: options.mcpServerNameClassName,\n nameKebabCase: options.mcpServerNameKebabCase,\n dockerImageTag: options.dockerImageTag,\n dockerOutputDir: options.dockerOutputDir,\n projectName: options.projectName,\n appDirectory: 'mcp-servers',\n serverProtocol: 'mcp',\n iac: options.iac,\n auth: options.auth,\n containers: options.containers,\n });\n};\n\nexport interface AddAgentInfraProps {\n agentNameClassName: string;\n agentNameKebabCase: string;\n projectName: string;\n dockerImageTag: string;\n dockerOutputDir: string;\n auth: AgentCoreAuth;\n serverProtocol?: 'http' | 'a2a';\n containers: Containers;\n}\n\n/**\n * Add an agent CDK construct\n */\nexport const addAgentInfra = async (\n tree: Tree,\n options: AddAgentInfraProps & IACProvider,\n) => {\n await addAgentCoreInfra(tree, {\n nameClassName: options.agentNameClassName,\n nameKebabCase: options.agentNameKebabCase,\n projectName: options.projectName,\n dockerImageTag: options.dockerImageTag,\n dockerOutputDir: options.dockerOutputDir,\n appDirectory: 'agents',\n serverProtocol: options.serverProtocol ?? 'http',\n iac: options.iac,\n auth: options.auth,\n containers: options.containers,\n });\n};\n\nexport interface AddAgentCoreGatewayInfraProps {\n gatewayNameClassName: string;\n gatewayNameKebabCase: string;\n projectName: string;\n projectDirectory: string;\n cedarPolicy: boolean;\n auth: AgentCoreAuth;\n}\n\nexport const addAgentCoreGatewayInfra = async (\n tree: Tree,\n options: AddAgentCoreGatewayInfraProps & IACProvider,\n) => {\n switch (options.iac) {\n case 'cdk':\n await addAgentCoreGatewayCDKInfra(tree, options);\n break;\n case 'terraform':\n addAgentCoreGatewayTerraformInfra(tree, options);\n break;\n }\n\n updateJson(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n options.iac === 'cdk' ? SHARED_CONSTRUCTS_DIR : SHARED_TERRAFORM_DIR,\n 'project.json',\n ),\n (config: ProjectConfiguration) => {\n addDependencyToTargetIfNotPresent(\n config,\n 'build',\n `${options.projectName}:build`,\n );\n return config;\n },\n );\n};\n\nconst addAgentCoreGatewayCDKInfra = async (\n tree: Tree,\n options: AddAgentCoreGatewayInfraProps,\n) => {\n // Generic gateway construct (readiness probe, policy engine, Cedar policy\n // loading) shared by all gateways\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'cdk',\n 'core',\n 'agentcore-gateway',\n ),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'core',\n 'agentcore-gateway',\n ),\n { ...esmVars(tree) },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'cdk',\n 'app',\n 'agentcore-gateway',\n ),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'gateways',\n ),\n {\n nameClassName: options.gatewayNameClassName,\n nameKebabCase: options.gatewayNameKebabCase,\n projectDirectory: options.projectDirectory,\n cedarPolicy: options.cedarPolicy,\n auth: options.auth,\n ...esmVars(tree),\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'core',\n 'index.ts',\n ),\n './agentcore-gateway/agentcore-gateway.js',\n );\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'gateways',\n 'index.ts',\n ),\n `./${options.gatewayNameKebabCase}/${options.gatewayNameKebabCase}.js`,\n );\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'index.ts',\n ),\n './gateways/index.js',\n );\n};\n\nconst addAgentCoreGatewayTerraformInfra = (\n tree: Tree,\n options: AddAgentCoreGatewayInfraProps,\n) => {\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'terraform',\n 'core',\n 'agentcore-gateway',\n ),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_TERRAFORM_DIR,\n 'src',\n 'core',\n 'agentcore-gateway',\n ),\n { ...terraformProviderVersions() },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'terraform',\n 'app',\n 'agentcore-gateway',\n ),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_TERRAFORM_DIR,\n 'src',\n 'app',\n 'gateways',\n ),\n {\n nameClassName: options.gatewayNameClassName,\n nameKebabCase: options.gatewayNameKebabCase,\n projectDirectory: options.projectDirectory,\n cedarPolicy: options.cedarPolicy,\n auth: options.auth,\n boto3Version: PY_VERSIONS.boto3,\n httpxVersion: PY_VERSIONS.httpx,\n mcpVersion: PY_VERSIONS.mcp,\n ...terraformProviderVersions(),\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n // The Cedar render script is only needed when policies are enabled\n if (!options.cedarPolicy) {\n const renderScript = joinPathFragments(\n PACKAGES_DIR,\n SHARED_TERRAFORM_DIR,\n 'src',\n 'app',\n 'gateways',\n options.gatewayNameKebabCase,\n 'render-cedar.cjs',\n );\n if (tree.exists(renderScript)) {\n tree.delete(renderScript);\n }\n }\n};\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateJson","addStarExport","esmVars","addDependencyToTargetIfNotPresent","PACKAGES_DIR","SHARED_CONSTRUCTS_DIR","SHARED_TERRAFORM_DIR","PY_VERSIONS","terraformProviderVersions","addAgentCoreInfra","tree","options","iac","addAgentCoreCDKInfra","addAgentCoreTerraformInfra","config","projectName","dirname","appDirectory","overwriteStrategy","KeepExisting","nameKebabCase","containers","boto3Version","boto3","addMcpServerInfra","nameClassName","mcpServerNameClassName","mcpServerNameKebabCase","dockerImageTag","dockerOutputDir","serverProtocol","auth","addAgentInfra","agentNameClassName","agentNameKebabCase","addAgentCoreGatewayInfra","addAgentCoreGatewayCDKInfra","addAgentCoreGatewayTerraformInfra","gatewayNameClassName","gatewayNameKebabCase","projectDirectory","cedarPolicy","httpxVersion","httpx","mcpVersion","mcp","renderScript","exists","delete"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAGjBC,UAAU,QACL,aAAa;AACpB,SAASC,aAAa,QAAQ,YAAS;AAGvC,SAASC,OAAO,QAAQ,sBAAmB;AAC3C,SAASC,iCAAiC,QAAQ,WAAQ;AAC1D,SACEC,YAAY,EACZC,qBAAqB,EACrBC,oBAAoB,QACf,oCAAiC;AACxC,SAASC,WAAW,EAAEC,yBAAyB,QAAQ,iBAAc;AAkBrE,MAAMC,oBAAoB,OACxBC,MACAC;IAEA,OAAQA,QAAQC,GAAG;QACjB,KAAK;YACH,MAAMC,qBAAqBH,MAAMC;YACjC;QACF,KAAK;YACHG,2BAA2BJ,MAAMC;YACjC;IACJ;IAEA,qFAAqF;IACrFX,WACEU,MACAZ,kBACEM,cACAO,QAAQC,GAAG,KAAK,QAAQP,wBAAwBC,sBAChD,iBAEF,CAACS;QACCZ,kCACEY,QACA,SACA,GAAGJ,QAAQK,WAAW,CAAC,MAAM,CAAC;QAEhC,OAAOD;IACT;AAEJ;AAEA,MAAMF,uBAAuB,OAC3BH,MACAC;IAEA,sCAAsC;IACtCd,cACEa,MACAZ,kBAAkB,YAAY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AAW,EAAE;QACxB,MAAMK,eAAejD,kBACnBM,cACAE,sBACA,OACA,OACA,YACAK,QAAQ6B,oBAAoB,EAC5B;QAEF,IAAI9B,KAAKsC,MAAM,CAACD,eAAe;YAC7BrC,KAAKuC,MAAM,CAACF;QACd;IACF;AACF"}
|
|
@@ -3,6 +3,10 @@ import { Construct } from 'constructs';
|
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import * as url from 'node:url';
|
|
5
5
|
<%_ } _%>
|
|
6
|
+
<%_ if (auth === 'cognito') { _%>
|
|
7
|
+
import { GatewayAuthorizer } from 'aws-cdk-lib/aws-bedrockagentcore';
|
|
8
|
+
import { IUserPool, IUserPoolClient } from 'aws-cdk-lib/aws-cognito';
|
|
9
|
+
<%_ } _%>
|
|
6
10
|
import {
|
|
7
11
|
AgentCoreGateway,
|
|
8
12
|
AgentCoreGatewayProps,
|
|
@@ -12,14 +16,28 @@ import { RuntimeConfig } from '../../../core/runtime-config<% if (esm) { %>.js<%
|
|
|
12
16
|
import { findWorkspaceRoot } from '../../../core/workspace<% if (esm) { %>.js<% } %>';
|
|
13
17
|
<%_ } _%>
|
|
14
18
|
|
|
15
|
-
<%_ if (
|
|
19
|
+
<%_ if (auth === 'cognito') { _%>
|
|
20
|
+
export type <%- nameClassName %>Props = Omit<
|
|
21
|
+
AgentCoreGatewayProps,
|
|
22
|
+
<%_ if (cedarPolicy) { _%>'cedarPolicyPath' | <%_ } _%>'authorizer'
|
|
23
|
+
> & {
|
|
24
|
+
/**
|
|
25
|
+
* Identity details for Cognito authentication. Callers authenticate with a
|
|
26
|
+
* JWT bearer token issued by this user pool.
|
|
27
|
+
*/
|
|
28
|
+
identity: {
|
|
29
|
+
userPool: IUserPool;
|
|
30
|
+
userPoolClient: IUserPoolClient;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
<%_ } else if (cedarPolicy) { _%>
|
|
16
34
|
export type <%- nameClassName %>Props = Omit<AgentCoreGatewayProps, 'cedarPolicyPath'>;
|
|
17
35
|
<%_ } else { _%>
|
|
18
36
|
export type <%- nameClassName %>Props = AgentCoreGatewayProps;
|
|
19
37
|
<%_ } _%>
|
|
20
38
|
|
|
21
39
|
/**
|
|
22
|
-
* AgentCore Gateway wired for MCP protocol with IAM inbound auth.
|
|
40
|
+
* AgentCore Gateway wired for MCP protocol with <%- auth === 'cognito' ? 'Cognito (JWT)' : 'IAM' %> inbound auth.
|
|
23
41
|
<%_ if (cedarPolicy) { _%>
|
|
24
42
|
*
|
|
25
43
|
* Cedar policies are loaded from the gateway project's policies/ directory
|
|
@@ -30,7 +48,23 @@ export class <%- nameClassName %> extends AgentCoreGateway {
|
|
|
30
48
|
/** Default Gateway target name when added to another Gateway. */
|
|
31
49
|
public readonly gatewayName = '<%- nameKebabCase %>';
|
|
32
50
|
|
|
33
|
-
constructor(scope: Construct, id: string, props
|
|
51
|
+
constructor(scope: Construct, id: string, props<%_ if (auth !== 'cognito') { _%>?<%_ } _%>: <%- nameClassName %>Props) {
|
|
52
|
+
<%_ if (auth === 'cognito') { _%>
|
|
53
|
+
const { identity, ...restProps } = props;
|
|
54
|
+
super(scope, id, {
|
|
55
|
+
<%_ if (cedarPolicy) { _%>
|
|
56
|
+
cedarPolicyPath: path.join(
|
|
57
|
+
findWorkspaceRoot(url.fileURLToPath(new URL(<% if (esm) { %>import.meta.url<% } else { %>require('url').pathToFileURL(__filename).href<% } %>))),
|
|
58
|
+
'<%- projectDirectory %>/policies',
|
|
59
|
+
),
|
|
60
|
+
<%_ } _%>
|
|
61
|
+
authorizer: GatewayAuthorizer.usingCognito({
|
|
62
|
+
userPool: identity.userPool,
|
|
63
|
+
allowedClients: [identity.userPoolClient],
|
|
64
|
+
}),
|
|
65
|
+
...restProps,
|
|
66
|
+
});
|
|
67
|
+
<%_ } else { _%>
|
|
34
68
|
super(scope, id, {
|
|
35
69
|
<%_ if (cedarPolicy) { _%>
|
|
36
70
|
cedarPolicyPath: path.join(
|
|
@@ -40,6 +74,7 @@ export class <%- nameClassName %> extends AgentCoreGateway {
|
|
|
40
74
|
<%_ } _%>
|
|
41
75
|
...props,
|
|
42
76
|
});
|
|
77
|
+
<%_ } _%>
|
|
43
78
|
|
|
44
79
|
const rc = RuntimeConfig.ensure(this);
|
|
45
80
|
rc.set('agentcore', 'gateways', {
|
|
@@ -34,11 +34,20 @@ export interface AgentCoreGatewayProps {
|
|
|
34
34
|
* @default true
|
|
35
35
|
*/
|
|
36
36
|
readonly enableWaf?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Inbound authorizer for the gateway. Defaults to IAM (SigV4) authentication;
|
|
39
|
+
* pass `GatewayAuthorizer.usingCognito(...)` or `usingCustomJwt(...)` to
|
|
40
|
+
* authenticate callers with JWT bearer tokens instead.
|
|
41
|
+
*
|
|
42
|
+
* @default GatewayAuthorizer.usingAwsIam()
|
|
43
|
+
*/
|
|
44
|
+
readonly authorizer?: agentcore.IGatewayAuthorizerConfig;
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
/**
|
|
40
|
-
* AgentCore Gateway wired for MCP protocol
|
|
41
|
-
*
|
|
48
|
+
* AgentCore Gateway wired for MCP protocol, exposing attached MCP servers'
|
|
49
|
+
* tools under `<targetName>___<toolName>` names. Inbound auth defaults to IAM
|
|
50
|
+
* (SigV4); pass an `authorizer` to use Cognito/JWT instead.
|
|
42
51
|
*/
|
|
43
52
|
export class AgentCoreGateway extends Construct implements iam.IGrantable {
|
|
44
53
|
public readonly gateway: agentcore.Gateway;
|
|
@@ -60,7 +69,8 @@ export class AgentCoreGateway extends Construct implements iam.IGrantable {
|
|
|
60
69
|
searchType: agentcore.McpGatewaySearchType.SEMANTIC,
|
|
61
70
|
supportedVersions: [agentcore.MCPProtocolVersion.MCP_2025_03_26],
|
|
62
71
|
}),
|
|
63
|
-
authorizerConfiguration:
|
|
72
|
+
authorizerConfiguration:
|
|
73
|
+
props?.authorizer ?? agentcore.GatewayAuthorizer.usingAwsIam(),
|
|
64
74
|
});
|
|
65
75
|
|
|
66
76
|
if (props?.cedarPolicyPath) {
|
|
@@ -40,6 +40,18 @@ variable "enable_waf" {
|
|
|
40
40
|
type = bool
|
|
41
41
|
default = true
|
|
42
42
|
}
|
|
43
|
+
<%_ if (auth === 'cognito') { _%>
|
|
44
|
+
|
|
45
|
+
variable "user_pool_id" {
|
|
46
|
+
description = "ID of the Cognito user pool used to authenticate inbound requests to the gateway."
|
|
47
|
+
type = string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
variable "user_pool_client_ids" {
|
|
51
|
+
description = "IDs of the Cognito user pool clients allowed to authenticate inbound requests to the gateway."
|
|
52
|
+
type = list(string)
|
|
53
|
+
}
|
|
54
|
+
<%_ } _%>
|
|
43
55
|
<%_ if (cedarPolicy) { _%>
|
|
44
56
|
|
|
45
57
|
variable "policy_dependencies" {
|
|
@@ -161,7 +173,16 @@ resource "aws_bedrockagentcore_gateway" "this" {
|
|
|
161
173
|
}
|
|
162
174
|
}
|
|
163
175
|
|
|
164
|
-
authorizer_type = "AWS_IAM"
|
|
176
|
+
authorizer_type = "<%- auth === 'cognito' ? 'CUSTOM_JWT' : 'AWS_IAM' %>"
|
|
177
|
+
<%_ if (auth === 'cognito') { _%>
|
|
178
|
+
|
|
179
|
+
authorizer_configuration {
|
|
180
|
+
custom_jwt_authorizer {
|
|
181
|
+
discovery_url = "https://cognito-idp.${local.aws_region}.amazonaws.com/${var.user_pool_id}/.well-known/openid-configuration"
|
|
182
|
+
allowed_clients = var.user_pool_client_ids
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
<%_ } _%>
|
|
165
186
|
<%_ if (cedarPolicy) { _%>
|
|
166
187
|
|
|
167
188
|
policy_engine_configuration {
|
package/src/utils/commands.js
CHANGED
|
@@ -52,7 +52,7 @@ export const PACKAGE_MANAGER_COMMANDS = {
|
|
|
52
52
|
case 'npm':
|
|
53
53
|
return `npm install --legacy-peer-deps ${dev ? '-D ' : ''}${pkg}`;
|
|
54
54
|
case 'bun':
|
|
55
|
-
return `bun
|
|
55
|
+
return `bun add ${dev ? '-D ' : ''}${pkg}`;
|
|
56
56
|
default:
|
|
57
57
|
return `${pm} install ${dev ? '-D ' : ''}${pkg}`;
|
|
58
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/commands.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { TS_VERSIONS } from './versions';\n\n/**\n * The nx version the plugin is built against. Commands that download nx\n * (e.g. `nx init`) pin to this version so the workspace's nx matches the\n * plugin's `@nx/*` packages — a mismatch deadlocks `nx sync`.\n */\nexport const NX_VERSION = TS_VERSIONS['@nx/devkit'];\n\n/**\n * Display-friendly command prefixes for each package manager.\n *\n * - `exec`: prefix for running local binaries (e.g. `npx nx`, `pnpm nx`, `bunx nx`)\n * - `run`: prefix for running package.json scripts (e.g. `npm run build`, `pnpm build`)\n *\n * @see docs/src/components/package-manager-exec-command.astro\n * @see docs/src/components/package-manager-short-command.astro\n */\nexport interface PackageManagerDisplayCommands {\n /** Prefix for running local binaries: npx, pnpm, yarn, bunx */\n exec: string;\n /** Prefix for running package.json scripts: `npm run`, pnpm, yarn, bun */\n run: string;\n /** Prefix for `create` commands: `npm create`, `pnpm create`, etc. */\n create: string;\n}\n\nexport const PACKAGE_MANAGER_COMMANDS: Record<\n string,\n PackageManagerDisplayCommands\n> = {\n npm: { exec: 'npx', run: 'npm run', create: 'npm create' },\n pnpm: { exec: 'pnpm', run: 'pnpm', create: 'pnpm create' },\n yarn: { exec: 'yarn', run: 'yarn', create: 'yarn create' },\n bun: { exec: 'bunx', run: 'bun', create: 'bun create' },\n};\n\n/**\n * Build a package manager exec command (e.g. pnpm cmd, npx cmd, bunx cmd)\n */\nexport const buildPackageManagerExecCommand = (pm: string, command: string) => {\n const prefix = PACKAGE_MANAGER_COMMANDS[pm]?.exec ?? pm;\n return `${prefix} ${command}`;\n};\n\n/**\n * Build a short package manager command (e.g. pnpm build, npm run build)\n */\nexport const buildPackageManagerShortCommand = (\n pm: string,\n command: string,\n) => {\n const prefix = PACKAGE_MANAGER_COMMANDS[pm]?.run ?? pm;\n return `${prefix} ${command}`;\n};\n\n/**\n * Build an install command for a given package manager\n */\nexport const buildInstallCommand = (pm: string, pkg: string, dev: boolean) => {\n switch (pm) {\n case 'pnpm':\n return `pnpm add ${dev ? '-D' : '-'}w ${pkg}`;\n case 'yarn':\n return `yarn add ${dev ? '-D ' : ''}${pkg}`;\n case 'npm':\n return `npm install --legacy-peer-deps ${dev ? '-D ' : ''}${pkg}`;\n case 'bun':\n return `bun
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/commands.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { TS_VERSIONS } from './versions';\n\n/**\n * The nx version the plugin is built against. Commands that download nx\n * (e.g. `nx init`) pin to this version so the workspace's nx matches the\n * plugin's `@nx/*` packages — a mismatch deadlocks `nx sync`.\n */\nexport const NX_VERSION = TS_VERSIONS['@nx/devkit'];\n\n/**\n * Display-friendly command prefixes for each package manager.\n *\n * - `exec`: prefix for running local binaries (e.g. `npx nx`, `pnpm nx`, `bunx nx`)\n * - `run`: prefix for running package.json scripts (e.g. `npm run build`, `pnpm build`)\n *\n * @see docs/src/components/package-manager-exec-command.astro\n * @see docs/src/components/package-manager-short-command.astro\n */\nexport interface PackageManagerDisplayCommands {\n /** Prefix for running local binaries: npx, pnpm, yarn, bunx */\n exec: string;\n /** Prefix for running package.json scripts: `npm run`, pnpm, yarn, bun */\n run: string;\n /** Prefix for `create` commands: `npm create`, `pnpm create`, etc. */\n create: string;\n}\n\nexport const PACKAGE_MANAGER_COMMANDS: Record<\n string,\n PackageManagerDisplayCommands\n> = {\n npm: { exec: 'npx', run: 'npm run', create: 'npm create' },\n pnpm: { exec: 'pnpm', run: 'pnpm', create: 'pnpm create' },\n yarn: { exec: 'yarn', run: 'yarn', create: 'yarn create' },\n bun: { exec: 'bunx', run: 'bun', create: 'bun create' },\n};\n\n/**\n * Build a package manager exec command (e.g. pnpm cmd, npx cmd, bunx cmd)\n */\nexport const buildPackageManagerExecCommand = (pm: string, command: string) => {\n const prefix = PACKAGE_MANAGER_COMMANDS[pm]?.exec ?? pm;\n return `${prefix} ${command}`;\n};\n\n/**\n * Build a short package manager command (e.g. pnpm build, npm run build)\n */\nexport const buildPackageManagerShortCommand = (\n pm: string,\n command: string,\n) => {\n const prefix = PACKAGE_MANAGER_COMMANDS[pm]?.run ?? pm;\n return `${prefix} ${command}`;\n};\n\n/**\n * Build an install command for a given package manager\n */\nexport const buildInstallCommand = (pm: string, pkg: string, dev: boolean) => {\n switch (pm) {\n case 'pnpm':\n return `pnpm add ${dev ? '-D' : '-'}w ${pkg}`;\n case 'yarn':\n return `yarn add ${dev ? '-D ' : ''}${pkg}`;\n case 'npm':\n return `npm install --legacy-peer-deps ${dev ? '-D ' : ''}${pkg}`;\n case 'bun':\n return `bun add ${dev ? '-D ' : ''}${pkg}`;\n default:\n return `${pm} install ${dev ? '-D ' : ''}${pkg}`;\n }\n};\n\n/**\n * Build the command that adds Nx to a non-Nx project, pinned to the nx\n * version the plugin is built against.\n */\nexport const buildNxInitCommand = (pm: string) => {\n const dlxPrefix =\n { npm: 'npx', pnpm: 'pnpm dlx', yarn: 'yarn dlx', bun: 'bunx' }[pm] ??\n 'npx';\n return `${dlxPrefix} nx@${NX_VERSION} init`;\n};\n\n/**\n * Build a command to create a new workspace using @aws/create-nx-workspace.\n *\n * Uses the `create` shorthand for each package manager:\n * npm create @aws/nx-workspace my-project\n * pnpm create @aws/nx-workspace my-project\n * yarn create @aws/nx-workspace my-project\n * bun create @aws/nx-workspace my-project\n *\n * The package manager is auto-detected by @aws/create-nx-workspace from the\n * invoking command, so --pm is not needed.\n */\nexport const buildCreateNxWorkspaceCommand = (\n pm: string,\n workspace: string,\n iac?: 'cdk' | 'terraform',\n tag?: string,\n module?: 'esm' | 'cjs',\n) => {\n const createPrefix = PACKAGE_MANAGER_COMMANDS[pm]?.create ?? `${pm} create`;\n const pkgName = tag ? `@aws/nx-workspace@${tag}` : '@aws/nx-workspace';\n const parts = [\n createPrefix,\n pkgName,\n // npm requires '--' to stop interpreting subsequent flags as npm config\n ...(pm === 'npm' ? ['--'] : []),\n workspace,\n ...(iac ? [`--iac=${iac}`] : []),\n ...(module ? [`--module=${module}`] : []),\n ];\n return parts.join(' ');\n};\n"],"names":["TS_VERSIONS","NX_VERSION","PACKAGE_MANAGER_COMMANDS","npm","exec","run","create","pnpm","yarn","bun","buildPackageManagerExecCommand","pm","command","prefix","buildPackageManagerShortCommand","buildInstallCommand","pkg","dev","buildNxInitCommand","dlxPrefix","buildCreateNxWorkspaceCommand","workspace","iac","tag","module","createPrefix","pkgName","parts","join"],"mappings":"AAAA;;;CAGC,GACD,SAASA,WAAW,QAAQ,gBAAa;AAEzC;;;;CAIC,GACD,OAAO,MAAMC,aAAaD,WAAW,CAAC,aAAa,CAAC;AAoBpD,OAAO,MAAME,2BAGT;IACFC,KAAK;QAAEC,MAAM;QAAOC,KAAK;QAAWC,QAAQ;IAAa;IACzDC,MAAM;QAAEH,MAAM;QAAQC,KAAK;QAAQC,QAAQ;IAAc;IACzDE,MAAM;QAAEJ,MAAM;QAAQC,KAAK;QAAQC,QAAQ;IAAc;IACzDG,KAAK;QAAEL,MAAM;QAAQC,KAAK;QAAOC,QAAQ;IAAa;AACxD,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMI,iCAAiC,CAACC,IAAYC;IACzD,MAAMC,SAASX,wBAAwB,CAACS,GAAG,EAAEP,QAAQO;IACrD,OAAO,GAAGE,OAAO,CAAC,EAAED,SAAS;AAC/B,EAAE;AAEF;;CAEC,GACD,OAAO,MAAME,kCAAkC,CAC7CH,IACAC;IAEA,MAAMC,SAASX,wBAAwB,CAACS,GAAG,EAAEN,OA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"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { type Tree } from '@nx/devkit';
|
|
6
|
+
import type { Iac } from '../iac';
|
|
7
|
+
/**
|
|
8
|
+
* The DCR proxy Lambda handlers. Each is bundled independently and wired to a
|
|
9
|
+
* dedicated route on the HTTP API.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DCR_PROXY_HANDLERS: readonly ["authorization-server-metadata", "authorize", "mcp-proxy", "protected-resource-metadata", "register", "token"];
|
|
12
|
+
export type DcrProxyHandler = (typeof DCR_PROXY_HANDLERS)[number];
|
|
13
|
+
export interface AddDcrProxyInfraProps {
|
|
14
|
+
dcrProxyNameClassName: string;
|
|
15
|
+
dcrProxyNameKebabCase: string;
|
|
16
|
+
/**
|
|
17
|
+
* Fully qualified name of the TypeScript project that owns the bundled
|
|
18
|
+
* handlers, used to wire the shared package build to depend on it.
|
|
19
|
+
*/
|
|
20
|
+
proxyProjectName: string;
|
|
21
|
+
/**
|
|
22
|
+
* Map of handler name to the workspace-root-relative path of its bundle
|
|
23
|
+
* output directory (e.g. `dist/packages/dcr-proxy/bundle/token`).
|
|
24
|
+
*/
|
|
25
|
+
bundlePathsFromRoot: Record<DcrProxyHandler, string>;
|
|
26
|
+
iac: Iac;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Add a DCR proxy infrastructure (CDK construct or Terraform module) to the
|
|
30
|
+
* relevant shared package.
|
|
31
|
+
*
|
|
32
|
+
* The infrastructure exposes props/variables for the caller to inject their
|
|
33
|
+
* Cognito identifiers and the upstream MCP server URL from their own stack,
|
|
34
|
+
* since these may or may not be generated by this plugin. The Lambda handlers
|
|
35
|
+
* live in a standalone TypeScript project and are bundled by rolldown; both
|
|
36
|
+
* IaC providers reference the same bundle output.
|
|
37
|
+
*/
|
|
38
|
+
export declare const addDcrProxyInfra: (tree: Tree, options: AddDcrProxyInfraProps) => Promise<void>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ import { generateFiles, joinPathFragments, OverwriteStrategy, updateJson } from "@nx/devkit";
|
|
5
|
+
import { addStarExport } from "../ast.js";
|
|
6
|
+
import { esmVars } from "../module-format.js";
|
|
7
|
+
import { addDependencyToTargetIfNotPresent } from "../nx.js";
|
|
8
|
+
import { PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, SHARED_TERRAFORM_DIR } from "../shared-constructs-constants.js";
|
|
9
|
+
import { terraformProviderVersions } from "../versions.js";
|
|
10
|
+
/**
|
|
11
|
+
* The DCR proxy Lambda handlers. Each is bundled independently and wired to a
|
|
12
|
+
* dedicated route on the HTTP API.
|
|
13
|
+
*/ export const DCR_PROXY_HANDLERS = [
|
|
14
|
+
'authorization-server-metadata',
|
|
15
|
+
'authorize',
|
|
16
|
+
'mcp-proxy',
|
|
17
|
+
'protected-resource-metadata',
|
|
18
|
+
'register',
|
|
19
|
+
'token'
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* Add a DCR proxy infrastructure (CDK construct or Terraform module) to the
|
|
23
|
+
* relevant shared package.
|
|
24
|
+
*
|
|
25
|
+
* The infrastructure exposes props/variables for the caller to inject their
|
|
26
|
+
* Cognito identifiers and the upstream MCP server URL from their own stack,
|
|
27
|
+
* since these may or may not be generated by this plugin. The Lambda handlers
|
|
28
|
+
* live in a standalone TypeScript project and are bundled by rolldown; both
|
|
29
|
+
* IaC providers reference the same bundle output.
|
|
30
|
+
*/ export const addDcrProxyInfra = async (tree, options)=>{
|
|
31
|
+
if (options.iac === 'cdk') {
|
|
32
|
+
await addDcrProxyCdkConstructs(tree, options);
|
|
33
|
+
} else if (options.iac === 'terraform') {
|
|
34
|
+
addDcrProxyTerraformModules(tree, options);
|
|
35
|
+
} else {
|
|
36
|
+
throw new Error(`Unsupported iac ${options.iac}`);
|
|
37
|
+
}
|
|
38
|
+
// Ensure the handler bundles are built before the shared package
|
|
39
|
+
updateJson(tree, joinPathFragments(PACKAGES_DIR, options.iac === 'cdk' ? SHARED_CONSTRUCTS_DIR : SHARED_TERRAFORM_DIR, 'project.json'), (config)=>{
|
|
40
|
+
addDependencyToTargetIfNotPresent(config, 'build', `${options.proxyProjectName}:build`);
|
|
41
|
+
return config;
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Add the DCR proxy CDK construct to the shared constructs package.
|
|
46
|
+
*/ const addDcrProxyCdkConstructs = async (tree, options)=>{
|
|
47
|
+
// Ensure the core HTTP API construct + utils are available (the proxy reuses
|
|
48
|
+
// them). These are shared with the api generators and safe to (re)generate
|
|
49
|
+
// with KeepExisting.
|
|
50
|
+
for (const coreApiFile of [
|
|
51
|
+
'http',
|
|
52
|
+
'utils'
|
|
53
|
+
]){
|
|
54
|
+
generateFiles(tree, joinPathFragments(import.meta.dirname, '..', 'api-constructs', 'files', 'cdk', 'core', 'api', coreApiFile), joinPathFragments(PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, 'src', 'core', 'api'), {
|
|
55
|
+
...esmVars(tree)
|
|
56
|
+
}, {
|
|
57
|
+
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', 'cdk', 'app', 'dcr-proxies'), joinPathFragments(PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, 'src', 'app', 'dcr-proxies'), {
|
|
61
|
+
nameClassName: options.dcrProxyNameClassName,
|
|
62
|
+
nameKebabCase: options.dcrProxyNameKebabCase,
|
|
63
|
+
bundlePathsFromRoot: options.bundlePathsFromRoot,
|
|
64
|
+
...esmVars(tree)
|
|
65
|
+
}, {
|
|
66
|
+
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
67
|
+
});
|
|
68
|
+
// Export the construct
|
|
69
|
+
await addStarExport(tree, joinPathFragments(PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, 'src', 'app', 'dcr-proxies', 'index.ts'), `./${options.dcrProxyNameKebabCase}/${options.dcrProxyNameKebabCase}.js`);
|
|
70
|
+
await addStarExport(tree, joinPathFragments(PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, 'src', 'app', 'index.ts'), './dcr-proxies/index.js');
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Add the DCR proxy Terraform module to the shared terraform package.
|
|
74
|
+
*/ const addDcrProxyTerraformModules = (tree, options)=>{
|
|
75
|
+
// Ensure the core HTTP API module is available (the proxy reuses it). This is
|
|
76
|
+
// shared with the api generators and safe to (re)generate with KeepExisting.
|
|
77
|
+
generateFiles(tree, joinPathFragments(import.meta.dirname, '..', 'api-constructs', 'files', 'terraform', 'core', 'api', 'http'), joinPathFragments(PACKAGES_DIR, SHARED_TERRAFORM_DIR, 'src', 'core', 'api'), {
|
|
78
|
+
...terraformProviderVersions()
|
|
79
|
+
}, {
|
|
80
|
+
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
81
|
+
});
|
|
82
|
+
// Generate the app specific terraform module
|
|
83
|
+
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', 'terraform', 'app', 'dcr-proxies'), joinPathFragments(PACKAGES_DIR, SHARED_TERRAFORM_DIR, 'src', 'app', 'dcr-proxies'), {
|
|
84
|
+
nameClassName: options.dcrProxyNameClassName,
|
|
85
|
+
nameKebabCase: options.dcrProxyNameKebabCase,
|
|
86
|
+
bundlePathsFromRoot: options.bundlePathsFromRoot,
|
|
87
|
+
...terraformProviderVersions()
|
|
88
|
+
}, {
|
|
89
|
+
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=dcr-proxy-constructs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/dcr-proxy-constructs/dcr-proxy-constructs.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type ProjectConfiguration,\n type Tree,\n updateJson,\n} from '@nx/devkit';\nimport { addStarExport } from '../ast';\nimport type { Iac } from '../iac';\nimport { esmVars } from '../module-format';\nimport { addDependencyToTargetIfNotPresent } from '../nx';\nimport {\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n SHARED_TERRAFORM_DIR,\n} from '../shared-constructs-constants';\nimport { terraformProviderVersions } from '../versions';\n\n/**\n * The DCR proxy Lambda handlers. Each is bundled independently and wired to a\n * dedicated route on the HTTP API.\n */\nexport const DCR_PROXY_HANDLERS = [\n 'authorization-server-metadata',\n 'authorize',\n 'mcp-proxy',\n 'protected-resource-metadata',\n 'register',\n 'token',\n] as const;\n\nexport type DcrProxyHandler = (typeof DCR_PROXY_HANDLERS)[number];\n\nexport interface AddDcrProxyInfraProps {\n dcrProxyNameClassName: string;\n dcrProxyNameKebabCase: string;\n\n /**\n * Fully qualified name of the TypeScript project that owns the bundled\n * handlers, used to wire the shared package build to depend on it.\n */\n proxyProjectName: string;\n\n /**\n * Map of handler name to the workspace-root-relative path of its bundle\n * output directory (e.g. `dist/packages/dcr-proxy/bundle/token`).\n */\n bundlePathsFromRoot: Record<DcrProxyHandler, string>;\n\n iac: Iac;\n}\n\n/**\n * Add a DCR proxy infrastructure (CDK construct or Terraform module) to the\n * relevant shared package.\n *\n * The infrastructure exposes props/variables for the caller to inject their\n * Cognito identifiers and the upstream MCP server URL from their own stack,\n * since these may or may not be generated by this plugin. The Lambda handlers\n * live in a standalone TypeScript project and are bundled by rolldown; both\n * IaC providers reference the same bundle output.\n */\nexport const addDcrProxyInfra = async (\n tree: Tree,\n options: AddDcrProxyInfraProps,\n) => {\n if (options.iac === 'cdk') {\n await addDcrProxyCdkConstructs(tree, options);\n } else if (options.iac === 'terraform') {\n addDcrProxyTerraformModules(tree, options);\n } else {\n throw new Error(`Unsupported iac ${options.iac}`);\n }\n\n // Ensure the handler bundles are built before the shared package\n updateJson(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n options.iac === 'cdk' ? SHARED_CONSTRUCTS_DIR : SHARED_TERRAFORM_DIR,\n 'project.json',\n ),\n (config: ProjectConfiguration) => {\n addDependencyToTargetIfNotPresent(\n config,\n 'build',\n `${options.proxyProjectName}:build`,\n );\n return config;\n },\n );\n};\n\n/**\n * Add the DCR proxy CDK construct to the shared constructs package.\n */\nconst addDcrProxyCdkConstructs = async (\n tree: Tree,\n options: AddDcrProxyInfraProps,\n) => {\n // Ensure the core HTTP API construct + utils are available (the proxy reuses\n // them). These are shared with the api generators and safe to (re)generate\n // with KeepExisting.\n for (const coreApiFile of ['http', 'utils']) {\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n '..',\n 'api-constructs',\n 'files',\n 'cdk',\n 'core',\n 'api',\n coreApiFile,\n ),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'core',\n 'api',\n ),\n { ...esmVars(tree) },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n }\n\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'cdk',\n 'app',\n 'dcr-proxies',\n ),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'dcr-proxies',\n ),\n {\n nameClassName: options.dcrProxyNameClassName,\n nameKebabCase: options.dcrProxyNameKebabCase,\n bundlePathsFromRoot: options.bundlePathsFromRoot,\n ...esmVars(tree),\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n // Export the construct\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'dcr-proxies',\n 'index.ts',\n ),\n `./${options.dcrProxyNameKebabCase}/${options.dcrProxyNameKebabCase}.js`,\n );\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'index.ts',\n ),\n './dcr-proxies/index.js',\n );\n};\n\n/**\n * Add the DCR proxy Terraform module to the shared terraform package.\n */\nconst addDcrProxyTerraformModules = (\n tree: Tree,\n options: AddDcrProxyInfraProps,\n) => {\n // Ensure the core HTTP API module is available (the proxy reuses it). This is\n // shared with the api generators and safe to (re)generate with KeepExisting.\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n '..',\n 'api-constructs',\n 'files',\n 'terraform',\n 'core',\n 'api',\n 'http',\n ),\n joinPathFragments(PACKAGES_DIR, SHARED_TERRAFORM_DIR, 'src', 'core', 'api'),\n { ...terraformProviderVersions() },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n // Generate the app specific terraform module\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'terraform',\n 'app',\n 'dcr-proxies',\n ),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_TERRAFORM_DIR,\n 'src',\n 'app',\n 'dcr-proxies',\n ),\n {\n nameClassName: options.dcrProxyNameClassName,\n nameKebabCase: options.dcrProxyNameKebabCase,\n bundlePathsFromRoot: options.bundlePathsFromRoot,\n ...terraformProviderVersions(),\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n};\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateJson","addStarExport","esmVars","addDependencyToTargetIfNotPresent","PACKAGES_DIR","SHARED_CONSTRUCTS_DIR","SHARED_TERRAFORM_DIR","terraformProviderVersions","DCR_PROXY_HANDLERS","addDcrProxyInfra","tree","options","iac","addDcrProxyCdkConstructs","addDcrProxyTerraformModules","Error","config","proxyProjectName","coreApiFile","dirname","overwriteStrategy","KeepExisting","nameClassName","dcrProxyNameClassName","nameKebabCase","dcrProxyNameKebabCase","bundlePathsFromRoot"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAGjBC,UAAU,QACL,aAAa;AACpB,SAASC,aAAa,QAAQ,YAAS;AAEvC,SAASC,OAAO,QAAQ,sBAAmB;AAC3C,SAASC,iCAAiC,QAAQ,WAAQ;AAC1D,SACEC,YAAY,EACZC,qBAAqB,EACrBC,oBAAoB,QACf,oCAAiC;AACxC,SAASC,yBAAyB,QAAQ,iBAAc;AAExD;;;CAGC,GACD,OAAO,MAAMC,qBAAqB;IAChC;IACA;IACA;IACA;IACA;IACA;CACD,CAAU;AAuBX;;;;;;;;;CASC,GACD,OAAO,MAAMC,mBAAmB,OAC9BC,MACAC;IAEA,IAAIA,QAAQC,GAAG,KAAK,OAAO;QACzB,MAAMC,yBAAyBH,MAAMC;IACvC,OAAO,IAAIA,QAAQC,GAAG,KAAK,aAAa;QACtCE,4BAA4BJ,MAAMC;IACpC,OAAO;QACL,MAAM,IAAII,MAAM,CAAC,gBAAgB,EAAEJ,QAAQC,GAAG,EAAE;IAClD;IAEA,iEAAiE;IACjEZ,WACEU,MACAZ,kBACEM,cACAO,QAAQC,GAAG,KAAK,QAAQP,wBAAwBC,sBAChD,iBAEF,CAACU;QACCb,kCACEa,QACA,SACA,GAAGL,QAAQM,gBAAgB,CAAC,MAAM,CAAC;QAErC,OAAOD;IACT;AAEJ,EAAE;AAEF;;CAEC,GACD,MAAMH,2BAA2B,OAC/BH,MACAC;IAEA,6EAA6E;IAC7E,2EAA2E;IAC3E,qBAAqB;IACrB,KAAK,MAAMO,eAAe;QAAC;QAAQ;KAAQ,CAAE;QAC3CrB,cACEa,MACAZ,kBACE,YAAYqB,OAAO,EACnB,MACA,kBACA,SACA,OACA,QACA,OAC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