lambda call aurora global database

0

I use lambda (python) to connect aurora global database to query data。 use response = boto3.client('rds').describe_global_clusters(GlobalClusterIdentifier='global database name') ...... response = boto3.client('rds').describe_db_clusters(DBClusterIdentifier='cluster id') Get the Endpoint and DatabaseName of the aurora global database then use pymysql.connect(host=Endpoint, user=user,password=password, database=database) connect to the database

When my lambda has a vpc, the database can be connected successfully, but the endpoint cannot be obtained。

When the vpc is deleted, the endpoint can be obtained normally, and the database cannot be connected。

1개 답변
2

When a Lambda function runs in a default VPC, it has access to the internet but no access to private resources in your VPC. When the function is attached to your VPC, it has access to the private resources, but it looses the access to the internet. To regain that access, you need to add a VPC endpoint for the AWS services you want to access or a NAT gateway to access the rest of the internet of AWS services that do not support VPC endpoints.

All the client('rds') calls are trying to access the RDS service public endpoint. As such you need to create an RDS VPC endpoint.

An alternative would be to configure an environment variable that contains the connection string so that you do not need to find it every time.

profile pictureAWS
전문가
Uri
답변함 일 년 전

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

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

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