This is an automated email from the ASF dual-hosted git repository.
vincbeck pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 93978958ae1 Fix example_neptune_analytics by pinning an explicit
region (#73851)
93978958ae1 is described below
commit 93978958ae1b795b75f415e15d17869c777e8d7a
Author: Vincent <[email protected]>
AuthorDate: Mon Sep 28 13:13:27 2026 -0400
Fix example_neptune_analytics by pinning an explicit region (#73851)
account_id_endpoint_mode=disabled forces botocore to build the standard
regional neptune-graph endpoint, but botocore cannot resolve that endpoint
when the region is None (as it is on the Airflow 2 runner with no
aws_default
connection). AWS then rejects the request with "Unable to determine
service/operation name to be authorized".
Pass the region already resolved via boto3.session.Session().region_name to
every Neptune operator and to the delete_graph_if_exists cleanup hook so the
regional endpoint can be built.
---
.../system/amazon/aws/example_neptune_analytics.py | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git
a/providers/amazon/tests/system/amazon/aws/example_neptune_analytics.py
b/providers/amazon/tests/system/amazon/aws/example_neptune_analytics.py
index 1fdb4e3853e..28361464d39 100644
--- a/providers/amazon/tests/system/amazon/aws/example_neptune_analytics.py
+++ b/providers/amazon/tests/system/amazon/aws/example_neptune_analytics.py
@@ -71,9 +71,9 @@ e1,n1,n2,KNOWS
@task(trigger_rule=TriggerRule.ALL_DONE)
-def delete_graph_if_exists(graph_name: str) -> None:
+def delete_graph_if_exists(graph_name: str, region_name: str | None = None) ->
None:
"""Safety net to clean up the graph in case a previous task failed."""
- hook = NeptuneAnalyticsHook(config=Config(**NEPTUNE_BOTOCORE_CONFIG))
+ hook = NeptuneAnalyticsHook(region_name=region_name,
config=Config(**NEPTUNE_BOTOCORE_CONFIG))
with contextlib.suppress(Exception):
# List graphs and find by name
paginator = hook.conn.get_paginator("list_graphs")
@@ -118,6 +118,8 @@ with DAG(
import_graph_name = f"{env_id}-import-graph"
bucket_name = f"{env_id}-neptune-analytics"
import_role_arn = test_context[NEPTUNE_IMPORT_ROLE_ARN_KEY]
+ # neptune-graph must be pinned to an explicit region: with
account_id_endpoint_mode disabled
+ # botocore builds the standard regional endpoint, which it cannot resolve
when region is None.
region = boto3.session.Session().region_name
# --- TEST SETUP ---
@@ -158,6 +160,7 @@ with DAG(
deferrable=False,
waiter_delay=30,
waiter_max_attempts=60,
+ region_name=region,
botocore_config=NEPTUNE_BOTOCORE_CONFIG,
)
# [END howto_operator_neptune_analytics_create_graph]
@@ -167,6 +170,7 @@ with DAG(
task_id="create_endpoint",
graph_identifier="{{
ti.xcom_pull(task_ids='create_graph')['graph_id']}}",
wait_for_completion=True,
+ region_name=region,
botocore_config=NEPTUNE_BOTOCORE_CONFIG,
)
# [END howto_operator_neptune_analytics_create_private_endpoint]
@@ -180,6 +184,7 @@ with DAG(
deferrable=False,
waiter_delay=30,
waiter_max_attempts=60,
+ region_name=region,
botocore_config=NEPTUNE_BOTOCORE_CONFIG,
)
# [END howto_operator_neptune_analytics_delete_private_endpoint]
@@ -196,6 +201,7 @@ with DAG(
deferrable=False,
waiter_delay=30,
waiter_max_attempts=60,
+ region_name=region,
botocore_config=NEPTUNE_BOTOCORE_CONFIG,
)
# [END howto_operator_neptune_analytics_start_import_task]
@@ -206,6 +212,7 @@ with DAG(
import_task_id="{{
ti.xcom_pull(task_ids='start_import')['import_task_id']}}",
wait_for_completion=True,
aws_conn_id="aws_default",
+ region_name=region,
botocore_config=NEPTUNE_BOTOCORE_CONFIG,
)
# [END howto_operator_neptune_analytics_cancel_import_task]
@@ -219,6 +226,7 @@ with DAG(
deferrable=False,
waiter_delay=30,
waiter_max_attempts=60,
+ region_name=region,
botocore_config=NEPTUNE_BOTOCORE_CONFIG,
)
# [END howto_operator_neptune_analytics_delete_graph]
@@ -241,6 +249,7 @@ with DAG(
deferrable=False,
waiter_delay=30,
waiter_max_attempts=60,
+ region_name=region,
botocore_config=NEPTUNE_BOTOCORE_CONFIG,
)
# [END howto_operator_neptune_analytics_create_graph_with_import]
@@ -255,6 +264,7 @@ with DAG(
trigger_rule=TriggerRule.ALL_DONE,
waiter_delay=30,
waiter_max_attempts=60,
+ region_name=region,
botocore_config=NEPTUNE_BOTOCORE_CONFIG,
)
# [END howto_operator_neptune_analytics_delete_import_graph]
@@ -268,8 +278,10 @@ with DAG(
force_delete=True,
)
- cleanup_graph =
delete_graph_if_exists.override(task_id="cleanup_graph")(graph_name)
- cleanup_import_graph =
delete_graph_if_exists.override(task_id="cleanup_import_graph")(import_graph_name)
+ cleanup_graph =
delete_graph_if_exists.override(task_id="cleanup_graph")(graph_name, region)
+ cleanup_import_graph =
delete_graph_if_exists.override(task_id="cleanup_import_graph")(
+ import_graph_name, region
+ )
chain(
# TEST SETUP