DEV Community

Rajit Paul
Rajit Paul

Posted on

2 1

Modify RDS Instance Type using Lambda during peak hours with Cloudwatch Events

Hi Folks, hope you are doing good.
Use-case: To modify RDS Instance Type to facilitate load during peak hours using Lambda and Cloudwatch Events

Create a Lambda Function:

  • Author from scratch
  • Function Name - your desired name
  • Runtime - Python 3.9
  • Architecture - x86_64
  • Permissions - Create a new role with basic Lambda Function

Code - (https://raw.githubusercontent.com/RajitPaul11/AWS-Lambda/main/RDS-DB-Modify/lambda_function.py)

Additional IAM Policy for RDS Modify Access:
Policy Json - (https://raw.githubusercontent.com/RajitPaul11/AWS-Lambda/main/RDS-DB-Modify/rds-modifyaccess-iam.json)

  • Add this as an inline policy to the Lambda Default Role

Amazon EventBridge (Cloudwatch Events):
Create a new rule
Rule Name - Desired Rule Name
Pattern - Schedule - Cron Expression (Cronex - 55 7 ? 2 7 * (Every Saturday at 7:55 GMT) - Choose your cron expression according to your requirement
Cron Expression Help - (https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html#CronExpressions)
Select Targets - Target - Lambda Function - Select your function.
Create Cloudwatch Event

We have automated the RDS Instance Type modification, the Cloudwatch Event shall trigger the Lambda Function at the desired time and modify the RDS Instance to an upgraded Instance type, you can also use this for downgrade db instance.

Billboard image

Use Playwright to test. Use Playwright to monitor.

Join Vercel, CrowdStrike, and thousands of other teams that run end-to-end monitors on Checkly's programmable monitoring platform.

Get started now!

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay