【问题标题】:InvalidInputException error for Availability Zone while creating a connection using boto3 to AWS Glue使用 boto3 创建与 AWS Glue 的连接时,可用区出现 InvalidInputException 错误
【发布时间】:2020-04-16 17:12:08
【问题描述】:

我正在尝试使用 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 但无济于事。 想法?

【问题讨论】:

标签: boto3 aws-glue


【解决方案1】:

使用大写的用户名和密码。

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'
            }
        }
    )

【讨论】:

    猜你喜欢
    • 2022-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-14
    • 2019-01-04
    • 1970-01-01
    • 2020-12-11
    • 2016-05-30
    相关资源
    最近更新 更多