From bffed4401fa0518cce650f6719fcf82e01308a91 Mon Sep 17 00:00:00 2001 From: Oussama Hansal Date: Tue, 28 Apr 2026 12:47:35 -0700 Subject: [PATCH 1/3] Validate that a Bedrock model or inference profile is available and enabled before attempting to use it --- ...kit-neptune-analytics-aurora-postgres.json | 268 +- ...ptune-analytics-opensearch-serverless.json | 268 +- ...-toolkit-neptune-analytics-s3-vectors.json | 268 +- .../graphrag-toolkit-neptune-analytics.json | 268 +- ...ptune-db-aurora-postgres-existing-vpc.json | 268 +- ...ag-toolkit-neptune-db-aurora-postgres.json | 4298 ++++++++--------- ...lkit-neptune-db-opensearch-serverless.json | 268 +- ...raphrag-toolkit-neptune-db-s3-vectors.json | 268 +- .../workshop/graphrag-toolkit-workshop.json | 88 +- integration-tests/build-tests.sh | 36 +- ...g-toolkit-neo4j-opensearch-serverless.json | 296 +- .../graphrag-toolkit-tests.json | 170 +- integration-tests/env.template | 4 +- .../graphrag_toolkit_tests/batch_extract.py | 4 +- .../graphrag_toolkit_tests/batch_fallback.py | 2 +- .../graphrag_toolkit_tests/checkpoint.py | 4 +- .../graphrag_toolkit_tests/extract.py | 2 +- .../extract_and_build.py | 2 +- .../graphrag_toolkit_tests/query.py | 22 +- .../graphrag_toolkit_tests/query_gpu.py | 2 +- .../graphrag_toolkit_tests/versioning.py | 10 +- .../graphrag_toolkit/lexical_graph/config.py | 4 +- 22 files changed, 2209 insertions(+), 4611 deletions(-) diff --git a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-aurora-postgres.json b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-aurora-postgres.json index 23ba68aa..b09b84cb 100644 --- a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-aurora-postgres.json +++ b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-aurora-postgres.json @@ -795,97 +795,19 @@ "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-5-haiku-20241022-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-7-sonnet-20250219-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" @@ -1033,99 +955,15 @@ }, "\" >> ~/.bashrc\n", "echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> ~/.bashrc\n", "echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_AUTH_MODE=IAM\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_SSL=True\" >> ~/.bashrc\n", @@ -1285,99 +1123,15 @@ }, "\" >> .env\n", " echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> .env\n", " echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> .env\n", " echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " if [ -f \"./run_test_suite.sh\" ]\n", " then\n", @@ -1996,4 +1750,4 @@ } } } -} \ No newline at end of file +} diff --git a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-opensearch-serverless.json b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-opensearch-serverless.json index 56ed7367..3a6551ad 100644 --- a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-opensearch-serverless.json +++ b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-opensearch-serverless.json @@ -356,97 +356,19 @@ "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-5-haiku-20241022-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-7-sonnet-20250219-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" @@ -881,99 +803,15 @@ }, "\" >> ~/.bashrc\n", "echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> ~/.bashrc\n", "echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_AUTH_MODE=IAM\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_SSL=True\" >> ~/.bashrc\n", @@ -1121,99 +959,15 @@ }, "\" >> .env\n", " echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> .env\n", " echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> .env\n", " echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " if [ -f \"./run_test_suite.sh\" ]\n", " then\n", @@ -1281,4 +1035,4 @@ } } } -} \ No newline at end of file +} diff --git a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-s3-vectors.json b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-s3-vectors.json index 19a402d1..958441f0 100644 --- a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-s3-vectors.json +++ b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-s3-vectors.json @@ -412,97 +412,19 @@ "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-5-haiku-20241022-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-7-sonnet-20250219-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" @@ -1109,99 +1031,15 @@ }, "\" >> ~/.bashrc\n", "echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> ~/.bashrc\n", "echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_AUTH_MODE=IAM\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_SSL=True\" >> ~/.bashrc\n", @@ -1341,99 +1179,15 @@ }, "\" >> .env\n", " echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> .env\n", " echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> .env\n", " echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " if [ -f \"./run_test_suite.sh\" ]\n", " then\n", @@ -1498,4 +1252,4 @@ } } } -} \ No newline at end of file +} diff --git a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics.json b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics.json index f5a3ee6e..cb12ec2c 100644 --- a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics.json +++ b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics.json @@ -308,97 +308,19 @@ "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-5-haiku-20241022-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-7-sonnet-20250219-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" @@ -538,99 +460,15 @@ }, "\" >> ~/.bashrc\n", "echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> ~/.bashrc\n", "echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_AUTH_MODE=IAM\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_SSL=True\" >> ~/.bashrc\n", @@ -778,99 +616,15 @@ }, "\" >> .env\n", " echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> .env\n", " echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> .env\n", " echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " if [ -f \"./run_test_suite.sh\" ]\n", " then\n", @@ -929,4 +683,4 @@ } } } -} \ No newline at end of file +} diff --git a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-aurora-postgres-existing-vpc.json b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-aurora-postgres-existing-vpc.json index c4d1b89c..7d436d85 100644 --- a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-aurora-postgres-existing-vpc.json +++ b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-aurora-postgres-existing-vpc.json @@ -735,97 +735,19 @@ "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-5-haiku-20241022-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-7-sonnet-20250219-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" @@ -1472,99 +1394,15 @@ "Ref": "AWS::StackId" }, "echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> ~/.bashrc\n", "echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_AUTH_MODE=IAM\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_SSL=True\" >> ~/.bashrc\n", @@ -1738,99 +1576,15 @@ }, "\" >> .env\n", " echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> .env\n", " echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> .env\n", " echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " echo \"export LOCAL_EXTRACT_S3=", { @@ -2246,4 +2000,4 @@ } } } -} \ No newline at end of file +} diff --git a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-aurora-postgres.json b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-aurora-postgres.json index 328fb4e8..cd43ca73 100644 --- a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-aurora-postgres.json +++ b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-aurora-postgres.json @@ -1,786 +1,708 @@ { - "Description": "Creates a lexical-graph environment (VPC, Neptune Database, Aurora Postgres, and SageMaker notebook)", - "Parameters": { - "ApplicationId": { - "Description": "Application id (used to name all resources in the environment)", - "Type": "String", - "Default": "graphrag-toolkit", - "AllowedPattern": "[a-z][a-z0-9-]*", - "MaxLength": 16, - "MinLength": 3, - "ConstraintDescription": "Must start with a lowercase letter, contain between 3 and 16 characters, and contain only lowercase letters, numbers and the hyphen" - }, - "NeptuneEngineVersion": { - "Description": "Neptune DB engine version", - "Type": "String", - "Default": "1.4.7.0" - }, - "NeptuneDbInstanceType": { - "Description": "Neptune DB instance type (use db.serverless to provision a Neptune Serverless cluster)", - "Type": "String", - "Default": "db.r8g.large", - "AllowedValues": [ - "db.serverless", - "db.r8g.large", - "db.r8g.xlarge", + "Description": "Creates a lexical-graph environment (VPC, Neptune Database, Aurora Postgres, and SageMaker notebook)", + "Parameters": { + "ApplicationId": { + "Description": "Application id (used to name all resources in the environment)", + "Type": "String", + "Default": "graphrag-toolkit", + "AllowedPattern": "[a-z][a-z0-9-]*", + "MaxLength": 16, + "MinLength": 3, + "ConstraintDescription": "Must start with a lowercase letter, contain between 3 and 16 characters, and contain only lowercase letters, numbers and the hyphen" + }, + "NeptuneEngineVersion": { + "Description": "Neptune DB engine version", + "Type": "String", + "Default": "1.4.7.0" + }, + "NeptuneDbInstanceType": { + "Description": "Neptune DB instance type (use db.serverless to provision a Neptune Serverless cluster)", + "Type": "String", + "Default": "db.r8g.large", + "AllowedValues": [ + "db.serverless", + "db.r8g.large", + "db.r8g.xlarge", "db.r8g.2xlarge", "db.r8g.4xlarge" - ], - "ConstraintDescription": "Must be a valid Neptune instance type." - }, - "MinNCU": { - "Description": "Min number of NCUs (default 2.5, relevant only when instance type is db.serverless).", - "Type": "Number", - "Default": 2.5, - "MaxValue": 128, - "MinValue": 1 - }, - "MaxNCU": { - "Description": "Max number of NCUs (default 32, relevant only when instance type is db.serverless).", - "Type": "Number", - "Default": 32, - "MaxValue": 128, - "MinValue": 1 - }, - "EnableAuditLog": { - "Description": "Enable database auditing logging", - "Type": "String", - "Default": "false", - "AllowedValues": [ - "true", - "false" - ] - }, - "PostgresDbInstanceType": { - "Description": "Aurora Postgres DB instance type (use db.serverless to provision an Aurora Serverless cluster)", - "Type": "String", - "Default": "db.serverless", - "AllowedValues": [ - "db.serverless", - "db.r6g.large", - "db.r6g.xlarge", - "db.r6g.2xlarge" - ], - "ConstraintDescription": "Must be a valid Aurora instance type." - }, - "MinACU": { - "Description": "Min number of ACUs (default 0, relevant only when instance type is db.serverless).", - "Type": "Number", - "Default": 0, - "MaxValue": 128, - "MinValue": 0 - }, - "MaxACU": { - "Description": "Max number of ACUs (default 32, relevant only when instance type is db.serverless).", - "Type": "Number", - "Default": 32, - "MaxValue": 128, - "MinValue": 0.5 - }, - "IamPolicyArn": { - "Type": "String", - "Description": "Space-separated ARNs of one or more additional IAM policies to be attached to the GraphRAG client IAM role (optional)", - "Default": "" - }, - "NotebookInstanceType": { - "Description": "SageMaker notebook instance type (use ml.p3.2xlarge to provision a GPU instance)", - "Type": "String", - "Default": "ml.m5.xlarge", - "AllowedValues": [ - "ml.m5.xlarge", + ], + "ConstraintDescription": "Must be a valid Neptune instance type." + }, + "MinNCU": { + "Description": "Min number of NCUs (default 2.5, relevant only when instance type is db.serverless).", + "Type": "Number", + "Default": 2.5, + "MaxValue": 128, + "MinValue": 1 + }, + "MaxNCU": { + "Description": "Max number of NCUs (default 32, relevant only when instance type is db.serverless).", + "Type": "Number", + "Default": 32, + "MaxValue": 128, + "MinValue": 1 + }, + "EnableAuditLog": { + "Description": "Enable database auditing logging", + "Type": "String", + "Default": "false", + "AllowedValues": [ + "true", + "false" + ] + }, + "PostgresDbInstanceType": { + "Description": "Aurora Postgres DB instance type (use db.serverless to provision an Aurora Serverless cluster)", + "Type": "String", + "Default": "db.serverless", + "AllowedValues": [ + "db.serverless", + "db.r6g.large", + "db.r6g.xlarge", + "db.r6g.2xlarge" + ], + "ConstraintDescription": "Must be a valid Aurora instance type." + }, + "MinACU": { + "Description": "Min number of ACUs (default 0, relevant only when instance type is db.serverless).", + "Type": "Number", + "Default": 0, + "MaxValue": 128, + "MinValue": 0 + }, + "MaxACU": { + "Description": "Max number of ACUs (default 32, relevant only when instance type is db.serverless).", + "Type": "Number", + "Default": 32, + "MaxValue": 128, + "MinValue": 0.5 + }, + "IamPolicyArn": { + "Type": "String", + "Description": "Space-separated ARNs of one or more additional IAM policies to be attached to the GraphRAG client IAM role (optional)", + "Default": "" + }, + "NotebookInstanceType": { + "Description": "SageMaker notebook instance type (use ml.p3.2xlarge to provision a GPU instance)", + "Type": "String", + "Default": "ml.m5.xlarge", + "AllowedValues": [ + "ml.m5.xlarge", "ml.m5.2xlarge", "ml.m5.4xlarge", - "ml.p3.2xlarge" - ], - "ConstraintDescription": "Must be a valid SageMaker instance type." - }, - "ExampleNotebooksURL": { - "Type": "String", - "Description": "URL of a zip file containing example notebooks to be installed on SageMaker instance (optional)", - "Default": "https://github.com/awslabs/graphrag-toolkit/releases/latest/download/lexical-graph-examples-latest.zip" - } - }, - "Metadata": { - "AWS::CloudFormation::Interface": { - "ParameterGroups": [ - { - "Label": { - "default": "Setup" - }, - "Parameters": [ - "ApplicationId" - ] - }, - { - "Label": { - "default": "Neptune" - }, - "Parameters": [ - "NeptuneEngineVersion", - "NeptuneDbInstanceType", - "MinNCU", - "MaxNCU", - "EnableAuditLog" - ] - }, - { - "Label": { - "default": "Aurora Postgres" - }, - "Parameters": [ - "PostgresDbInstanceType", - "MinACU", - "MaxACU" - ] - }, - { - "Label": { - "default": "Notebook" - }, - "Parameters": [ - "NotebookInstanceType", - "ExampleNotebooksURL", - "IamPolicyArn" - ] - } - ] - } - }, - "Conditions": { - "ExampleNotebooksURLIsNotBlank": { - "Fn::Not": [ - { - "Fn::Equals": [ - { - "Ref": "ExampleNotebooksURL" - }, - "" - ] - } - ] - }, - "IsS3ExampleNotebooksURL": { - "Fn::Equals": [ - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - ":", - { - "Ref": "ExampleNotebooksURL" - } - ] - } - ] - }, - "s3" - ] - }, - "IsIadRegion": { - "Fn::Equals": [ - { - "Ref": "AWS::Region" - }, - "us-east-1" - ] - }, - "AZ3NotPresent": { - "Fn::Or": [ - { - "Fn::Equals": [ - { - "Ref": "AWS::Region" - }, - "ca-central-1" - ] - }, - { - "Fn::Equals": [ - { - "Ref": "AWS::Region" - }, - "us-west-1" - ] - } - ] - }, - "AZ3Present": { - "Fn::Not": [ - { - "Condition": "AZ3NotPresent" - } - ] - }, - "AddIamPolicyArn": { - "Fn::Not": [ - { - "Fn::Equals": [ - { - "Ref": "IamPolicyArn" - }, - "" - ] - } - ] - }, - "AuditLogEnabled": { - "Fn::Equals": [ - { - "Ref": "EnableAuditLog" - }, - "true" - ] - } - }, - "Resources": { - "NeptuneDBSubnetGroup": { - "Type": "AWS::Neptune::DBSubnetGroup", - "Properties": { - "DBSubnetGroupDescription": "Neptune DB subnet group", - "DBSubnetGroupName": { - "Fn::Sub": "${ApplicationId}-neptune-subnet" - }, - "SubnetIds": { - "Fn::If": [ - "AZ3NotPresent", - [ - { - "Ref": "Subnet1" - }, - { - "Ref": "Subnet2" - } - ], - [ - { - "Ref": "Subnet1" - }, - { - "Ref": "Subnet2" - }, - { - "Ref": "Subnet3" - } - ] - ] - }, - "Tags": [ - { - "Key": "Name", - "Value": { - "Fn::Sub": "${ApplicationId}-neptune-subnet" - } - }, - { - "Key": "StackId", - "Value": { - "Fn::Sub": "${AWS::StackId}" - } - }, - { - "Key": "Stack", - "Value": { - "Fn::Sub": "${AWS::Region}-${AWS::StackName}" - } - }, - { - "Key": "Application", - "Value": { - "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" - } - } - ] - } - }, - "PostgresSubnetGroup": { - "Type": "AWS::RDS::DBSubnetGroup", - "Properties": { - "DBSubnetGroupDescription": "PostgreSQL subnet group", - "DBSubnetGroupName": { - "Fn::Sub": "${ApplicationId}-pg-subnet" - }, - "SubnetIds": { - "Fn::If": [ - "AZ3NotPresent", - [ - { - "Ref": "Subnet1" - }, - { - "Ref": "Subnet2" - } - ], - [ - { - "Ref": "Subnet1" - }, - { - "Ref": "Subnet2" - }, - { - "Ref": "Subnet3" - } - ] - ] - }, - "Tags": [ - { - "Key": "Name", - "Value": { - "Fn::Sub": "${ApplicationId}-pg- subnet" - } - }, - { - "Key": "StackId", - "Value": { - "Fn::Sub": "${AWS::StackId}" - } - }, - { - "Key": "Stack", - "Value": { - "Fn::Sub": "${AWS::Region}-${AWS::StackName}" - } - }, - { - "Key": "Application", - "Value": { - "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" - } - } - ] - } - }, - "GraphRAGClientSecurityGroup": { - "Type": "AWS::EC2::SecurityGroup", - "Properties": { - "GroupName": { - "Fn::Sub": "${ApplicationId}-client-sg" - }, - "VpcId": { - "Ref": "VPC" - }, - "GroupDescription": "GraphRAG client security group", - "SecurityGroupEgress": [ - { - "FromPort": "443", - "ToPort": "443", - "IpProtocol": "tcp", - "CidrIp": "0.0.0.0/0", - "Description": "HTTPS egress" - } - ], - "Tags": [ - { - "Key": "Name", - "Value": { - "Fn::Sub": "${ApplicationId}-client-sg" - } - }, - { - "Key": "StackId", - "Value": { - "Fn::Sub": "${AWS::StackId}" - } - }, - { - "Key": "Stack", - "Value": { - "Fn::Sub": "${AWS::Region}-${AWS::StackName}" - } - }, - { - "Key": "Application", - "Value": { - "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" - } - } - ] - } - }, - "NeptuneSecurityGroup": { - "Type": "AWS::EC2::SecurityGroup", - "Properties": { - "GroupName": { - "Fn::Sub": "${ApplicationId}-neptune-sg" - }, - "VpcId": { - "Ref": "VPC" - }, - "GroupDescription": "GraphRAG Neptune security group", - "Tags": [ - { - "Key": "Name", - "Value": { - "Fn::Sub": "${ApplicationId}-neptune-sg" - } - }, - { - "Key": "StackId", - "Value": { - "Fn::Sub": "${AWS::StackId}" - } - }, - { - "Key": "Stack", - "Value": { - "Fn::Sub": "${AWS::Region}-${AWS::StackName}" - } - }, - { - "Key": "Application", - "Value": { - "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" - } - } - ] - } - }, - "PostgresSecurityGroup": { - "Type": "AWS::EC2::SecurityGroup", - "Properties": { - "GroupName": { - "Fn::Sub": "${ApplicationId}-pg-sg" - }, - "VpcId": { - "Ref": "VPC" - }, - "GroupDescription": "PostgreSQL security group", - "Tags": [ - { - "Key": "Name", - "Value": { - "Fn::Sub": "${ApplicationId}-pg-sg" - } - }, - { - "Key": "StackId", - "Value": { - "Fn::Sub": "${AWS::StackId}" - } - }, - { - "Key": "Stack", - "Value": { - "Fn::Sub": "${AWS::Region}-${AWS::StackName}" - } - }, - { - "Key": "Application", - "Value": { - "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" - } - } - ] - } - }, - "GraphRAGClientSecurityGroupToNeptuneEgress": { - "Type": "AWS::EC2::SecurityGroupEgress", - "Properties": { - "IpProtocol": "tcp", - "FromPort": 8182, - "ToPort": 8182, - "DestinationSecurityGroupId": { - "Fn::GetAtt": [ - "NeptuneSecurityGroup", - "GroupId" - ] - }, - "GroupId": { - "Fn::GetAtt": [ - "GraphRAGClientSecurityGroup", - "GroupId" - ] - } - } - }, - "GraphRAGClientSecurityGroupToPostgresEgress": { - "Type": "AWS::EC2::SecurityGroupEgress", - "Properties": { - "IpProtocol": "tcp", - "FromPort": 5432, - "ToPort": 5432, - "DestinationSecurityGroupId": { - "Fn::GetAtt": [ - "PostgresSecurityGroup", - "GroupId" - ] - }, - "GroupId": { - "Fn::GetAtt": [ - "GraphRAGClientSecurityGroup", - "GroupId" - ] - } - } - }, - "NeptuneSecurityGroupIngress": { - "Type": "AWS::EC2::SecurityGroupIngress", - "Properties": { - "IpProtocol": "tcp", - "FromPort": 8182, - "ToPort": 8182, - "SourceSecurityGroupId": { - "Fn::GetAtt": [ - "GraphRAGClientSecurityGroup", - "GroupId" - ] - }, - "GroupId": { - "Fn::GetAtt": [ - "NeptuneSecurityGroup", - "GroupId" - ] - } - } - }, - "PostgresSecurityGroupIngress": { - "Type": "AWS::EC2::SecurityGroupIngress", - "Properties": { - "IpProtocol": "tcp", - "FromPort": 5432, - "ToPort": 5432, - "SourceSecurityGroupId": { - "Fn::GetAtt": [ - "GraphRAGClientSecurityGroup", - "GroupId" - ] - }, - "GroupId": { - "Fn::GetAtt": [ - "PostgresSecurityGroup", - "GroupId" - ] - } - } - }, - "GraphRAGClientRole": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Principal": { - "Service": [ - "sagemaker.amazonaws.com" - ] - }, - "Action": [ - "sts:AssumeRole" - ] - } - ] - }, - "ManagedPolicyArns": { - "Fn::If": [ - "AddIamPolicyArn", - { - "Fn::Split": [ - " ", - { - "Ref": "IamPolicyArn" - } - ] - }, - [ - { - "Ref": "AWS::NoValue" - } - ] - ] - }, - "Path": "/graphrag-toolkit/" - } - }, - "GraphRAGClientRolePolicy": { - "Type": "AWS::IAM::ManagedPolicy", - "Properties": { - "ManagedPolicyName": { - "Fn::Sub": "${ApplicationId}-graphrag-client-policy" - }, - "PolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Sid": "S3ListBucketAndGetObject", - "Effect": "Allow", - "Action": [ - "s3:GetObject", - "s3:ListBucket" - ], - "Resource": [ - { - "Fn::If": [ - "IsIadRegion", - "arn:aws:s3:::aws-neptune-notebook", - { - "Fn::Sub": "arn:aws:s3:::aws-neptune-notebook-${AWS::Region}" - } - ] - }, - { - "Fn::If": [ - "IsIadRegion", - "arn:aws:s3:::aws-neptune-notebook/*", - { - "Fn::Sub": "arn:aws:s3:::aws-neptune-notebook-${AWS::Region}/*" - } - ] - } - ] - }, - { - "Sid": "LogGroupAccess", - "Effect": "Allow", - "Action": [ - "logs:CreateLogGroup", - "logs:CreateLogStream", - "logs:PutLogEvents" - ], - "Resource": [ - { - "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/sagemaker/*" - } - ] - }, - { - "Sid": "SageMakerNotebookAccess", - "Effect": "Allow", - "Action": "sagemaker:DescribeNotebookInstance", - "Resource": [ - { - "Fn::Sub": "arn:${AWS::Partition}:sagemaker:${AWS::Region}:${AWS::AccountId}:notebook-instance/*" - } - ] - } - ] - }, - "Roles": [ - { - "Ref": "GraphRAGClientRole" - } - ], - "Path": "/graphrag-toolkit/" - } - }, - "BedrockInvokeModelPolicy": { - "Type": "AWS::IAM::ManagedPolicy", - "Properties": { - "ManagedPolicyName": { - "Fn::Sub": "${ApplicationId}-bedrock-invoke-model-policy" - }, - "PolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Action": [ - "bedrock:InvokeModel", - "bedrock:InvokeModelWithResponseStream" - ], - "Resource": [ - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" - }, - { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-5-haiku-20241022-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" - }, - { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-7-sonnet-20250219-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0" - }, - { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" - }, + "ml.p3.2xlarge" + ], + "ConstraintDescription": "Must be a valid SageMaker instance type." + }, + "ExampleNotebooksURL": { + "Type": "String", + "Description": "URL of a zip file containing example notebooks to be installed on SageMaker instance (optional)", + "Default": "https://github.com/awslabs/graphrag-toolkit/releases/latest/download/lexical-graph-examples-latest.zip" + } + }, + "Metadata": { + "AWS::CloudFormation::Interface": { + "ParameterGroups": [ + { + "Label": { + "default": "Setup" + }, + "Parameters": [ + "ApplicationId" + ] + }, + { + "Label": { + "default": "Neptune" + }, + "Parameters": [ + "NeptuneEngineVersion", + "NeptuneDbInstanceType", + "MinNCU", + "MaxNCU", + "EnableAuditLog" + ] + }, + { + "Label": { + "default": "Aurora Postgres" + }, + "Parameters": [ + "PostgresDbInstanceType", + "MinACU", + "MaxACU" + ] + }, + { + "Label": { + "default": "Notebook" + }, + "Parameters": [ + "NotebookInstanceType", + "ExampleNotebooksURL", + "IamPolicyArn" + ] + } + ] + } + }, + "Conditions": { + "ExampleNotebooksURLIsNotBlank": { + "Fn::Not": [ + { + "Fn::Equals": [ + { + "Ref": "ExampleNotebooksURL" + }, + "" + ] + } + ] + }, + "IsS3ExampleNotebooksURL": { + "Fn::Equals": [ + { + "Fn::Select": [ + 0, + { + "Fn::Split": [ + ":", + { + "Ref": "ExampleNotebooksURL" + } + ] + } + ] + }, + "s3" + ] + }, + "IsIadRegion": { + "Fn::Equals": [ + { + "Ref": "AWS::Region" + }, + "us-east-1" + ] + }, + "AZ3NotPresent": { + "Fn::Or": [ + { + "Fn::Equals": [ + { + "Ref": "AWS::Region" + }, + "ca-central-1" + ] + }, + { + "Fn::Equals": [ + { + "Ref": "AWS::Region" + }, + "us-west-1" + ] + } + ] + }, + "AZ3Present": { + "Fn::Not": [ + { + "Condition": "AZ3NotPresent" + } + ] + }, + "AddIamPolicyArn": { + "Fn::Not": [ + { + "Fn::Equals": [ + { + "Ref": "IamPolicyArn" + }, + "" + ] + } + ] + }, + "AuditLogEnabled": { + "Fn::Equals": [ + { + "Ref": "EnableAuditLog" + }, + "true" + ] + } + }, + "Resources": { + "NeptuneDBSubnetGroup": { + "Type": "AWS::Neptune::DBSubnetGroup", + "Properties": { + "DBSubnetGroupDescription": "Neptune DB subnet group", + "DBSubnetGroupName": { + "Fn::Sub": "${ApplicationId}-neptune-subnet" + }, + "SubnetIds": { + "Fn::If": [ + "AZ3NotPresent", + [ + { + "Ref": "Subnet1" + }, + { + "Ref": "Subnet2" + } + ], + [ + { + "Ref": "Subnet1" + }, + { + "Ref": "Subnet2" + }, + { + "Ref": "Subnet3" + } + ] + ] + }, + "Tags": [ + { + "Key": "Name", + "Value": { + "Fn::Sub": "${ApplicationId}-neptune-subnet" + } + }, + { + "Key": "StackId", + "Value": { + "Fn::Sub": "${AWS::StackId}" + } + }, + { + "Key": "Stack", + "Value": { + "Fn::Sub": "${AWS::Region}-${AWS::StackName}" + } + }, + { + "Key": "Application", + "Value": { + "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" + } + } + ] + } + }, + "PostgresSubnetGroup": { + "Type": "AWS::RDS::DBSubnetGroup", + "Properties": { + "DBSubnetGroupDescription": "PostgreSQL subnet group", + "DBSubnetGroupName": { + "Fn::Sub": "${ApplicationId}-pg-subnet" + }, + "SubnetIds": { + "Fn::If": [ + "AZ3NotPresent", + [ + { + "Ref": "Subnet1" + }, + { + "Ref": "Subnet2" + } + ], + [ + { + "Ref": "Subnet1" + }, + { + "Ref": "Subnet2" + }, + { + "Ref": "Subnet3" + } + ] + ] + }, + "Tags": [ + { + "Key": "Name", + "Value": { + "Fn::Sub": "${ApplicationId}-pg- subnet" + } + }, + { + "Key": "StackId", + "Value": { + "Fn::Sub": "${AWS::StackId}" + } + }, + { + "Key": "Stack", + "Value": { + "Fn::Sub": "${AWS::Region}-${AWS::StackName}" + } + }, + { + "Key": "Application", + "Value": { + "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" + } + } + ] + } + }, + "GraphRAGClientSecurityGroup": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupName": { + "Fn::Sub": "${ApplicationId}-client-sg" + }, + "VpcId": { + "Ref": "VPC" + }, + "GroupDescription": "GraphRAG client security group", + "SecurityGroupEgress": [ + { + "FromPort": "443", + "ToPort": "443", + "IpProtocol": "tcp", + "CidrIp": "0.0.0.0/0", + "Description": "HTTPS egress" + } + ], + "Tags": [ + { + "Key": "Name", + "Value": { + "Fn::Sub": "${ApplicationId}-client-sg" + } + }, + { + "Key": "StackId", + "Value": { + "Fn::Sub": "${AWS::StackId}" + } + }, + { + "Key": "Stack", + "Value": { + "Fn::Sub": "${AWS::Region}-${AWS::StackName}" + } + }, + { + "Key": "Application", + "Value": { + "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" + } + } + ] + } + }, + "NeptuneSecurityGroup": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupName": { + "Fn::Sub": "${ApplicationId}-neptune-sg" + }, + "VpcId": { + "Ref": "VPC" + }, + "GroupDescription": "GraphRAG Neptune security group", + "Tags": [ + { + "Key": "Name", + "Value": { + "Fn::Sub": "${ApplicationId}-neptune-sg" + } + }, + { + "Key": "StackId", + "Value": { + "Fn::Sub": "${AWS::StackId}" + } + }, + { + "Key": "Stack", + "Value": { + "Fn::Sub": "${AWS::Region}-${AWS::StackName}" + } + }, + { + "Key": "Application", + "Value": { + "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" + } + } + ] + } + }, + "PostgresSecurityGroup": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupName": { + "Fn::Sub": "${ApplicationId}-pg-sg" + }, + "VpcId": { + "Ref": "VPC" + }, + "GroupDescription": "PostgreSQL security group", + "Tags": [ + { + "Key": "Name", + "Value": { + "Fn::Sub": "${ApplicationId}-pg-sg" + } + }, + { + "Key": "StackId", + "Value": { + "Fn::Sub": "${AWS::StackId}" + } + }, + { + "Key": "Stack", + "Value": { + "Fn::Sub": "${AWS::Region}-${AWS::StackName}" + } + }, + { + "Key": "Application", + "Value": { + "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" + } + } + ] + } + }, + "GraphRAGClientSecurityGroupToNeptuneEgress": { + "Type": "AWS::EC2::SecurityGroupEgress", + "Properties": { + "IpProtocol": "tcp", + "FromPort": 8182, + "ToPort": 8182, + "DestinationSecurityGroupId": { + "Fn::GetAtt": [ + "NeptuneSecurityGroup", + "GroupId" + ] + }, + "GroupId": { + "Fn::GetAtt": [ + "GraphRAGClientSecurityGroup", + "GroupId" + ] + } + } + }, + "GraphRAGClientSecurityGroupToPostgresEgress": { + "Type": "AWS::EC2::SecurityGroupEgress", + "Properties": { + "IpProtocol": "tcp", + "FromPort": 5432, + "ToPort": 5432, + "DestinationSecurityGroupId": { + "Fn::GetAtt": [ + "PostgresSecurityGroup", + "GroupId" + ] + }, + "GroupId": { + "Fn::GetAtt": [ + "GraphRAGClientSecurityGroup", + "GroupId" + ] + } + } + }, + "NeptuneSecurityGroupIngress": { + "Type": "AWS::EC2::SecurityGroupIngress", + "Properties": { + "IpProtocol": "tcp", + "FromPort": 8182, + "ToPort": 8182, + "SourceSecurityGroupId": { + "Fn::GetAtt": [ + "GraphRAGClientSecurityGroup", + "GroupId" + ] + }, + "GroupId": { + "Fn::GetAtt": [ + "NeptuneSecurityGroup", + "GroupId" + ] + } + } + }, + "PostgresSecurityGroupIngress": { + "Type": "AWS::EC2::SecurityGroupIngress", + "Properties": { + "IpProtocol": "tcp", + "FromPort": 5432, + "ToPort": 5432, + "SourceSecurityGroupId": { + "Fn::GetAtt": [ + "GraphRAGClientSecurityGroup", + "GroupId" + ] + }, + "GroupId": { + "Fn::GetAtt": [ + "PostgresSecurityGroup", + "GroupId" + ] + } + } + }, + "GraphRAGClientRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Principal": { + "Service": [ + "sagemaker.amazonaws.com" + ] + }, + "Action": [ + "sts:AssumeRole" + ] + } + ] + }, + "ManagedPolicyArns": { + "Fn::If": [ + "AddIamPolicyArn", + { + "Fn::Split": [ + " ", + { + "Ref": "IamPolicyArn" + } + ] + }, + [ + { + "Ref": "AWS::NoValue" + } + ] + ] + }, + "Path": "/graphrag-toolkit/" + } + }, + "GraphRAGClientRolePolicy": { + "Type": "AWS::IAM::ManagedPolicy", + "Properties": { + "ManagedPolicyName": { + "Fn::Sub": "${ApplicationId}-graphrag-client-policy" + }, + "PolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "S3ListBucketAndGetObject", + "Effect": "Allow", + "Action": [ + "s3:GetObject", + "s3:ListBucket" + ], + "Resource": [ + { + "Fn::If": [ + "IsIadRegion", + "arn:aws:s3:::aws-neptune-notebook", + { + "Fn::Sub": "arn:aws:s3:::aws-neptune-notebook-${AWS::Region}" + } + ] + }, + { + "Fn::If": [ + "IsIadRegion", + "arn:aws:s3:::aws-neptune-notebook/*", + { + "Fn::Sub": "arn:aws:s3:::aws-neptune-notebook-${AWS::Region}/*" + } + ] + } + ] + }, + { + "Sid": "LogGroupAccess", + "Effect": "Allow", + "Action": [ + "logs:CreateLogGroup", + "logs:CreateLogStream", + "logs:PutLogEvents" + ], + "Resource": [ + { + "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/sagemaker/*" + } + ] + }, + { + "Sid": "SageMakerNotebookAccess", + "Effect": "Allow", + "Action": "sagemaker:DescribeNotebookInstance", + "Resource": [ + { + "Fn::Sub": "arn:${AWS::Partition}:sagemaker:${AWS::Region}:${AWS::AccountId}:notebook-instance/*" + } + ] + } + ] + }, + "Roles": [ + { + "Ref": "GraphRAGClientRole" + } + ], + "Path": "/graphrag-toolkit/" + } + }, + "BedrockInvokeModelPolicy": { + "Type": "AWS::IAM::ManagedPolicy", + "Properties": { + "ManagedPolicyName": { + "Fn::Sub": "${ApplicationId}-bedrock-invoke-model-policy" + }, + "PolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "bedrock:InvokeModel", + "bedrock:InvokeModelWithResponseStream" + ], + "Resource": [ + { + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" + }, + { + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" + }, + { + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" + }, + { + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" + }, + { + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" + }, + { + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" + }, + { + "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" + }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.rerank-v3-5:0" } @@ -796,15 +718,15 @@ "Effect": "Allow" } ] - }, - "Roles": [ - { - "Ref": "GraphRAGClientRole" - } - ], - "Path": "/graphrag-toolkit/" - } - }, + }, + "Roles": [ + { + "Ref": "GraphRAGClientRole" + } + ], + "Path": "/graphrag-toolkit/" + } + }, "NeptuneDBDataAccessQueryingPolicy": { "Type": "AWS::IAM::ManagedPolicy", "Properties": { @@ -917,1488 +839,1320 @@ "Path": "/graphrag-toolkit/" } }, - "PostgresDataAccessPolicy": { - "Type": "AWS::IAM::ManagedPolicy", - "Properties": { - "ManagedPolicyName": { - "Fn::Sub": "${ApplicationId}-pg-db-policy" - }, - "PolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Action": [ - "rds-db:connect" - ], - "Resource": { - "Fn::Join": [ - "", - [ - { - "Fn::Sub": "arn:${AWS::Partition}:rds-db:" - }, - { - "Ref": "AWS::Region" - }, - ":", - { - "Ref": "AWS::AccountId" - }, - ":dbuser:", - { - "Fn::GetAtt": [ - "PostgresCluster", - "DBClusterResourceId" - ] - }, - "/graphrag" - ] - ] - } - } - ] - }, - "Roles": [ - { - "Ref": "GraphRAGClientRole" - } - ], - "Path": "/graphrag-toolkit/" - } - }, - "PostgresClusterParameterGroup": { - "Type": "AWS::RDS::DBClusterParameterGroup", - "Properties": { - "DBClusterParameterGroupName": { - "Fn::Sub": "pg-cluster-params-${ApplicationId}" - }, - "Description": "PostgreSQL cluster parameter group", - "Family": "aurora-postgresql16", - "Parameters": { - "client_encoding": "UTF8" - }, - "Tags": [ - { - "Key": "Name", - "Value": { - "Fn::Sub": "pg-cluster-params-${ApplicationId}" - } - }, - { - "Key": "StackId", - "Value": { - "Fn::Sub": "${AWS::StackName}" - } - }, - { - "Key": "Stack", - "Value": { - "Fn::Sub": "${AWS::Region}-${AWS::StackId}" - } - }, - { - "Key": "Application", - "Value": { - "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" - } - } - ] - } - }, - "PostgresDBParameterGroup": { - "Type": "AWS::RDS::DBParameterGroup", - "Properties": { - "DBParameterGroupName": { - "Fn::Sub": "pg-params-${ApplicationId}" - }, - "Description": "PostgreSQL parameter group", - "Family": "aurora-postgresql16", - "Tags": [ - { - "Key": "Name", - "Value": { - "Fn::Sub": "pg-params-${ApplicationId}" - } - }, - { - "Key": "StackId", - "Value": { - "Fn::Sub": "${AWS::StackName}" - } - }, - { - "Key": "Stack", - "Value": { - "Fn::Sub": "${AWS::Region}-${AWS::StackId}" - } - }, - { - "Key": "Application", - "Value": { - "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" - } - } - ] - } - }, - "PostgresCluster": { - "UpdateReplacePolicy": "Snapshot", - "Type": "AWS::RDS::DBCluster", - "Properties": { - "DBClusterIdentifier": { - "Fn::Sub": "${ApplicationId}-pg-cluster" - }, - "DBClusterParameterGroupName": { - "Ref": "PostgresClusterParameterGroup" - }, - "DBSubnetGroupName": { - "Ref": "PostgresSubnetGroup" - }, - "DatabaseName": "postgres", - "EnableHttpEndpoint": true, - "EnableIAMDatabaseAuthentication": true, - "Engine": "aurora-postgresql", - "EngineVersion": "16.6", - "Port": "5432", - "ManageMasterUserPassword": true, - "MasterUsername": "pgmasteruser", - "ServerlessV2ScalingConfiguration": { - "MaxCapacity": { - "Ref": "MaxACU" - }, - "MinCapacity": { - "Ref": "MinACU" - }, - "SecondsUntilAutoPause": 3600 - }, - "StorageEncrypted": true, - "Tags": [ - { - "Key": "Name", - "Value": { - "Fn::Sub": "${ApplicationId}-pg-cluster" - } - }, - { - "Key": "StackId", - "Value": { - "Fn::Sub": "${AWS::StackId}" - } - }, - { - "Key": "Stack", - "Value": { - "Fn::Sub": "${AWS::Region}-${AWS::StackName}" - } - }, - { - "Key": "Application", - "Value": { - "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" - } - } - ], - "VpcSecurityGroupIds": [ - { - "Ref": "PostgresSecurityGroup" - } - ] - }, - "DependsOn": [ - "PostgresSubnetGroup", - "PostgresClusterParameterGroup" - ] - }, - "PostgresInstance": { - "Type": "AWS::RDS::DBInstance", - "Properties": { - "DBClusterIdentifier": { - "Ref": "PostgresCluster" - }, - "DBInstanceClass": { - "Ref": "PostgresDbInstanceType" - }, - "DBInstanceIdentifier": { - "Fn::Sub": "${ApplicationId}-pg-db-1" - }, - "Engine": "aurora-postgresql", - "EngineVersion": "16.6", - "AutoMinorVersionUpgrade": true, - "Tags": [ - { - "Key": "Name", - "Value": { - "Fn::Sub": "${ApplicationId}-pg-db-1" - } - }, - { - "Key": "StackId", - "Value": { - "Fn::Sub": "${AWS::StackId}" - } - }, - { - "Key": "Stack", - "Value": { - "Fn::Sub": "${AWS::Region}-${AWS::StackName}" - } - }, - { - "Key": "Application", - "Value": { - "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" - } - } - ] - }, - "DependsOn": [ - "PostgresCluster", - "PostgresDBParameterGroup" - ] - }, - "NeptuneDBClusterParameterGroup": { - "Type": "AWS::Neptune::DBClusterParameterGroup", - "Properties": { - "Name": { - "Fn::Sub": "neptune-cluster-params-${ApplicationId}" - }, - "Family": "neptune1.4", - "Description": "Neptune cluster parameter group", - "Parameters": { - "neptune_enable_audit_log": { - "Fn::If": [ - "AuditLogEnabled", - 1, - 0 - ] - } - }, - "Tags": [ - { - "Key": "Name", - "Value": { - "Fn::Sub": "neptune-cluster-params-${ApplicationId}" - } - }, - { - "Key": "StackId", - "Value": { - "Fn::Sub": "${AWS::StackName}" - } - }, - { - "Key": "Stack", - "Value": { - "Fn::Sub": "${AWS::Region}-${AWS::StackId}" - } - }, - { - "Key": "Application", - "Value": { - "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" - } - } - ] - } - }, - "NeptuneDBParameterGroup": { - "Type": "AWS::Neptune::DBParameterGroup", - "Properties": { - "Name": { - "Fn::Sub": "neptune-params-${ApplicationId}" - }, - "Family": "neptune1.4", - "Description": "Neptune parameter group", - "Parameters": { - "neptune_query_timeout": 60000 - }, - "Tags": [ - { - "Key": "Name", - "Value": { - "Fn::Sub": "neptune-params-${ApplicationId}" - } - }, - { - "Key": "StackId", - "Value": { - "Fn::Sub": "${AWS::StackId}" - } - }, - { - "Key": "Stack", - "Value": { - "Fn::Sub": "${AWS::Region}-${AWS::StackName}" - } - }, - { - "Key": "Application", - "Value": { - "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" - } - } - ] - } - }, - "NeptuneDBCluster": { - "Type": "AWS::Neptune::DBCluster", - "Properties": { - "DBClusterIdentifier": { - "Fn::Sub": "${ApplicationId}-neptune-cluster" - }, - "EngineVersion": { - "Ref": "NeptuneEngineVersion" - }, - "DBSubnetGroupName": { - "Ref": "NeptuneDBSubnetGroup" - }, - "VpcSecurityGroupIds": [ - { - "Ref": "NeptuneSecurityGroup" - } - ], - "DBClusterParameterGroupName": { - "Ref": "NeptuneDBClusterParameterGroup" - }, - "Port": "8182", - "IamAuthEnabled": true, - "ServerlessScalingConfiguration": { - "MaxCapacity": { - "Ref": "MaxNCU" - }, - "MinCapacity": { - "Ref": "MinNCU" - } - }, - "StorageEncrypted": true, - "Tags": [ - { - "Key": "Name", - "Value": { - "Fn::Sub": "${ApplicationId}-neptune-cluster" - } - }, - { - "Key": "StackId", - "Value": { - "Fn::Sub": "${AWS::StackId}" - } - }, - { - "Key": "Stack", - "Value": { - "Fn::Sub": "${AWS::Region}-${AWS::StackName}" - } - }, - { - "Key": "Application", - "Value": { - "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" - } - } - ] - }, - "DependsOn": [ - "NeptuneDBSubnetGroup", - "NeptuneDBClusterParameterGroup" - ] - }, - "NeptuneDBInstance": { - "Type": "AWS::Neptune::DBInstance", - "Properties": { - "DBInstanceIdentifier": { - "Fn::Sub": "${ApplicationId}-neptune-db-1" - }, - "DBClusterIdentifier": { - "Ref": "NeptuneDBCluster" - }, - "DBInstanceClass": { - "Ref": "NeptuneDbInstanceType" - }, - "DBParameterGroupName": { - "Ref": "NeptuneDBParameterGroup" - }, - "AutoMinorVersionUpgrade": true, - "Tags": [ - { - "Key": "Name", - "Value": { - "Fn::Sub": "${ApplicationId}-neptune-db-1" - } - }, - { - "Key": "StackId", - "Value": { - "Fn::Sub": "${AWS::StackId}" - } - }, - { - "Key": "Stack", - "Value": { - "Fn::Sub": "${AWS::Region}-${AWS::StackName}" - } - }, - { - "Key": "Application", - "Value": { - "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" - } - } - ] - }, - "DependsOn": [ - "NeptuneDBCluster", - "NeptuneDBParameterGroup" - ] - }, - "NeptuneNotebookInstance": { - "Type": "AWS::SageMaker::NotebookInstance", - "Properties": { - "InstanceType": { - "Ref": "NotebookInstanceType" - }, - "PlatformIdentifier": "notebook-al2-v3", - "NotebookInstanceName": { - "Fn::Sub": "aws-neptune-${ApplicationId}" - }, - "SubnetId": { - "Ref": "Subnet4" - }, - "SecurityGroupIds": [ - { - "Ref": "GraphRAGClientSecurityGroup" - } - ], - "RoleArn": { - "Fn::GetAtt": [ - "GraphRAGClientRole", - "Arn" - ] - }, - "LifecycleConfigName": { - "Fn::GetAtt": [ - "NeptuneNotebookInstanceLifecycleConfig", - "NotebookInstanceLifecycleConfigName" - ] - }, - "Tags": [ - { - "Key": "StackId", - "Value": { - "Fn::Sub": "${AWS::StackId}" - } - }, - { - "Key": "Stack", - "Value": { - "Fn::Sub": "${AWS::Region}-${AWS::StackName}" - } - }, - { - "Key": "Application", - "Value": { - "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" - } - } - ] - } - }, - "NeptuneNotebookInstanceLifecycleConfig": { - "Type": "AWS::SageMaker::NotebookInstanceLifecycleConfig", - "Properties": { - "OnStart": [ - { - "Content": { - "Fn::Base64": { - "Fn::Join": [ - "", - [ - "#!/bin/bash\n\n", - "sudo -u ec2-user -i <<'EOF'\n", - "\n", - "sudo pip install packaging==24.2\n", - "echo \"export STACK_ID=", - { - "Ref": "AWS::StackId" - }, - "\" >> ~/.bashrc\n", - "echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, - "\" >> ~/.bashrc\n", - "echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> ~/.bashrc\n", - "echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> ~/.bashrc\n", - "echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, - "\" >> ~/.bashrc\n", - "echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, - "\" >> ~/.bashrc\n", - "echo \"export GRAPH_NOTEBOOK_AUTH_MODE=IAM\" >> ~/.bashrc\n", - "echo \"export GRAPH_NOTEBOOK_SSL=True\" >> ~/.bashrc\n", - "echo \"export GRAPH_NOTEBOOK_IAM_PROVIDER=ROLE\" >> ~/.bashrc\n", - "echo \"export GRAPH_NOTEBOOK_PORT=", - { - "Fn::GetAtt": [ - "NeptuneDBCluster", - "Port" - ] - }, - "\" >> ~/.bashrc\n", - "echo \"export GRAPH_STORE=", - { - "Fn::Sub": [ - "neptune-db://${graphid}", - { - "graphid": { - "Fn::GetAtt": [ - "NeptuneDBCluster", - "Endpoint" - ] - } - } - ] - }, - "\" >> ~/.bashrc\n", - "echo \"export VECTOR_STORE=", - { - "Fn::Sub": [ - "postgresql://graphrag@${endpoint}:${port}/postgres?enable_iam_db_auth=True", - { - "endpoint": { - "Fn::GetAtt": [ - "PostgresCluster", - "Endpoint.Address" - ] - }, - "port": { - "Fn::GetAtt": [ - "PostgresCluster", - "Endpoint.Port" - ] - } - } - ] - }, - "\" >> ~/.bashrc\n", - "echo \"export GRAPH_NOTEBOOK_SERVICE=neptune-db\" >> ~/.bashrc\n", - "echo \"export GRAPH_NOTEBOOK_HOST=", - { - "Fn::GetAtt": [ - "NeptuneDBCluster", - "Endpoint" - ] - }, - "\" >> ~/.bashrc\n", - "echo \"export AWS_REGION=", - { - "Ref": "AWS::Region" - }, - "\" >> ~/.bashrc\n\n", - "aws s3 cp s3://", - { - "Fn::If": [ - "IsIadRegion", - "aws-neptune-notebook", - { - "Fn::Sub": "aws-neptune-notebook-${AWS::Region}" - } - ] - }, - "/graph_notebook.tar.gz /tmp/graph_notebook.tar.gz\n", - "rm -rf /tmp/graph_notebook\n", - "tar -zxvf /tmp/graph_notebook.tar.gz -C /tmp\n", - "chmod +x /tmp/graph_notebook/install_jl4x.sh\n", - "/tmp/graph_notebook/install_jl4x.sh\n", - "\n", - "cd /home/ec2-user/SageMaker\n", - "if [ ! -d graphrag-toolkit ]; then\n", - " mkdir graphrag-toolkit\n", - " chmod -R 777 graphrag-toolkit\n", - { - "Fn::If": [ - "ExampleNotebooksURLIsNotBlank", - { - "Fn::If": [ - "IsS3ExampleNotebooksURL", - { - "Fn::Join": [ - "", - [ - " aws s3 cp \"", - { - "Ref": "ExampleNotebooksURL" - }, - "\" lexical-graph-examples.zip\n", - " unzip lexical-graph-examples.zip -d graphrag-toolkit\n", - " rm -rf lexical-graph-examples.zip\n" - ] - ] - }, - { - "Fn::Join": [ - "", - [ - " curl -L \"", - { - "Ref": "ExampleNotebooksURL" - }, - "\" -o \"lexical-graph-examples.zip\"\n", - " unzip lexical-graph-examples.zip -d graphrag-toolkit\n", - " rm -rf lexical-graph-examples.zip\n" - ] - ] - } - ] - }, - { - "Ref": "AWS::NoValue" - } - ] - }, - " cd graphrag-toolkit\n", - " echo \"export STACK_ID=", - { - "Ref": "AWS::StackId" - }, - "\" >> .env\n", - " echo \"export GRAPH_STORE=", - { - "Fn::Sub": [ - "neptune-db://${graphid}", - { - "graphid": { - "Fn::GetAtt": [ - "NeptuneDBCluster", - "Endpoint" - ] - } - } - ] - }, - "\" >> .env\n", - " echo \"export VECTOR_STORE=", - { - "Fn::Sub": [ - "postgresql://graphrag@${endpoint}:${port}/postgres?enable_iam_db_auth=True", - { - "endpoint": { - "Fn::GetAtt": [ - "PostgresCluster", - "Endpoint.Address" - ] - }, - "port": { - "Fn::GetAtt": [ - "PostgresCluster", - "Endpoint.Port" - ] - } - } - ] - }, - "\" >> .env\n", - " echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, - "\" >> .env\n", - " echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> .env\n", - " echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> .env\n", - " echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, - "\" >> .env\n", - " echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, - "\" >> .env\n", - " if [ -f \"./run_test_suite.sh\" ]\n", - " then\n", - " echo \"Running test suite\"\n", - " screen -L -m -d sh run_test_suite.sh\n", - " else\n", - " echo \"No test suite\"\n", - " fi\n", - "fi\n", - "EOF" - ] - ] - } - } - } - ] - } - }, - "InitPostgresFunctionRole": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Principal": { - "Service": [ - "lambda.amazonaws.com" - ] - }, - "Action": [ - "sts:AssumeRole" - ] - } - ] - }, - "Path": "/graphrag-toolkit/", - "Policies": [ - { - "PolicyName": "root", - "PolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Action": "logs:CreateLogGroup", - "Resource": { - "Fn::Join": [ - "", - [ - { - "Fn::Sub": "arn:${AWS::Partition}:logs:" - }, - { - "Ref": "AWS::Region" - }, - ":", - { - "Ref": "AWS::AccountId" - }, - ":*" - ] - ] - } - }, - { - "Effect": "Allow", - "Action": [ - "logs:CreateLogStream", - "logs:PutLogEvents" - ], - "Resource": { - "Fn::Join": [ - "", - [ - { - "Fn::Sub": "arn:${AWS::Partition}:logs:" - }, - { - "Ref": "AWS::Region" - }, - ":", - { - "Ref": "AWS::AccountId" - }, - ":log-group:/aws/lambda/", - { - "Fn::Sub": "${ApplicationId}-init-pg" - }, - ":*" - ] - ] - } - }, - { - "Effect": "Allow", - "Action": [ - "secretsmanager:GetSecretValue" - ], - "Resource": { - "Fn::GetAtt": [ - "PostgresCluster", - "MasterUserSecret.SecretArn" - ] - } - }, - { - "Effect": "Allow", - "Action": [ - "rds-data:BatchExecuteStatement", - "rds-data:BeginTransaction", - "rds-data:CommitTransaction", - "rds-data:ExecuteStatement", - "rds-data:RollbackTransaction" - ], - "Resource": { - "Fn::Join": [ - "", - [ - { - "Fn::Sub": "arn:${AWS::Partition}:rds:" - }, - { - "Ref": "AWS::Region" - }, - ":", - { - "Ref": "AWS::AccountId" - }, - ":cluster:", - { - "Ref": "PostgresCluster" - } - ] - ] - } - } - ] - } - } - ] - } - }, - "InitPostgresFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "FunctionName": { - "Fn::Sub": "${ApplicationId}-init-pg" - }, - "Handler": "index.lambda_handler", - "Role": { - "Fn::GetAtt": [ - "InitPostgresFunctionRole", - "Arn" - ] - }, - "Code": { - "ZipFile": { - "Fn::Join": [ - "", - [ - "import json\n", - "import boto3\n", - "import cfnresponse\n", - "import logging\n", - "\n", - "logger = logging.getLogger()\n", - "logger.setLevel(logging.INFO)\n", - "\n", - "rds_data = boto3.client('rds-data')\n", - " \n", - "def execute_sql(sql, cluster_arn, secret_arn):\n", - " rds_data.execute_statement(\n", - " resourceArn = cluster_arn,\n", - " secretArn = secret_arn,\n", - " database = 'postgres',\n", - " sql = sql\n", - " )\n", - "\n", - "def lambda_handler(event, context):\n", - " \n", - " logger.info('Event: {}'.format(event))\n", - " logger.info('Context: {}'.format(context))\n", - " \n", - " cluster_arn = event['ResourceProperties']['ClusterArn']\n", - " secret_arn = event['ResourceProperties']['SecretArn']\n", - " \n", - " if event['RequestType'] == 'Create' or event['RequestType'] == 'Update':\n", - " \n", - " try:\n", - " \n", - " logger.info('Begin Postgres setup')\n", - "\n", - " execute_sql('CREATE EXTENSION IF NOT EXISTS vector;', cluster_arn, secret_arn)\n", - " execute_sql(\"\"\"DO\n", - " $$\n", - " BEGIN\n", - " IF NOT EXISTS (SELECT * FROM pg_user WHERE usename = 'graphrag') THEN\n", - " CREATE USER graphrag;\n", - " END IF;\n", - " END\n", - " $$\n", - " ;\n", - " \"\"\", cluster_arn, secret_arn)\n", - " execute_sql('CREATE SCHEMA IF NOT EXISTS graphrag;', cluster_arn, secret_arn)\n", - " execute_sql('GRANT CONNECT ON DATABASE postgres TO graphrag;', cluster_arn, secret_arn)\n", - " execute_sql('GRANT ALL PRIVILEGES ON SCHEMA graphrag TO graphrag;', cluster_arn, secret_arn)\n", - " execute_sql('GRANT rds_iam TO graphrag;', cluster_arn, secret_arn)\n", - " \n", - " logger.info('Postgres setup complete')\n", - " \n", - " cfnresponse.send(event, \n", - " context, \n", - " cfnresponse.SUCCESS, \n", - " {\n", - " 'ClusterArn': cluster_arn, \n", - " }, \n", - " context.log_stream_name\n", - " )\n", - " \n", - " except Exception as e:\n", - " cfnresponse.send(event, context, cfnresponse.FAILED, { 'Message': str(e) }, context.log_stream_name)\n", - " \n", - " elif event['RequestType'] == 'Delete':\n", - " \n", - " logger.info('Delet request - do nothing')\n", - " \n", - " cfnresponse.send(event, \n", - " context, \n", - " cfnresponse.SUCCESS, \n", - " {\n", - " 'ClusterArn': cluster_arn, \n", - " }, \n", - " context.log_stream_name\n", - " )\n", - " \n", - " else:\n", - " cfnresponse.send(event, context, cfnresponse.FAILED, { 'Message': 'Expected a Create, Delete or Update request' }, context.log_stream_name)\n" - ] - ] - } - }, - "MemorySize": 128, - "Runtime": "python3.13", - "Timeout": "900" - } - }, - "CustomInitPostgres": { - "Type": "Custom::CustomResource", - "Properties": { - "ServiceToken": { - "Fn::GetAtt": [ - "InitPostgresFunction", - "Arn" - ] - }, - "ClusterArn": { - "Fn::GetAtt": [ - "PostgresCluster", - "DBClusterArn" - ] - }, - "SecretArn": { - "Fn::GetAtt": [ - "PostgresCluster", - "MasterUserSecret.SecretArn" - ] - } - }, - "DependsOn": [ - "PostgresInstance" - ] - }, - "ElasticIP1": { - "Type": "AWS::EC2::EIP", - "Properties": { - "Domain": "VPC" - } - }, - "VPC": { - "Type": "AWS::EC2::VPC", - "Properties": { - "CidrBlock": "172.30.0.0/16", - "EnableDnsSupport": "true", - "EnableDnsHostnames": "true", - "Tags": [ - { - "Key": "Name", - "Value": { - "Fn::Sub": "${ApplicationId}-vpc" - } - }, - { - "Key": "StackId", - "Value": { - "Fn::Sub": "${AWS::StackId}" - } - }, - { - "Key": "Stack", - "Value": { - "Fn::Sub": "${AWS::Region}-${AWS::StackName}" - } - } - ] - } - }, - "PublicRouteTable": { - "Type": "AWS::EC2::RouteTable", - "Properties": { - "VpcId": { - "Ref": "VPC" - } - }, - "DependsOn": [ - "VPC" - ] - }, - "PrivateRouteTable": { - "Type": "AWS::EC2::RouteTable", - "Properties": { - "VpcId": { - "Ref": "VPC" - } - }, - "DependsOn": [ - "VPC" - ] - }, - "IGWAtt": { - "Type": "AWS::EC2::VPCGatewayAttachment", - "Properties": { - "InternetGatewayId": { - "Ref": "IGW" - }, - "VpcId": { - "Ref": "VPC" - } - }, - "DependsOn": [ - "VPC", - "IGW" - ] - }, - "IGW": { - "Type": "AWS::EC2::InternetGateway", - "Properties": { - "Tags": [ - { - "Key": "Name", - "Value": { - "Fn::Sub": "${ApplicationId}-igw" - } - }, - { - "Key": "StackId", - "Value": { - "Fn::Sub": "${AWS::StackId}" - } - }, - { - "Key": "Stack", - "Value": { - "Fn::Sub": "${AWS::Region}-${AWS::StackName}" - } - }, - { - "Key": "Application", - "Value": { - "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" - } - } - ] - } - }, - "NATGW": { - "Type": "AWS::EC2::NatGateway", - "Properties": { - "AllocationId": { - "Fn::GetAtt": [ - "ElasticIP1", - "AllocationId" - ] - }, - "SubnetId": { - "Ref": "Subnet4" - } - } - }, - "PublicRoute": { - "Type": "AWS::EC2::Route", - "Properties": { - "DestinationCidrBlock": "0.0.0.0/0", - "GatewayId": { - "Ref": "IGW" - }, - "RouteTableId": { - "Ref": "PublicRouteTable" - } - }, - "DependsOn": [ - "IGWAtt" - ] - }, - "PrivateRoute": { - "Type": "AWS::EC2::Route", - "Properties": { - "DestinationCidrBlock": "0.0.0.0/0", - "NatGatewayId": { - "Ref": "NATGW" - }, - "RouteTableId": { - "Ref": "PrivateRouteTable" - } - }, - "DependsOn": [ - "IGWAtt" - ] - }, - "Subnet1": { - "Type": "AWS::EC2::Subnet", - "Properties": { - "CidrBlock": "172.30.1.0/24", - "VpcId": { - "Ref": "VPC" - }, - "AvailabilityZone": { - "Fn::Select": [ - 0, - { - "Fn::GetAZs": "" - } - ] - } - } - }, - "Subnet2": { - "Type": "AWS::EC2::Subnet", - "Properties": { - "CidrBlock": "172.30.2.0/24", - "VpcId": { - "Ref": "VPC" - }, - "AvailabilityZone": { - "Fn::Select": [ - 1, - { - "Fn::GetAZs": "" - } - ] - } - } - }, - "Subnet3": { - "Type": "AWS::EC2::Subnet", - "Condition": "AZ3Present", - "Properties": { - "CidrBlock": "172.30.3.0/24", - "VpcId": { - "Ref": "VPC" - }, - "AvailabilityZone": { - "Fn::Select": [ - 2, - { - "Fn::GetAZs": "" - } - ] - } - } - }, - "Subnet4": { - "Type": "AWS::EC2::Subnet", - "Properties": { - "CidrBlock": "172.30.4.0/24", - "MapPublicIpOnLaunch": "true", - "VpcId": { - "Ref": "VPC" - }, - "AvailabilityZone": { - "Fn::Select": [ - 0, - { - "Fn::GetAZs": "" - } - ] - } - } - }, - "SubnetRTAssociation1": { - "Type": "AWS::EC2::SubnetRouteTableAssociation", - "DependsOn": [ - "Subnet1", - "PrivateRouteTable" - ], - "Properties": { - "RouteTableId": { - "Ref": "PrivateRouteTable" - }, - "SubnetId": { - "Ref": "Subnet1" - } - } - }, - "SubnetRTAssociation2": { - "Type": "AWS::EC2::SubnetRouteTableAssociation", - "DependsOn": [ - "Subnet2", - "PrivateRouteTable" - ], - "Properties": { - "RouteTableId": { - "Ref": "PrivateRouteTable" - }, - "SubnetId": { - "Ref": "Subnet2" - } - } - }, - "SubnetRTAssociation3": { - "Type": "AWS::EC2::SubnetRouteTableAssociation", - "Condition": "AZ3Present", - "DependsOn": [ - "Subnet3", - "PrivateRouteTable" - ], - "Properties": { - "RouteTableId": { - "Ref": "PrivateRouteTable" - }, - "SubnetId": { - "Ref": "Subnet3" - } - } - }, - "SubnetRTAssociation4": { - "Type": "AWS::EC2::SubnetRouteTableAssociation", - "DependsOn": [ - "Subnet4", - "PublicRouteTable" - ], - "Properties": { - "RouteTableId": { - "Ref": "PublicRouteTable" - }, - "SubnetId": { - "Ref": "Subnet4" - } - } - } - }, - "Outputs": { - "NeptuneClusterId": { - "Description": "Neptune cluster id", - "Value": { - "Ref": "NeptuneDBCluster" - } - }, - "NeptuneClusterEndpoint": { - "Description": "Neptune cluster endpoint", - "Value": { - "Fn::GetAtt": [ - "NeptuneDBCluster", - "Endpoint" - ] - } - }, - "PostgresClusterId": { - "Description": "Neptune cluster id", - "Value": { - "Ref": "PostgresCluster" - } - }, - "PostgresClusterEndpoint": { - "Description": "Postgres cluster endpoint", - "Value": { - "Fn::GetAtt": [ - "PostgresCluster", - "Endpoint.Address" - ] - } - }, - "GraphRAGClientSecurityGroup": { - "Description": "GraphRAG client security group", - "Value": { - "Ref": "GraphRAGClientSecurityGroup" - } - }, - "NeptuneSagemakerNotebook": { - "Description": "SageMaker notebook URL", - "Value": { - "Fn::Join": [ - "", - [ - "https://", - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "/", - { - "Ref": "NeptuneNotebookInstance" - } - ] - } - ] - }, - ".notebook.", - { - "Ref": "AWS::Region" - }, - ".sagemaker.aws/nbclassic/tree" - ] - ] - } - }, - "VPC": { - "Description": "VPC", - "Value": { - "Ref": "VPC" - } - } - } -} \ No newline at end of file + "PostgresDataAccessPolicy": { + "Type": "AWS::IAM::ManagedPolicy", + "Properties": { + "ManagedPolicyName": { + "Fn::Sub": "${ApplicationId}-pg-db-policy" + }, + "PolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "rds-db:connect" + ], + "Resource": { + "Fn::Join": [ + "", + [ + { + "Fn::Sub": "arn:${AWS::Partition}:rds-db:" + }, + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":dbuser:", + { + "Fn::GetAtt": [ + "PostgresCluster", + "DBClusterResourceId" + ] + }, + "/graphrag" + ] + ] + } + } + ] + }, + "Roles": [ + { + "Ref": "GraphRAGClientRole" + } + ], + "Path": "/graphrag-toolkit/" + } + }, + "PostgresClusterParameterGroup": { + "Type": "AWS::RDS::DBClusterParameterGroup", + "Properties": { + "DBClusterParameterGroupName": { + "Fn::Sub": "pg-cluster-params-${ApplicationId}" + }, + "Description": "PostgreSQL cluster parameter group", + "Family": "aurora-postgresql16", + "Parameters": { + "client_encoding": "UTF8" + }, + "Tags": [ + { + "Key": "Name", + "Value": { + "Fn::Sub": "pg-cluster-params-${ApplicationId}" + } + }, + { + "Key": "StackId", + "Value": { + "Fn::Sub": "${AWS::StackName}" + } + }, + { + "Key": "Stack", + "Value": { + "Fn::Sub": "${AWS::Region}-${AWS::StackId}" + } + }, + { + "Key": "Application", + "Value": { + "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" + } + } + ] + } + }, + "PostgresDBParameterGroup": { + "Type": "AWS::RDS::DBParameterGroup", + "Properties": { + "DBParameterGroupName": { + "Fn::Sub": "pg-params-${ApplicationId}" + }, + "Description": "PostgreSQL parameter group", + "Family": "aurora-postgresql16", + "Tags": [ + { + "Key": "Name", + "Value": { + "Fn::Sub": "pg-params-${ApplicationId}" + } + }, + { + "Key": "StackId", + "Value": { + "Fn::Sub": "${AWS::StackName}" + } + }, + { + "Key": "Stack", + "Value": { + "Fn::Sub": "${AWS::Region}-${AWS::StackId}" + } + }, + { + "Key": "Application", + "Value": { + "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" + } + } + ] + } + }, + "PostgresCluster": { + "UpdateReplacePolicy": "Snapshot", + "Type": "AWS::RDS::DBCluster", + "Properties": { + "DBClusterIdentifier": { + "Fn::Sub": "${ApplicationId}-pg-cluster" + }, + "DBClusterParameterGroupName": { + "Ref": "PostgresClusterParameterGroup" + }, + "DBSubnetGroupName": { + "Ref": "PostgresSubnetGroup" + }, + "DatabaseName": "postgres", + "EnableHttpEndpoint": true, + "EnableIAMDatabaseAuthentication": true, + "Engine": "aurora-postgresql", + "EngineVersion": "16.6", + "Port": "5432", + "ManageMasterUserPassword": true, + "MasterUsername": "pgmasteruser", + "ServerlessV2ScalingConfiguration": { + "MaxCapacity": { + "Ref": "MaxACU" + }, + "MinCapacity": { + "Ref": "MinACU" + }, + "SecondsUntilAutoPause": 3600 + }, + "StorageEncrypted": true, + "Tags": [ + { + "Key": "Name", + "Value": { + "Fn::Sub": "${ApplicationId}-pg-cluster" + } + }, + { + "Key": "StackId", + "Value": { + "Fn::Sub": "${AWS::StackId}" + } + }, + { + "Key": "Stack", + "Value": { + "Fn::Sub": "${AWS::Region}-${AWS::StackName}" + } + }, + { + "Key": "Application", + "Value": { + "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" + } + } + ], + "VpcSecurityGroupIds": [ + { + "Ref": "PostgresSecurityGroup" + } + ] + }, + "DependsOn": [ + "PostgresSubnetGroup", + "PostgresClusterParameterGroup" + ] + }, + "PostgresInstance": { + "Type": "AWS::RDS::DBInstance", + "Properties": { + "DBClusterIdentifier": { + "Ref": "PostgresCluster" + }, + "DBInstanceClass": { + "Ref": "PostgresDbInstanceType" + }, + "DBInstanceIdentifier": { + "Fn::Sub": "${ApplicationId}-pg-db-1" + }, + "Engine": "aurora-postgresql", + "EngineVersion": "16.6", + "AutoMinorVersionUpgrade": true, + "Tags": [ + { + "Key": "Name", + "Value": { + "Fn::Sub": "${ApplicationId}-pg-db-1" + } + }, + { + "Key": "StackId", + "Value": { + "Fn::Sub": "${AWS::StackId}" + } + }, + { + "Key": "Stack", + "Value": { + "Fn::Sub": "${AWS::Region}-${AWS::StackName}" + } + }, + { + "Key": "Application", + "Value": { + "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" + } + } + ] + }, + "DependsOn": [ + "PostgresCluster", + "PostgresDBParameterGroup" + ] + }, + "NeptuneDBClusterParameterGroup": { + "Type": "AWS::Neptune::DBClusterParameterGroup", + "Properties": { + "Name": { + "Fn::Sub": "neptune-cluster-params-${ApplicationId}" + }, + "Family": "neptune1.4", + "Description": "Neptune cluster parameter group", + "Parameters": { + "neptune_enable_audit_log": { + "Fn::If": [ + "AuditLogEnabled", + 1, + 0 + ] + } + }, + "Tags": [ + { + "Key": "Name", + "Value": { + "Fn::Sub": "neptune-cluster-params-${ApplicationId}" + } + }, + { + "Key": "StackId", + "Value": { + "Fn::Sub": "${AWS::StackName}" + } + }, + { + "Key": "Stack", + "Value": { + "Fn::Sub": "${AWS::Region}-${AWS::StackId}" + } + }, + { + "Key": "Application", + "Value": { + "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" + } + } + ] + } + }, + "NeptuneDBParameterGroup": { + "Type": "AWS::Neptune::DBParameterGroup", + "Properties": { + "Name": { + "Fn::Sub": "neptune-params-${ApplicationId}" + }, + "Family": "neptune1.4", + "Description": "Neptune parameter group", + "Parameters": { + "neptune_query_timeout": 60000 + }, + "Tags": [ + { + "Key": "Name", + "Value": { + "Fn::Sub": "neptune-params-${ApplicationId}" + } + }, + { + "Key": "StackId", + "Value": { + "Fn::Sub": "${AWS::StackId}" + } + }, + { + "Key": "Stack", + "Value": { + "Fn::Sub": "${AWS::Region}-${AWS::StackName}" + } + }, + { + "Key": "Application", + "Value": { + "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" + } + } + ] + } + }, + "NeptuneDBCluster": { + "Type": "AWS::Neptune::DBCluster", + "Properties": { + "DBClusterIdentifier": { + "Fn::Sub": "${ApplicationId}-neptune-cluster" + }, + "EngineVersion": { + "Ref": "NeptuneEngineVersion" + }, + "DBSubnetGroupName": { + "Ref": "NeptuneDBSubnetGroup" + }, + "VpcSecurityGroupIds": [ + { + "Ref": "NeptuneSecurityGroup" + } + ], + "DBClusterParameterGroupName": { + "Ref": "NeptuneDBClusterParameterGroup" + }, + "Port": "8182", + "IamAuthEnabled": true, + "ServerlessScalingConfiguration": { + "MaxCapacity": { + "Ref": "MaxNCU" + }, + "MinCapacity": { + "Ref": "MinNCU" + } + }, + "StorageEncrypted": true, + "Tags": [ + { + "Key": "Name", + "Value": { + "Fn::Sub": "${ApplicationId}-neptune-cluster" + } + }, + { + "Key": "StackId", + "Value": { + "Fn::Sub": "${AWS::StackId}" + } + }, + { + "Key": "Stack", + "Value": { + "Fn::Sub": "${AWS::Region}-${AWS::StackName}" + } + }, + { + "Key": "Application", + "Value": { + "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" + } + } + ] + }, + "DependsOn": [ + "NeptuneDBSubnetGroup", + "NeptuneDBClusterParameterGroup" + ] + }, + "NeptuneDBInstance": { + "Type": "AWS::Neptune::DBInstance", + "Properties": { + "DBInstanceIdentifier": { + "Fn::Sub": "${ApplicationId}-neptune-db-1" + }, + "DBClusterIdentifier": { + "Ref": "NeptuneDBCluster" + }, + "DBInstanceClass": { + "Ref": "NeptuneDbInstanceType" + }, + "DBParameterGroupName": { + "Ref": "NeptuneDBParameterGroup" + }, + "AutoMinorVersionUpgrade": true, + "Tags": [ + { + "Key": "Name", + "Value": { + "Fn::Sub": "${ApplicationId}-neptune-db-1" + } + }, + { + "Key": "StackId", + "Value": { + "Fn::Sub": "${AWS::StackId}" + } + }, + { + "Key": "Stack", + "Value": { + "Fn::Sub": "${AWS::Region}-${AWS::StackName}" + } + }, + { + "Key": "Application", + "Value": { + "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" + } + } + ] + }, + "DependsOn": [ + "NeptuneDBCluster", + "NeptuneDBParameterGroup" + ] + }, + "NeptuneNotebookInstance": { + "Type": "AWS::SageMaker::NotebookInstance", + "Properties": { + "InstanceType": { + "Ref": "NotebookInstanceType" + }, + "PlatformIdentifier": "notebook-al2-v3", + "NotebookInstanceName": { + "Fn::Sub": "aws-neptune-${ApplicationId}" + }, + "SubnetId": { + "Ref": "Subnet4" + }, + "SecurityGroupIds": [ + { + "Ref": "GraphRAGClientSecurityGroup" + } + ], + "RoleArn": { + "Fn::GetAtt": [ + "GraphRAGClientRole", + "Arn" + ] + }, + "LifecycleConfigName": { + "Fn::GetAtt": [ + "NeptuneNotebookInstanceLifecycleConfig", + "NotebookInstanceLifecycleConfigName" + ] + }, + "Tags": [ + { + "Key": "StackId", + "Value": { + "Fn::Sub": "${AWS::StackId}" + } + }, + { + "Key": "Stack", + "Value": { + "Fn::Sub": "${AWS::Region}-${AWS::StackName}" + } + }, + { + "Key": "Application", + "Value": { + "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" + } + } + ] + } + }, + "NeptuneNotebookInstanceLifecycleConfig": { + "Type": "AWS::SageMaker::NotebookInstanceLifecycleConfig", + "Properties": { + "OnStart": [ + { + "Content": { + "Fn::Base64": { + "Fn::Join": [ + "", + [ + "#!/bin/bash\n\n", + "sudo -u ec2-user -i <<'EOF'\n", + "\n", + "sudo pip install packaging==24.2\n", + "echo \"export STACK_ID=", + { + "Ref": "AWS::StackId" + }, + "\" >> ~/.bashrc\n", + "echo \"export EXTRACTION_MODEL=", + "anthropic.claude-sonnet-4-6", + "\" >> ~/.bashrc\n", + "echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> ~/.bashrc\n", + "echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> ~/.bashrc\n", + "echo \"export RESPONSE_MODEL=", + "anthropic.claude-sonnet-4-6", + "\" >> ~/.bashrc\n", + "echo \"export EVALUATION_MODEL=", + "anthropic.claude-sonnet-4-6", + "\" >> ~/.bashrc\n", + "echo \"export GRAPH_NOTEBOOK_AUTH_MODE=IAM\" >> ~/.bashrc\n", + "echo \"export GRAPH_NOTEBOOK_SSL=True\" >> ~/.bashrc\n", + "echo \"export GRAPH_NOTEBOOK_IAM_PROVIDER=ROLE\" >> ~/.bashrc\n", + "echo \"export GRAPH_NOTEBOOK_PORT=", + { + "Fn::GetAtt": [ + "NeptuneDBCluster", + "Port" + ] + }, + "\" >> ~/.bashrc\n", + "echo \"export GRAPH_STORE=", + { + "Fn::Sub": [ + "neptune-db://${graphid}", + { + "graphid": { + "Fn::GetAtt": [ + "NeptuneDBCluster", + "Endpoint" + ] + } + } + ] + }, + "\" >> ~/.bashrc\n", + "echo \"export VECTOR_STORE=", + { + "Fn::Sub": [ + "postgresql://graphrag@${endpoint}:${port}/postgres?enable_iam_db_auth=True", + { + "endpoint": { + "Fn::GetAtt": [ + "PostgresCluster", + "Endpoint.Address" + ] + }, + "port": { + "Fn::GetAtt": [ + "PostgresCluster", + "Endpoint.Port" + ] + } + } + ] + }, + "\" >> ~/.bashrc\n", + "echo \"export GRAPH_NOTEBOOK_SERVICE=neptune-db\" >> ~/.bashrc\n", + "echo \"export GRAPH_NOTEBOOK_HOST=", + { + "Fn::GetAtt": [ + "NeptuneDBCluster", + "Endpoint" + ] + }, + "\" >> ~/.bashrc\n", + "echo \"export AWS_REGION=", + { + "Ref": "AWS::Region" + }, + "\" >> ~/.bashrc\n\n", + "aws s3 cp s3://", + { + "Fn::If": [ + "IsIadRegion", + "aws-neptune-notebook", + { + "Fn::Sub": "aws-neptune-notebook-${AWS::Region}" + } + ] + }, + "/graph_notebook.tar.gz /tmp/graph_notebook.tar.gz\n", + "rm -rf /tmp/graph_notebook\n", + "tar -zxvf /tmp/graph_notebook.tar.gz -C /tmp\n", + "chmod +x /tmp/graph_notebook/install_jl4x.sh\n", + "/tmp/graph_notebook/install_jl4x.sh\n", + "\n", + "cd /home/ec2-user/SageMaker\n", + "if [ ! -d graphrag-toolkit ]; then\n", + " mkdir graphrag-toolkit\n", + " chmod -R 777 graphrag-toolkit\n", + { + "Fn::If": [ + "ExampleNotebooksURLIsNotBlank", + { + "Fn::If": [ + "IsS3ExampleNotebooksURL", + { + "Fn::Join": [ + "", + [ + " aws s3 cp \"", + { + "Ref": "ExampleNotebooksURL" + }, + "\" lexical-graph-examples.zip\n", + " unzip lexical-graph-examples.zip -d graphrag-toolkit\n", + " rm -rf lexical-graph-examples.zip\n" + ] + ] + }, + { + "Fn::Join": [ + "", + [ + " curl -L \"", + { + "Ref": "ExampleNotebooksURL" + }, + "\" -o \"lexical-graph-examples.zip\"\n", + " unzip lexical-graph-examples.zip -d graphrag-toolkit\n", + " rm -rf lexical-graph-examples.zip\n" + ] + ] + } + ] + }, + { + "Ref": "AWS::NoValue" + } + ] + }, + " cd graphrag-toolkit\n", + " echo \"export STACK_ID=", + { + "Ref": "AWS::StackId" + }, + "\" >> .env\n", + " echo \"export GRAPH_STORE=", + { + "Fn::Sub": [ + "neptune-db://${graphid}", + { + "graphid": { + "Fn::GetAtt": [ + "NeptuneDBCluster", + "Endpoint" + ] + } + } + ] + }, + "\" >> .env\n", + " echo \"export VECTOR_STORE=", + { + "Fn::Sub": [ + "postgresql://graphrag@${endpoint}:${port}/postgres?enable_iam_db_auth=True", + { + "endpoint": { + "Fn::GetAtt": [ + "PostgresCluster", + "Endpoint.Address" + ] + }, + "port": { + "Fn::GetAtt": [ + "PostgresCluster", + "Endpoint.Port" + ] + } + } + ] + }, + "\" >> .env\n", + " echo \"export EXTRACTION_MODEL=", + "anthropic.claude-sonnet-4-6", + "\" >> .env\n", + " echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> .env\n", + " echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> .env\n", + " echo \"export RESPONSE_MODEL=", + "anthropic.claude-sonnet-4-6", + "\" >> .env\n", + " echo \"export EVALUATION_MODEL=", + "anthropic.claude-sonnet-4-6", + "\" >> .env\n", + " if [ -f \"./run_test_suite.sh\" ]\n", + " then\n", + " echo \"Running test suite\"\n", + " screen -L -m -d sh run_test_suite.sh\n", + " else\n", + " echo \"No test suite\"\n", + " fi\n", + "fi\n", + "EOF" + ] + ] + } + } + } + ] + } + }, + "InitPostgresFunctionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + }, + "Action": [ + "sts:AssumeRole" + ] + } + ] + }, + "Path": "/graphrag-toolkit/", + "Policies": [ + { + "PolicyName": "root", + "PolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": "logs:CreateLogGroup", + "Resource": { + "Fn::Join": [ + "", + [ + { + "Fn::Sub": "arn:${AWS::Partition}:logs:" + }, + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":*" + ] + ] + } + }, + { + "Effect": "Allow", + "Action": [ + "logs:CreateLogStream", + "logs:PutLogEvents" + ], + "Resource": { + "Fn::Join": [ + "", + [ + { + "Fn::Sub": "arn:${AWS::Partition}:logs:" + }, + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/lambda/", + { + "Fn::Sub": "${ApplicationId}-init-pg" + }, + ":*" + ] + ] + } + }, + { + "Effect": "Allow", + "Action": [ + "secretsmanager:GetSecretValue" + ], + "Resource": { + "Fn::GetAtt": [ + "PostgresCluster", + "MasterUserSecret.SecretArn" + ] + } + }, + { + "Effect": "Allow", + "Action": [ + "rds-data:BatchExecuteStatement", + "rds-data:BeginTransaction", + "rds-data:CommitTransaction", + "rds-data:ExecuteStatement", + "rds-data:RollbackTransaction" + ], + "Resource": { + "Fn::Join": [ + "", + [ + { + "Fn::Sub": "arn:${AWS::Partition}:rds:" + }, + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":cluster:", + { + "Ref": "PostgresCluster" + } + ] + ] + } + } + ] + } + } + ] + } + }, + "InitPostgresFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "FunctionName": { + "Fn::Sub": "${ApplicationId}-init-pg" + }, + "Handler": "index.lambda_handler", + "Role": { + "Fn::GetAtt": [ + "InitPostgresFunctionRole", + "Arn" + ] + }, + "Code": { + "ZipFile": { + "Fn::Join": [ + "", + [ + "import json\n", + "import boto3\n", + "import cfnresponse\n", + "import logging\n", + "\n", + "logger = logging.getLogger()\n", + "logger.setLevel(logging.INFO)\n", + "\n", + "rds_data = boto3.client('rds-data')\n", + " \n", + "def execute_sql(sql, cluster_arn, secret_arn):\n", + " rds_data.execute_statement(\n", + " resourceArn = cluster_arn,\n", + " secretArn = secret_arn,\n", + " database = 'postgres',\n", + " sql = sql\n", + " )\n", + "\n", + "def lambda_handler(event, context):\n", + " \n", + " logger.info('Event: {}'.format(event))\n", + " logger.info('Context: {}'.format(context))\n", + " \n", + " cluster_arn = event['ResourceProperties']['ClusterArn']\n", + " secret_arn = event['ResourceProperties']['SecretArn']\n", + " \n", + " if event['RequestType'] == 'Create' or event['RequestType'] == 'Update':\n", + " \n", + " try:\n", + " \n", + " logger.info('Begin Postgres setup')\n", + "\n", + " execute_sql('CREATE EXTENSION IF NOT EXISTS vector;', cluster_arn, secret_arn)\n", + " execute_sql(\"\"\"DO\n", + " $$\n", + " BEGIN\n", + " IF NOT EXISTS (SELECT * FROM pg_user WHERE usename = 'graphrag') THEN\n", + " CREATE USER graphrag;\n", + " END IF;\n", + " END\n", + " $$\n", + " ;\n", + " \"\"\", cluster_arn, secret_arn)\n", + " execute_sql('CREATE SCHEMA IF NOT EXISTS graphrag;', cluster_arn, secret_arn)\n", + " execute_sql('GRANT CONNECT ON DATABASE postgres TO graphrag;', cluster_arn, secret_arn)\n", + " execute_sql('GRANT ALL PRIVILEGES ON SCHEMA graphrag TO graphrag;', cluster_arn, secret_arn)\n", + " execute_sql('GRANT rds_iam TO graphrag;', cluster_arn, secret_arn)\n", + " \n", + " logger.info('Postgres setup complete')\n", + " \n", + " cfnresponse.send(event, \n", + " context, \n", + " cfnresponse.SUCCESS, \n", + " {\n", + " 'ClusterArn': cluster_arn, \n", + " }, \n", + " context.log_stream_name\n", + " )\n", + " \n", + " except Exception as e:\n", + " cfnresponse.send(event, context, cfnresponse.FAILED, { 'Message': str(e) }, context.log_stream_name)\n", + " \n", + " elif event['RequestType'] == 'Delete':\n", + " \n", + " logger.info('Delet request - do nothing')\n", + " \n", + " cfnresponse.send(event, \n", + " context, \n", + " cfnresponse.SUCCESS, \n", + " {\n", + " 'ClusterArn': cluster_arn, \n", + " }, \n", + " context.log_stream_name\n", + " )\n", + " \n", + " else:\n", + " cfnresponse.send(event, context, cfnresponse.FAILED, { 'Message': 'Expected a Create, Delete or Update request' }, context.log_stream_name)\n" + ] + ] + } + }, + "MemorySize": 128, + "Runtime": "python3.13", + "Timeout": "900" + } + }, + "CustomInitPostgres": { + "Type": "Custom::CustomResource", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "InitPostgresFunction", + "Arn" + ] + }, + "ClusterArn": { + "Fn::GetAtt": [ + "PostgresCluster", + "DBClusterArn" + ] + }, + "SecretArn": { + "Fn::GetAtt": [ + "PostgresCluster", + "MasterUserSecret.SecretArn" + ] + } + }, + "DependsOn": [ + "PostgresInstance" + ] + }, + "ElasticIP1": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "VPC" + } + }, + "VPC": { + "Type": "AWS::EC2::VPC", + "Properties": { + "CidrBlock": "172.30.0.0/16", + "EnableDnsSupport": "true", + "EnableDnsHostnames": "true", + "Tags": [ + { + "Key": "Name", + "Value": { + "Fn::Sub": "${ApplicationId}-vpc" + } + }, + { + "Key": "StackId", + "Value": { + "Fn::Sub": "${AWS::StackId}" + } + }, + { + "Key": "Stack", + "Value": { + "Fn::Sub": "${AWS::Region}-${AWS::StackName}" + } + } + ] + } + }, + "PublicRouteTable": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "VPC" + } + }, + "DependsOn": [ + "VPC" + ] + }, + "PrivateRouteTable": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "VPC" + } + }, + "DependsOn": [ + "VPC" + ] + }, + "IGWAtt": { + "Type": "AWS::EC2::VPCGatewayAttachment", + "Properties": { + "InternetGatewayId": { + "Ref": "IGW" + }, + "VpcId": { + "Ref": "VPC" + } + }, + "DependsOn": [ + "VPC", + "IGW" + ] + }, + "IGW": { + "Type": "AWS::EC2::InternetGateway", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": { + "Fn::Sub": "${ApplicationId}-igw" + } + }, + { + "Key": "StackId", + "Value": { + "Fn::Sub": "${AWS::StackId}" + } + }, + { + "Key": "Stack", + "Value": { + "Fn::Sub": "${AWS::Region}-${AWS::StackName}" + } + }, + { + "Key": "Application", + "Value": { + "Fn::Sub": "graphrag-toolkit:application-id:${ApplicationId}" + } + } + ] + } + }, + "NATGW": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "AllocationId": { + "Fn::GetAtt": [ + "ElasticIP1", + "AllocationId" + ] + }, + "SubnetId": { + "Ref": "Subnet4" + } + } + }, + "PublicRoute": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "IGW" + }, + "RouteTableId": { + "Ref": "PublicRouteTable" + } + }, + "DependsOn": [ + "IGWAtt" + ] + }, + "PrivateRoute": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "NATGW" + }, + "RouteTableId": { + "Ref": "PrivateRouteTable" + } + }, + "DependsOn": [ + "IGWAtt" + ] + }, + "Subnet1": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "CidrBlock": "172.30.1.0/24", + "VpcId": { + "Ref": "VPC" + }, + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + } + } + }, + "Subnet2": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "CidrBlock": "172.30.2.0/24", + "VpcId": { + "Ref": "VPC" + }, + "AvailabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + } + } + }, + "Subnet3": { + "Type": "AWS::EC2::Subnet", + "Condition": "AZ3Present", + "Properties": { + "CidrBlock": "172.30.3.0/24", + "VpcId": { + "Ref": "VPC" + }, + "AvailabilityZone": { + "Fn::Select": [ + 2, + { + "Fn::GetAZs": "" + } + ] + } + } + }, + "Subnet4": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "CidrBlock": "172.30.4.0/24", + "MapPublicIpOnLaunch": "true", + "VpcId": { + "Ref": "VPC" + }, + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + } + } + }, + "SubnetRTAssociation1": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "DependsOn": [ + "Subnet1", + "PrivateRouteTable" + ], + "Properties": { + "RouteTableId": { + "Ref": "PrivateRouteTable" + }, + "SubnetId": { + "Ref": "Subnet1" + } + } + }, + "SubnetRTAssociation2": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "DependsOn": [ + "Subnet2", + "PrivateRouteTable" + ], + "Properties": { + "RouteTableId": { + "Ref": "PrivateRouteTable" + }, + "SubnetId": { + "Ref": "Subnet2" + } + } + }, + "SubnetRTAssociation3": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Condition": "AZ3Present", + "DependsOn": [ + "Subnet3", + "PrivateRouteTable" + ], + "Properties": { + "RouteTableId": { + "Ref": "PrivateRouteTable" + }, + "SubnetId": { + "Ref": "Subnet3" + } + } + }, + "SubnetRTAssociation4": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "DependsOn": [ + "Subnet4", + "PublicRouteTable" + ], + "Properties": { + "RouteTableId": { + "Ref": "PublicRouteTable" + }, + "SubnetId": { + "Ref": "Subnet4" + } + } + } + }, + "Outputs": { + "NeptuneClusterId": { + "Description": "Neptune cluster id", + "Value": { + "Ref": "NeptuneDBCluster" + } + }, + "NeptuneClusterEndpoint": { + "Description": "Neptune cluster endpoint", + "Value": { + "Fn::GetAtt": [ + "NeptuneDBCluster", + "Endpoint" + ] + } + }, + "PostgresClusterId": { + "Description": "Neptune cluster id", + "Value": { + "Ref": "PostgresCluster" + } + }, + "PostgresClusterEndpoint": { + "Description": "Postgres cluster endpoint", + "Value": { + "Fn::GetAtt": [ + "PostgresCluster", + "Endpoint.Address" + ] + } + }, + "GraphRAGClientSecurityGroup": { + "Description": "GraphRAG client security group", + "Value": { + "Ref": "GraphRAGClientSecurityGroup" + } + }, + "NeptuneSagemakerNotebook": { + "Description": "SageMaker notebook URL", + "Value": { + "Fn::Join": [ + "", + [ + "https://", + { + "Fn::Select": [ + 1, + { + "Fn::Split": [ + "/", + { + "Ref": "NeptuneNotebookInstance" + } + ] + } + ] + }, + ".notebook.", + { + "Ref": "AWS::Region" + }, + ".sagemaker.aws/nbclassic/tree" + ] + ] + } + }, + "VPC": { + "Description": "VPC", + "Value": { + "Ref": "VPC" + } + } + } +} diff --git a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-opensearch-serverless.json b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-opensearch-serverless.json index 0ca41004..50844311 100644 --- a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-opensearch-serverless.json +++ b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-opensearch-serverless.json @@ -559,97 +559,19 @@ "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-5-haiku-20241022-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-7-sonnet-20250219-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" @@ -1418,99 +1340,15 @@ }, "\" >> ~/.bashrc\n", "echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> ~/.bashrc\n", "echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_AUTH_MODE=IAM\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_SSL=True\" >> ~/.bashrc\n", @@ -1665,99 +1503,15 @@ }, "\" >> .env\n", " echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> .env\n", " echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> .env\n", " echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " if [ -f \"./run_test_suite.sh\" ]\n", " then\n", @@ -2121,4 +1875,4 @@ } } } -} \ No newline at end of file +} diff --git a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-s3-vectors.json b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-s3-vectors.json index 667295d3..07dfe3aa 100644 --- a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-s3-vectors.json +++ b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-s3-vectors.json @@ -617,97 +617,19 @@ "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-5-haiku-20241022-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-7-sonnet-20250219-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" @@ -1582,99 +1504,15 @@ }, "\" >> ~/.bashrc\n", "echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> ~/.bashrc\n", "echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_AUTH_MODE=IAM\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_SSL=True\" >> ~/.bashrc\n", @@ -1821,99 +1659,15 @@ }, "\" >> .env\n", " echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> .env\n", " echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> .env\n", " echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " if [ -f \"./run_test_suite.sh\" ]\n", " then\n", @@ -2274,4 +2028,4 @@ } } } -} \ No newline at end of file +} diff --git a/examples/lexical-graph/workshop/graphrag-toolkit-workshop.json b/examples/lexical-graph/workshop/graphrag-toolkit-workshop.json index 1eb52528..cf351ada 100644 --- a/examples/lexical-graph/workshop/graphrag-toolkit-workshop.json +++ b/examples/lexical-graph/workshop/graphrag-toolkit-workshop.json @@ -706,7 +706,7 @@ "Resource": "*" }, { - "Sid": "GrantGlobalCrisInferenceProfileRegionAccess", + "Sid": "GrantCrisInferenceProfileAccess", "Effect": "Allow", "Action": [ "bedrock:InvokeModel", @@ -714,68 +714,12 @@ ], "Resource": [ { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/global.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - } - ], - "Condition": { - "StringEquals": { - "aws:RequestedRegion": { - "Ref": "AWS::Region" - } + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" } - } - }, - { - "Sid": "GrantGlobalCrisInferenceProfileInRegionModelAccess", - "Effect": "Allow", - "Action": [ - "bedrock:InvokeModel", - "bedrock:InvokeModelWithResponseStream" - ], - "Resource": [ - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0" - } - ], - "Condition": { - "StringEquals": { - "aws:RequestedRegion": { - "Ref": "AWS::Region" - }, - "bedrock:InferenceProfileArn": { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}:${AWS::AccountId}:inference-profile/global.anthropic.claude-sonnet-4-20250514-v1:0" - } - } - } + ] }, { - "Sid": "GrantGlobalCrisInferenceProfileGlobalModelAccess", + "Sid": "GrantFoundationModelAccess", "Effect": "Allow", "Action": [ "bedrock:InvokeModel", @@ -783,17 +727,9 @@ ], "Resource": [ { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" } - ], - "Condition": { - "StringEquals": { - "aws:RequestedRegion": "unspecified", - "bedrock:InferenceProfileArn": { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}:${AWS::AccountId}:inference-profile/global.anthropic.claude-sonnet-4-20250514-v1:0" - } - } - } + ] }, { "Effect": "Allow", @@ -1490,14 +1426,14 @@ "Ref": "AWS::StackId" }, "\" >> ~/.bashrc\n", - "echo \"export EXTRACTION_MODEL=global.anthropic.claude-sonnet-4-20250514-v1:0\" >> ~/.bashrc\n", + "echo \"export EXTRACTION_MODEL=anthropic.claude-sonnet-4-6\" >> ~/.bashrc\n", "echo \"export ENABLE_CACHE=True\" >> ~/.bashrc\n", "echo \"export OPENSEARCH_ENGINE=faiss\" >> ~/.bashrc\n", "echo \"export INCLUDE_CLASSIFICATION_IN_ENTITY_ID=False\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> ~/.bashrc\n", - "echo \"export RESPONSE_MODEL=global.anthropic.claude-sonnet-4-20250514-v1:0\" >> ~/.bashrc\n", - "echo \"export EVALUATION_MODEL=global.anthropic.claude-sonnet-4-20250514-v1:0\" >> ~/.bashrc\n", + "echo \"export RESPONSE_MODEL=anthropic.claude-sonnet-4-6\" >> ~/.bashrc\n", + "echo \"export EVALUATION_MODEL=anthropic.claude-sonnet-4-6\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_AUTH_MODE=IAM\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_SSL=True\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_IAM_PROVIDER=ROLE\" >> ~/.bashrc\n", @@ -1650,14 +1586,14 @@ ] }, "\" >> .env\n", - " echo \"export EXTRACTION_MODEL=global.anthropic.claude-sonnet-4-20250514-v1:0\" >> .env\n", + " echo \"export EXTRACTION_MODEL=anthropic.claude-sonnet-4-6\" >> .env\n", " echo \"export ENABLE_CACHE=True\" >> .env\n", " echo \"export OPENSEARCH_ENGINE=faiss\" >> .env\n", " echo \"export INCLUDE_CLASSIFICATION_IN_ENTITY_ID=False\" >> .env\n", " echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> .env\n", " echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> .env\n", - " echo \"export RESPONSE_MODEL=global.anthropic.claude-sonnet-4-20250514-v1:0\" >> .env\n", - " echo \"export EVALUATION_MODEL=global.anthropic.claude-sonnet-4-20250514-v1:0\" >> .env\n", + " echo \"export RESPONSE_MODEL=anthropic.claude-sonnet-4-6\" >> .env\n", + " echo \"export EVALUATION_MODEL=anthropic.claude-sonnet-4-6\" >> .env\n", " if [ -f \"./on-start.sh\" ]\n", " then\n", " echo \"Running startup script\"\n", diff --git a/integration-tests/build-tests.sh b/integration-tests/build-tests.sh index 958a0e6f..b9984b87 100644 --- a/integration-tests/build-tests.sh +++ b/integration-tests/build-tests.sh @@ -125,11 +125,11 @@ if [[ -z "$FAIL_FAST" ]]; then fi if [[ -z "$TEST_EXTRACTION_LLM" ]]; then - TEST_EXTRACTION_LLM="us.anthropic.claude-sonnet-4-20250514-v1:0" + TEST_EXTRACTION_LLM="us.anthropic.claude-sonnet-4-6" fi if [[ -z "$TEST_RESPONSE_LLM" ]]; then - TEST_RESPONSE_LLM="us.anthropic.claude-sonnet-4-20250514-v1:0" + TEST_RESPONSE_LLM="us.anthropic.claude-sonnet-4-6" fi if [[ -z "$NEPTUNE_INSTANCE_TYPE" ]]; then @@ -355,6 +355,38 @@ echo "----------------------------------------------------" echo "" if [[ -z "$DRY_RUN" ]]; then + + validate_model() { + local label="$1" + local model_id="$2" + local prefix="${model_id%%.*}" + + echo "Validating $label: $model_id (region: $REGION_NAME)..." + + if [[ "$prefix" == "us" || "$prefix" == "eu" || "$prefix" == "au" || "$prefix" == "jp" || "$prefix" == "global" ]]; then + if ! aws bedrock get-inference-profile --inference-profile-identifier "$model_id" --region "$REGION_NAME" > /dev/null 2>&1; then + echo "" + echo "ERROR: $label model '$model_id' is not available in region '$REGION_NAME'." + echo " The inference profile could not be found or is not accessible." + echo " Check the latest supported models: https://docs.aws.amazon.com/bedrock/latest/userguide/model-cards.html" + exit 1 + fi + else + if ! aws bedrock get-foundation-model --model-identifier "$model_id" --region "$REGION_NAME" > /dev/null 2>&1; then + echo "" + echo "ERROR: $label model '$model_id' is not available in region '$REGION_NAME'." + echo " The foundation model could not be found or is not accessible." + echo " Check the latest supported models: https://docs.aws.amazon.com/bedrock/latest/userguide/model-cards.html" + exit 1 + fi + fi + + echo "✓ $label: $model_id" + } + + validate_model "Extraction LLM" "$TEST_EXTRACTION_LLM" + validate_model "Response LLM" "$TEST_RESPONSE_LLM" + if [[ "$PREV_STACK_NAME" ]]; then echo "Deleting previous stack: $PREV_STACK_NAME" aws cloudformation delete-stack --stack-name "$PREV_STACK_NAME" --region $REGION_NAME diff --git a/integration-tests/cloudformation-templates/graphrag-toolkit-neo4j-opensearch-serverless.json b/integration-tests/cloudformation-templates/graphrag-toolkit-neo4j-opensearch-serverless.json index d718ff10..1d11a562 100644 --- a/integration-tests/cloudformation-templates/graphrag-toolkit-neo4j-opensearch-serverless.json +++ b/integration-tests/cloudformation-templates/graphrag-toolkit-neo4j-opensearch-serverless.json @@ -30,8 +30,8 @@ "Description": "Neo4j password", "Type": "String", "MinLength": 8, - "NoEcho": true, - "Default": "xhu4klq!J" + "NoEcho": true, + "Default": "xhu4klq!J" }, "SSHCIDR": { "Description": "SSH CIDR (Specify an address range from which ec2 instances are accessible on port 22. You can use 0.0.0.0/0 to allow access from any IP address)", @@ -543,115 +543,37 @@ "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-5-haiku-20241022-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-3-5-haiku-20241022-v1:0" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-7-sonnet-20250219-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-3-7-sonnet-20250219-v1:0" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.rerank-v3-5:0" - } + { + "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.rerank-v3-5:0" + } ] }, - { - "Action": [ - "bedrock:Rerank" - ], - "Resource": [ - "*" - ], - "Effect": "Allow" - } + { + "Action": [ + "bedrock:Rerank" + ], + "Resource": [ + "*" + ], + "Effect": "Allow" + } ] }, "Roles": [ @@ -1247,99 +1169,15 @@ }, "\" >> ~/.bashrc\n", "echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> ~/.bashrc\n", "echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> ~/.bashrc\n", "echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_AUTH_MODE=IAM\" >> ~/.bashrc\n", "echo \"export GRAPH_NOTEBOOK_SSL=True\" >> ~/.bashrc\n", @@ -1484,99 +1322,15 @@ }, "\" >> .env\n", " echo \"export EXTRACTION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " echo \"export EMBEDDINGS_MODEL=cohere.embed-english-v3\" >> .env\n", " echo \"export EMBEDDINGS_DIMENSIONS=1024\" >> .env\n", " echo \"export RESPONSE_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " echo \"export EVALUATION_MODEL=", - { - "Fn::Sub": [ - "${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] - }, + "anthropic.claude-sonnet-4-6", "\" >> .env\n", " if [ -f \"./run_test_suite.sh\" ]\n", " then\n", @@ -1961,4 +1715,4 @@ } } } -} \ No newline at end of file +} diff --git a/integration-tests/cloudformation-templates/graphrag-toolkit-tests.json b/integration-tests/cloudformation-templates/graphrag-toolkit-tests.json index d69f53ed..b0ebb732 100644 --- a/integration-tests/cloudformation-templates/graphrag-toolkit-tests.json +++ b/integration-tests/cloudformation-templates/graphrag-toolkit-tests.json @@ -301,196 +301,40 @@ "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/openai.gpt-oss-120b-1:0" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-7-sonnet-20250219-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-3-7-sonnet-20250219-v1:0" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-5-haiku-20241022-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-3-5-haiku-20241022-v1:0" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-sonnet-20241022-v2:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-5-sonnet-20241022-v2:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-3-5-sonnet-20241022-v2:0" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-sonnet-20240620-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-5-sonnet-20240620-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-3-5-sonnet-20240620-v1:0" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-sonnet-20240229-v1:0" }, { - "Fn::Sub": [ - "arn:${partition}:bedrock:${region}:${accountId}:inference-profile/${regionPrefix}.anthropic.claude-3-sonnet-20240229-v1:0", - { - "partition": { - "Ref": "AWS::Partition" - }, - "region": { - "Ref": "AWS::Region" - }, - "accountId": { - "Ref": "AWS::AccountId" - }, - "regionPrefix": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "-", - { - "Ref": "AWS::Region" - } - ] - } - ] - } - } - ] + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-3-sonnet-20240229-v1:0" } ] }, diff --git a/integration-tests/env.template b/integration-tests/env.template index a2316d22..dfada824 100644 --- a/integration-tests/env.template +++ b/integration-tests/env.template @@ -12,7 +12,7 @@ export DELETE_STACK_ROLE= export FAIL_FAST= export TOPIC= -export TEST_EXTRACTION_LLM= -export TEST_RESPONSE_LLM= +export TEST_EXTRACTION_LLM= +export TEST_RESPONSE_LLM= export EMBEDDINGS_MODEL= export EMBEDDINGS_DIMENSIONS= diff --git a/integration-tests/test-scripts/graphrag_toolkit_tests/batch_extract.py b/integration-tests/test-scripts/graphrag_toolkit_tests/batch_extract.py index 2014d48e..ac6c7a72 100644 --- a/integration-tests/test-scripts/graphrag_toolkit_tests/batch_extract.py +++ b/integration-tests/test-scripts/graphrag_toolkit_tests/batch_extract.py @@ -36,7 +36,7 @@ def description(self): def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-6') GraphRAGConfig.extraction_batch_size = 100 GraphRAGConfig.extraction_num_workers = 2 @@ -126,7 +126,7 @@ def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): from llama_index.readers.s3 import S3Reader - GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-6') GraphRAGConfig.extraction_batch_size = 600 GraphRAGConfig.extraction_num_workers = 4 diff --git a/integration-tests/test-scripts/graphrag_toolkit_tests/batch_fallback.py b/integration-tests/test-scripts/graphrag_toolkit_tests/batch_fallback.py index afe8fb18..637039d4 100644 --- a/integration-tests/test-scripts/graphrag_toolkit_tests/batch_fallback.py +++ b/integration-tests/test-scripts/graphrag_toolkit_tests/batch_fallback.py @@ -26,7 +26,7 @@ def description(self): def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-6') GraphRAGConfig.extraction_batch_size = 100 GraphRAGConfig.extraction_num_workers = 2 diff --git a/integration-tests/test-scripts/graphrag_toolkit_tests/checkpoint.py b/integration-tests/test-scripts/graphrag_toolkit_tests/checkpoint.py index 94672af5..fde6f33b 100644 --- a/integration-tests/test-scripts/graphrag_toolkit_tests/checkpoint.py +++ b/integration-tests/test-scripts/graphrag_toolkit_tests/checkpoint.py @@ -26,7 +26,7 @@ def description(self): def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-6') with( @@ -105,7 +105,7 @@ def description(self): def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-6') with( diff --git a/integration-tests/test-scripts/graphrag_toolkit_tests/extract.py b/integration-tests/test-scripts/graphrag_toolkit_tests/extract.py index 1050b673..c9ef9410 100644 --- a/integration-tests/test-scripts/graphrag_toolkit_tests/extract.py +++ b/integration-tests/test-scripts/graphrag_toolkit_tests/extract.py @@ -24,7 +24,7 @@ def description(self): def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-6') extracted_docs = FileBasedDocs( docs_directory='extracted' diff --git a/integration-tests/test-scripts/graphrag_toolkit_tests/extract_and_build.py b/integration-tests/test-scripts/graphrag_toolkit_tests/extract_and_build.py index 2c6ab835..2f40766c 100644 --- a/integration-tests/test-scripts/graphrag_toolkit_tests/extract_and_build.py +++ b/integration-tests/test-scripts/graphrag_toolkit_tests/extract_and_build.py @@ -23,7 +23,7 @@ def description(self): def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-6') with( diff --git a/integration-tests/test-scripts/graphrag_toolkit_tests/query.py b/integration-tests/test-scripts/graphrag_toolkit_tests/query.py index 1df2e49d..4f910cb4 100644 --- a/integration-tests/test-scripts/graphrag_toolkit_tests/query.py +++ b/integration-tests/test-scripts/graphrag_toolkit_tests/query.py @@ -35,7 +35,7 @@ def wait(self) -> bool: def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-6') with( GraphStoreFactory.for_graph_store( @@ -80,7 +80,7 @@ def wait(self) -> bool: def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-6') with( GraphStoreFactory.for_graph_store( @@ -126,7 +126,7 @@ def wait(self) -> bool: def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-6') with( GraphStoreFactory.for_graph_store( @@ -172,7 +172,7 @@ def wait(self) -> bool: def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-6') with( GraphStoreFactory.for_graph_store( @@ -218,7 +218,7 @@ def wait(self) -> bool: def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-6') with( GraphStoreFactory.for_graph_store( @@ -284,7 +284,7 @@ def wait(self) -> bool: def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-6') with( GraphStoreFactory.for_graph_store( @@ -329,7 +329,7 @@ def wait(self) -> bool: def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-6') with( GraphStoreFactory.for_graph_store( @@ -379,7 +379,7 @@ def wait(self) -> bool: def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-6') with( GraphStoreFactory.for_graph_store( @@ -454,7 +454,7 @@ def wait(self) -> bool: def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-6') with( GraphStoreFactory.for_graph_store( @@ -507,7 +507,7 @@ def wait(self) -> bool: def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-6') with( GraphStoreFactory.for_graph_store( @@ -556,7 +556,7 @@ def wait(self) -> bool: def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-6') with( GraphStoreFactory.for_graph_store( diff --git a/integration-tests/test-scripts/graphrag_toolkit_tests/query_gpu.py b/integration-tests/test-scripts/graphrag_toolkit_tests/query_gpu.py index 6d542a25..556c571c 100644 --- a/integration-tests/test-scripts/graphrag_toolkit_tests/query_gpu.py +++ b/integration-tests/test-scripts/graphrag_toolkit_tests/query_gpu.py @@ -29,7 +29,7 @@ def wait(self) -> bool: def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-6') if os.environ.get('USE_GPU', 'False') == 'False': print('Non-GPU instance, so skipping test') diff --git a/integration-tests/test-scripts/graphrag_toolkit_tests/versioning.py b/integration-tests/test-scripts/graphrag_toolkit_tests/versioning.py index 3ae0de38..509662ce 100644 --- a/integration-tests/test-scripts/graphrag_toolkit_tests/versioning.py +++ b/integration-tests/test-scripts/graphrag_toolkit_tests/versioning.py @@ -51,7 +51,7 @@ def description(self): def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-6') GraphRAGConfig.enable_versioning = True with( @@ -107,7 +107,7 @@ def wait(self) -> bool: def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.response_llm = os.environ.get('TEST_RESPONSE_LLM', 'anthropic.claude-sonnet-4-6') class VersioningAssertions(unittest.TestCase): @@ -280,7 +280,7 @@ def description(self): def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-6') GraphRAGConfig.enable_versioning = True with( @@ -362,7 +362,7 @@ def description(self): def _run_test(self, handler:IntegrationTestHandler, params:Dict[str, Any]): - GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-6') GraphRAGConfig.enable_versioning = True with( @@ -419,7 +419,7 @@ def deletion_protection_filter_fn(metadata): deletion_protection = metadata.get('deletionProtection', False) return not deletion_protection - GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-20250514-v1:0') + GraphRAGConfig.extraction_llm = os.environ.get('TEST_EXTRACTION_LLM', 'anthropic.claude-sonnet-4-6') GraphRAGConfig.enable_versioning = True with( diff --git a/lexical-graph/src/graphrag_toolkit/lexical_graph/config.py b/lexical-graph/src/graphrag_toolkit/lexical_graph/config.py index 75d57647..0a2612fc 100644 --- a/lexical-graph/src/graphrag_toolkit/lexical_graph/config.py +++ b/lexical-graph/src/graphrag_toolkit/lexical_graph/config.py @@ -31,8 +31,8 @@ EmbeddingType = Union[BaseEmbedding, str] logger = logging.getLogger(__name__) -DEFAULT_EXTRACTION_MODEL = 'us.anthropic.claude-sonnet-4-20250514-v1:0' -DEFAULT_RESPONSE_MODEL = 'us.anthropic.claude-sonnet-4-20250514-v1:0' +DEFAULT_EXTRACTION_MODEL = 'us.anthropic.claude-sonnet-4-6' +DEFAULT_RESPONSE_MODEL = 'us.anthropic.claude-sonnet-4-6' DEFAULT_EMBEDDINGS_MODEL = 'cohere.embed-english-v3' DEFAULT_RERANKING_MODEL = 'mixedbread-ai/mxbai-rerank-xsmall-v1' DEFAULT_BEDROCK_RERANKING_MODEL = 'cohere.rerank-v3-5:0' From 3092889d1ba93eab19e064fb878314127d77b202 Mon Sep 17 00:00:00 2001 From: Oussama Hansal Date: Tue, 28 Apr 2026 12:52:20 -0700 Subject: [PATCH 2/3] remove Neo4jPassword --- .../graphrag-toolkit-neo4j-opensearch-serverless.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/integration-tests/cloudformation-templates/graphrag-toolkit-neo4j-opensearch-serverless.json b/integration-tests/cloudformation-templates/graphrag-toolkit-neo4j-opensearch-serverless.json index 1d11a562..61db5cf8 100644 --- a/integration-tests/cloudformation-templates/graphrag-toolkit-neo4j-opensearch-serverless.json +++ b/integration-tests/cloudformation-templates/graphrag-toolkit-neo4j-opensearch-serverless.json @@ -30,8 +30,7 @@ "Description": "Neo4j password", "Type": "String", "MinLength": 8, - "NoEcho": true, - "Default": "xhu4klq!J" + "NoEcho": true }, "SSHCIDR": { "Description": "SSH CIDR (Specify an address range from which ec2 instances are accessible on port 22. You can use 0.0.0.0/0 to allow access from any IP address)", From 461c23343136c0e0fd4faa014296afc21bb25837 Mon Sep 17 00:00:00 2001 From: Oussama Hansal Date: Wed, 29 Apr 2026 17:23:48 -0700 Subject: [PATCH 3/3] use wildcard IAM policies --- ...kit-neptune-analytics-aurora-postgres.json | 16 ++------- ...ptune-analytics-opensearch-serverless.json | 16 ++------- ...-toolkit-neptune-analytics-s3-vectors.json | 16 ++------- .../graphrag-toolkit-neptune-analytics.json | 16 ++------- ...ptune-db-aurora-postgres-existing-vpc.json | 16 ++------- ...ag-toolkit-neptune-db-aurora-postgres.json | 16 ++------- ...lkit-neptune-db-opensearch-serverless.json | 16 ++------- ...raphrag-toolkit-neptune-db-s3-vectors.json | 16 ++------- .../workshop/graphrag-toolkit-workshop.json | 4 +-- ...g-toolkit-neo4j-opensearch-serverless.json | 16 ++------- .../graphrag-toolkit-tests.json | 34 ++----------------- 11 files changed, 22 insertions(+), 160 deletions(-) diff --git a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-aurora-postgres.json b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-aurora-postgres.json index b09b84cb..32f7fbfa 100644 --- a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-aurora-postgres.json +++ b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-aurora-postgres.json @@ -792,22 +792,10 @@ ], "Resource": [ { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.*" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.*" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" diff --git a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-opensearch-serverless.json b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-opensearch-serverless.json index 3a6551ad..6debda34 100644 --- a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-opensearch-serverless.json +++ b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-opensearch-serverless.json @@ -353,22 +353,10 @@ ], "Resource": [ { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.*" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.*" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" diff --git a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-s3-vectors.json b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-s3-vectors.json index 958441f0..d13f8512 100644 --- a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-s3-vectors.json +++ b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics-s3-vectors.json @@ -409,22 +409,10 @@ ], "Resource": [ { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.*" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.*" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" diff --git a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics.json b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics.json index cb12ec2c..d010d29f 100644 --- a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics.json +++ b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-analytics.json @@ -305,22 +305,10 @@ ], "Resource": [ { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.*" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.*" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" diff --git a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-aurora-postgres-existing-vpc.json b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-aurora-postgres-existing-vpc.json index 7d436d85..dff2a302 100644 --- a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-aurora-postgres-existing-vpc.json +++ b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-aurora-postgres-existing-vpc.json @@ -732,22 +732,10 @@ ], "Resource": [ { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.*" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.*" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" diff --git a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-aurora-postgres.json b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-aurora-postgres.json index cd43ca73..1c18d00b 100644 --- a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-aurora-postgres.json +++ b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-aurora-postgres.json @@ -683,22 +683,10 @@ ], "Resource": [ { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.*" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.*" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" diff --git a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-opensearch-serverless.json b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-opensearch-serverless.json index 50844311..42fb1702 100644 --- a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-opensearch-serverless.json +++ b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-opensearch-serverless.json @@ -556,22 +556,10 @@ ], "Resource": [ { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.*" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.*" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" diff --git a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-s3-vectors.json b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-s3-vectors.json index 07dfe3aa..0a9ef2b6 100644 --- a/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-s3-vectors.json +++ b/examples/lexical-graph/cloudformation-templates/graphrag-toolkit-neptune-db-s3-vectors.json @@ -614,22 +614,10 @@ ], "Resource": [ { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.*" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.*" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" diff --git a/examples/lexical-graph/workshop/graphrag-toolkit-workshop.json b/examples/lexical-graph/workshop/graphrag-toolkit-workshop.json index cf351ada..5c2bc310 100644 --- a/examples/lexical-graph/workshop/graphrag-toolkit-workshop.json +++ b/examples/lexical-graph/workshop/graphrag-toolkit-workshop.json @@ -714,7 +714,7 @@ ], "Resource": [ { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.*" } ] }, @@ -727,7 +727,7 @@ ], "Resource": [ { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.*" } ] }, diff --git a/integration-tests/cloudformation-templates/graphrag-toolkit-neo4j-opensearch-serverless.json b/integration-tests/cloudformation-templates/graphrag-toolkit-neo4j-opensearch-serverless.json index 61db5cf8..d0f777d2 100644 --- a/integration-tests/cloudformation-templates/graphrag-toolkit-neo4j-opensearch-serverless.json +++ b/integration-tests/cloudformation-templates/graphrag-toolkit-neo4j-opensearch-serverless.json @@ -539,22 +539,10 @@ ], "Resource": [ { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.*" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-3-5-haiku-20241022-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-3-7-sonnet-20250219-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.*" }, { "Fn::Sub": "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3" diff --git a/integration-tests/cloudformation-templates/graphrag-toolkit-tests.json b/integration-tests/cloudformation-templates/graphrag-toolkit-tests.json index b0ebb732..3363365c 100644 --- a/integration-tests/cloudformation-templates/graphrag-toolkit-tests.json +++ b/integration-tests/cloudformation-templates/graphrag-toolkit-tests.json @@ -301,40 +301,10 @@ "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/openai.gpt-oss-120b-1:0" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.*" }, { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-sonnet-4-6" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-3-7-sonnet-20250219-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-3-5-haiku-20241022-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-sonnet-20241022-v2:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-3-5-sonnet-20241022-v2:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-sonnet-20240620-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-3-5-sonnet-20240620-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-sonnet-20240229-v1:0" - }, - { - "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.claude-3-sonnet-20240229-v1:0" + "Fn::Sub": "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:inference-profile/*.anthropic.*" } ] },