![]() I have deeep knowledge and experience on working with various database platforms such as MS SQL Server, PostgeSQL, Oracle, MongoDB, Redshift, Dyanamodb, Amazon Aurora. I work with developers to architect, build, and manage cloud infrastructure, and services. I am currently working as Sr Cloud Architect with focus on Cloud Infrastructure, Big Data. I love learning new technologies and share my knowledge to community. I’m a passionate IT professional with over 14 years of experience on providing solutions for customers who are looking on cloud computing, Database Migration, Development, and Big Data. You can see the results that host is updated to. Let’s see the results in the database. ![]() Here you go lambda is successfully executed.In this example function name is UpdateHost_Python as shown in below After creating test even you can run the lambda by clicking test before that make sure lambda function name is updated to function name you created.This will prompt you to create test even as below Now, we have lambda deployed and run the lambda for testing.I’ve created a security group and attached to lambda. ![]() You need to create a security group that have access to PostgreSQL database from the lambda. Next, Here comes to access to Database from lambda.Once you create the lambda, then combine both step1 and step2 as one zip file and upload the zip file in lambda you may download the combined zip file here In the above screenshot I’ve created a test_lambda_role iam role to get access to lambda services.It calls the function to update.Ĭonn_string = "dbname='test' port='5432' user='username' password='password' host='RDSEndpoint'"Ĭursor.execute("select system_env_host('')") Write a sample lambda that updates the url in the table.I’ve built a custom compiled python library to connect to latest PostgreSQL 9.6 database using this. Build a PostgreSQL psycopg module in order to connect to database.In this post i would like to show an example of lambda to connect to PostgreSQL database and execute the query. Parameters Group in RDS should be configured to log slow queries.It’s been long time since i wrote a blog post.There is a parameter named ‘distinguisher’ which is actually the keyword specifying the occurrence of slow query.You are also asked to do this when creating Lambda function. To find out how to define required rules, please see this AWS documentation. The lamda function should have some permissions to get RDS Logs and send alerts using SNS.In this case, using CloudWatch Events to schedule it periodically makes sense. As you may know, there are some ways to trigger a Lambda function.You can find the code here but there are some other things to be considered: ![]() Of course slow queries are important for developers as it helps them to debug better and improve performance of the application. There are lots of use cases for Lambda functions here I used it to implement a service which sends alerts in case there is a slow query running in RDS. Lambda functions are just another great tool provided by AWS to solve issues in a modern way! Using Lambda functions, you can run a micro service without a need to have a server and think of how to configure and maintain it!
0 Comments
Leave a Reply. |