Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 12, 2022 07:58 am GMT

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.


Original Link: https://dev.to/rajitpaul/modify-rds-instance-type-using-lambda-during-peak-hours-with-cloudwatch-events-29hi

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To