AWS Glue Python Shell 作业连接超时错误

AWS Glue Python Shell Job Connect Timeout Error

正在尝试 运行 AWS Glue Python Shell 作业但出现连接超时错误

错误图片:https://i.stack.imgur.com/MHpHg.png

脚本:https://i.stack.imgur.com/KQxkj.png

您似乎没有将 secretsmanager 端点添加到您的 VPC。由于流量不会离开 AWS network,因此您的 Glue 作业的 VPC 内将无法访问互联网。因此,如果您想连接到 secretsmanager,则需要将其添加到您的 VPC。

请参阅this on how you can add this to your VPC and this以确保您已正确配置安全组。

AWS Glue Git Issue

你好, 我们让 AWS Glue Python Shell 与所有依赖项一起工作,如下所示。 Glue 具有 awscli 依赖性以及 boto3

AWS Glue Python Shell 与 Internet

在 Glue 作业执行期间将 awscli 和 boto3 whl 文件添加到 Python 库路径 。这个选项很慢,因为它必须下载和安装依赖项。

  1. 下载以下whl文件
  1. 将文件上传到给定 python 库路径中的 s3 存储桶
  2. 在Python库路径中添加s3 whl文件路径。给整个whl文件s3引用路径,用逗号
  3. 分隔

AWS Glue Python Shell 没有互联网连接

参考AWS Wrangler Glue dependency build

  1. 我们按照上面提到的 awscliboto3 whl 文件
  2. 的步骤
  3. 下面是最新的requirements.txt编译的最新版本
colorama==0.4.3
docutils==0.15.2
rsa==4.5.0
s3transfer==0.3.3
PyYAML==5.3.1
botocore==1.19.23
pyasn1==0.4.8
jmespath==0.10.0
urllib3==1.26.2
python_dateutil==2.8.1
six==1.15.0
  1. 将依赖项下载到 libs 文件夹
pip download -r requirements.txt -d libs
  1. 将原来的主whl文件也移动到lib目录下
  1. 打包为 zip 文件
cd libs zip ../boto3-depends.zip *
  1. 上传boto3-depends.zip到s3并添加Glue作业路径引用文件路径 注意:是引用文件路径而不是Python库路径

  2. 占位符代码,用于安装最新的 awcli 和 boto3 并加载到 AWS Python Glue Shell.

import os.path
import subprocess
import sys

# borrowed from 
def get_referenced_filepath(file_name, matchFunc=os.path.isfile):
for dir_name in sys.path:
candidate = os.path.join(dir_name, file_name)
if matchFunc(candidate):
return candidate
raise Exception("Can't find file: ".format(file_name))

zip_file = get_referenced_filepath("awswrangler-depends.zip")

subprocess.run()

# Can't install --user, or without "-t ." because of permissions issues on the filesystem
subprocess.run(, shell=True)

#Additonal code as part of AWS Thread https://forums.aws.amazon.com/thread.jspa?messageID=954344
sys.path.insert(0, '/glue/lib/installation')
keys =
for k in keys:
if 'boto' in k:
del sys.modules[k]

import boto3
print('boto3 version')
print(boto3.__version__)
  1. 检查代码是否适用于最新的 AWS CLI API

谢谢 萨拉斯