Surya Sekhar Mondal
Surya Sekhar Mondal

Reputation: 179

InvalidInputException error for Availability Zone while creating a connection using boto3 to AWS Glue

I am trying to establish a connection to an RDS instance using Connections in AWS Glue. I am trying to do this using boto3 client and the create_connection() method.

This is what I have so far

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

This is the error I am receiving

{
  "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)"
    ]
  ]
}

I have tried with other AZ but to no avail. Thoughts?

Upvotes: 0

Views: 3789

Answers (1)

Abraham
Abraham

Reputation: 443

Making the USERNAME and PASSWORD in uppercase works.

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

Upvotes: 2

Related Questions