You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS Glue Job获取数据库表时ap-south-1端点连接超时,不使用端点如何解决

AWS Glue调用get_tables接口连接超时排查方案(不使用自定义端点)

该报错为运行环境无法正常访问ap-south-1区域的Glue公共服务端点导致,可按以下步骤排查:

  • 检查Glue Job的VPC关联配置
    若Job绑定了VPC、子网和安全组:
    • 确认子网有公网访问能力:子网路由表需配置指向互联网网关(IGW)的0.0.0.0/0路由;如果是纯私有子网,必须配置NAT网关作为公网出口,不能只有内部路由
    • 安全组出站规则需放开HTTPS 443端口的公网访问权限,至少要允许访问ap-south-1区域的Glue服务IP段
      若Job没有绑定VPC,默认运行在AWS托管公网环境,跳过这一步
  • 核对区域配置一致性
    确认目标Glue数据库postgresql_processed确实部署在ap-south-1区域,若跨区域需修改boto3.client初始化时的region_name参数为数据库实际所在区域
  • 检查IAM角色权限
    Glue Job关联的IAM角色必须包含glue:GetTables权限,示例权限策略如下:
    {
        "Effect": "Allow",
        "Action": "glue:GetTables",
        "Resource": [
            "arn:aws:glue:ap-south-1:<你的AWS账号ID>:database/postgresql_processed",
            "arn:aws:glue:ap-south-1:<你的AWS账号ID>:table/postgresql_processed/*",
            "arn:aws:glue:ap-south-1:<你的AWS账号ID>:catalog"
        ]
    }
    
  • 调整客户端超时与重试配置
    可以显式配置boto3客户端的超时与重试规则,避免默认参数过短导致的偶发超时,修改后的完整代码如下:
    import boto3
    from botocore.config import Config
    
    next_token = ""
    # 自定义超时重试配置
    glue_config = Config(
        connect_timeout=30,
        read_timeout=60,
        retries = {
            "max_attempts": 3,
            "mode": "standard"
        }
    )
    client = boto3.client('glue', region_name='ap-south-1', config=glue_config)
    table_list = []
    
    while True:
      response = client.get_tables(DatabaseName = 'postgresql_processed', NextToken = next_token)
      for tables in response['TableList']:
          table_list.append(tables['Name'])
      next_token = response.get('NextToken')
      if next_token is None:
        break
    print(table_list)
    
  • 验证是否为偶发网络波动
    重跑Job确认是否为区域临时网络故障导致的偶发报错。

内容的提问来源于stack exchange,提问作者user12444584

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.01 03:18:00