boto3 - 使用 boto3 创建与 AWS Glue 的连接时,可用区出现 InvalidInputException 错误
问题描述
我正在尝试使用 AWS Glue 中的连接建立与 RDS 实例的连接。我正在尝试使用 boto3 客户端和create_connection()
方法来做到这一点。
这是我到目前为止所拥有的
import json
import boto3
def lambda_handler(event, context):
glue= boto3.client('glue')
response= glue.create_connection(
ConnectionInput={
'Name': 'TEST_CONNECTION',
'ConnectionType': 'JDBC',
'MatchCriteria':[
'string',
],
'ConnectionProperties':{
'JDBC_CONNECTION_URL': 'jdbc:mysql://xxxxx.us-east-1.rds.amazonaws.com:xxxx/xxxx',
'username':'xxxxx',
'password':'xxxxxx'
},
'PhysicalConnectionRequirements':{
'SubnetId':'subnet-xxxxxxxx',
'SecurityGroupIdList':[
'sg-xxxxxxxx',
],
'AvailabilityZone':'us-east-1a'
}
}
)
这是我收到的错误
{
"errorMessage": "An error occurred (InvalidInputException) when calling the CreateConnection operation: Validation for connection properties failed",
"errorType": "InvalidInputException",
"stackTrace": [
[
"/var/task/lambda_function.py",
23,
"lambda_handler",
"'AvailabilityZone':'us-east-1a'"
],
[
"/var/runtime/botocore/client.py",
316,
"_api_call",
"return self._make_api_call(operation_name, kwargs)"
],
[
"/var/runtime/botocore/client.py",
626,
"_make_api_call",
"raise error_class(parsed_response, operation_name)"
]
]
}
我曾尝试与其他 AZ 但无济于事。想法?
解决方案
将 USERNAME 和 PASSWORD 设为大写即可。
import json
import boto3
def lambda_handler(event, context):
glue= boto3.client('glue')
response= glue.create_connection(
ConnectionInput={
'Name': 'TEST_CONNECTION',
'ConnectionType': 'JDBC',
'ConnectionProperties':{
'JDBC_CONNECTION_URL': 'jdbc:mysql://xxxxx.us-east-1.rds.amazonaws.com:xxxx/xxxx',
'USERNAME':'xxxxx',
'PASSWORD':'xxxxxx'
},
'PhysicalConnectionRequirements':{
'SubnetId':'subnet-xxxxxxx',
'SecurityGroupIdList':[
'sg-xxxxxx'
],
'AvailabilityZone':'us-east-1a'
}
}
)
推荐阅读
- c++ - 当我将嵌套的括号初始化列表传递给 C++ 中的构造函数时会发生什么?
- javascript - 如何让 Cypress.io 测试等待 div 的渲染值
- python - 如何通过更改时间段来计算唯一事件分组?
- ios - 尝试在已经呈现“ConfirmUser”的“RoomViewController”上呈现“ChatController”
- python - 在 multiprocessing.Process 中终止 os.system 调用
- networking - 为什么tcp服务器可以获取客户端的ip?
- javascript - 如何在Javascript中计算任何一个月的最后一天?
- reactjs - 在 i18n 中更改系统语言时,URL 中的语言没有更改
- java - 如何获取 PDF 文件中每个单词的字体文件或 PDFont?
- visual-studio-code - 如何在从 GoogleTestAdapter 运行 google 测试之前将 Visual Studio Code 配置为自动构建?