使用boto3创建到AWS Glue的连接时,Availability Zone出现InvalidInputExcept



我正在尝试使用AWS Glue中的Connections建立到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'
}
}
)

最新更新