OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

AWS SageMaker Jupyter instance connection to RDS proxy failing

  • Thread starter Thread starter Mark lovens Allam
  • Start date Start date
M

Mark lovens Allam

Guest
**> Is there a way to get my sagemaker or multiple sagemakers to access

the RDS Proxy with an existing postgre database.

Basically, I launched a jupyter notebook instance from sagemaker and tried these python codes but they failed.Since its a proxy authentication, my token works but I'm getting a error saying Connection to server , port 5432 faild, password authentication failed for username. Any recommendations on how to connect sagemaker to an RDS proxy postgre database, please. ==================**

Code:
{
import boto3
import psycopg2

###### AWS RDS details
region = '       '  # Sydney region perhaps
db_username = 'your_db_username'
db_endpoint = 'your-rds-proxy-endpoint.amazonaws.com'
db_name = 'your_db_name'

###### Boto3 RDS client
rds_client = boto3.client('rds', region_name=region)

###### Generate IAM authentication token
token = rds_client.generate_db_auth_token(
    DBHostname=db_endpoint,
    Port=5432,
    DBUsername=db_username
)

###### Connect to the database
conn = psycopg2.connect(
    host=db_endpoint,
    port=5432,
    user=db_username,
    password=token,
    dbname=db_name,

sslmode='require'
)

print("Connection established")
}
<p>**> Is there a way to get my sagemaker or multiple sagemakers to access</p>
<blockquote>
<p>the RDS Proxy with an existing postgre database.</p>
<p>Basically, I launched a jupyter notebook instance from sagemaker and
tried these python codes but they failed.Since its a proxy
authentication, my token works but I'm getting a error saying
Connection to server , port 5432 faild, password authentication failed
for username. Any recommendations on how to connect sagemaker to an
RDS proxy postgre database, please.
==================**</p>
</blockquote>
<pre><code>{
import boto3
import psycopg2

###### AWS RDS details
region = ' ' # Sydney region perhaps
db_username = 'your_db_username'
db_endpoint = 'your-rds-proxy-endpoint.amazonaws.com'
db_name = 'your_db_name'

###### Boto3 RDS client
rds_client = boto3.client('rds', region_name=region)

###### Generate IAM authentication token
token = rds_client.generate_db_auth_token(
DBHostname=db_endpoint,
Port=5432,
DBUsername=db_username
)

###### Connect to the database
conn = psycopg2.connect(
host=db_endpoint,
port=5432,
user=db_username,
password=token,
dbname=db_name,

sslmode='require'
)

print("Connection established")
}
</code></pre>
Continue reading...
 
Top