Error in connect to Mysql in RDS by using IAM through Python code.

0

I am trying to connect with Mysql DB instance (inside RDS) using IAM permissions from EMR(pyspark) for test purpose i have provided policy 'AmazonRDSFullAccess' to my EMR role, and trying below python code

pymysql.connect(host=host, user=user, passwd='mypswd', ssl=ssl)

and i am getting error as

pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '-.eu-central-1.rds.amazonaws.com' (timed out)")

The above code is working fine if i add my EMR cluster IP address in inbound rule of the security group attached in the db instance.

But my requirement is to connect with the db instance with just by using IAM since my IP address is dynamic(each time I create new EMR cluster), so each time i cannot add a new IP in security group and i do not want to allow all ip(0.0.0.0) in inbound rule,

질문됨 8달 전240회 조회
1개 답변
0

Hello.

Security group settings are required even for RDS IAM authentication.

I don't think it is necessary to allow it with 0.0.0.0/0 if you set the security group associated with EMR as the security group source for RDS.
https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-man-sec-groups.html

profile picture
전문가
답변함 8달 전
profile picture
전문가
검토됨 8달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠