Reputation: 41
I want to connect aws redshift with aws lambda. But this gives me error that connection timed out
Class.forName("com.amazon.redshift.jdbc42.Driver");
System.out.println("\n\nconnecting to database...\n\n");
connStringBuilder = "jdbc:redshift:iam://%s?AccessKeyID=%s&SecretAccessKey=%s&DbUser=%s&SessionToken=%s";
connString = String.format(connStringBuilder, redshiftClusterURL, accessKeyId, secret, dbUser, token);
System.out.println("connString is " + connString);
conn = DriverManager.getConnection(connString);
Upvotes: 2
Views: 4398
Reputation: 148
Just ensure these steps and let me know if your problem exists:
First Ensure that your aws lambda function is running in VPC if its running in VPC you need to configure NAT gateway to connect to the internet and open the outbound port for the database
In redshift db open the inbound port for the specified IP ranges of your VPC.
If your aws lambda is not running in VPC.
Upvotes: 1