Wednesday, November 14, 2018

Start RDS clusters based on Tag values


Start RDS clusters based on Tag values



Earlier, in my blog post, I have posted an article to "Stop RDS clusters based on Tag values"...

Now let us see how to start every morning just before our office time starts...


Steps to automate RDS starting in AWS:
  1. Login to your AWS account via console
  2. Go to services Lambda -> Author from scratch -> Give a Name; select 'Runtime-> Python2.7; Choose a Role -> Choose an existing Role; Existing Role-> Role that is already available in your account to run the Lambda script
  3. Click on 'Create Function'
  4. Click on your lambda function which expands to the code IDE for writing your python code
  5. Now copy the code from my github account[https://github.com/gvnirmalaa/utilities/blob/master/l_startRDS_UseTags.py] into the Python script IDE
  6. Now, from the designer pane -> click on 'Cloudwatch' -> to select the cloud watch rule which has the definition of scheduling timelines to execute this lambda script
Steps to create Cloud watch Rule:
  1. Goto or select service 'Cloudwatch' in your AWS console/account
  2. Click on 'Rules' -> 'Create Rule' -> 'Event source-> scheduler' -> 'cron expression'  -> define or set the timing by which the lambda script is to be scheduled; for example, 9AM if office time starts at 9AM...
  3. From the top right corner, click on the 'Add Target' -> Lambda -> <<select the lambda function created from above step'
  4. Click on 'Configure Details'
  5. Now a cron scheduler is ready for executing any lambda scripts as per the requirement
Note: the script will work only when you add tags against your existing or new RDS as 'start:yes'


No comments:

Post a Comment