how to get the RDS snapshot list last 24 hours list by using the lambda functions

0 votes
Sep 24, 2020 in AWS by shaik
• 140 points
3,081 views

1 answer to this question.

0 votes

Hi@shalk,

You can list down your RDS snapshot. But you need to customize your script according to your requirement. You can take help from the below given script.

import
boto3
import datetime
def lambda_handler(event, context):
  client = boto3.client('rds')
  client.create_db_snapshot(
  DBInstanceIdentifier='web-platform-slave',
  DBSnapshotIdentifier='web-platform-%s' %
  datetime.datetime.now().strftime("%y-%m-%d-%H"),
  )
  for snapshot in
    client.describe_db_snapshots(DBInstanceIdentifier='web-platform-slave',
    MaxRecords=50)['DBSnapshots']:
    if create_ts < datetime.datetime.now() -
    datetime.timedelta(days=7):
    print "Deleting snapshot id:", snapshot['DBSnapshotIdentifier']
    client.delete_db_snapshot(
    DBSnapshotIdentifier=snapshot['DBSnapshotIdentifier']
answered Sep 24, 2020 by MD
• 95,460 points

Related Questions In AWS

+1 vote
1 answer

How to load CSV data to RDS Aurora table using lambda?

Launch an Amazon RDS MySQL database engine ...READ MORE

answered Jul 26, 2018 in AWS by Priyaj
• 58,020 points
4,648 views
0 votes
1 answer

How to list the contents of Amazon S3 by modified date?

One easy solution would be probably to ...READ MORE

answered Aug 21, 2018 in AWS by datageek
• 2,540 points
53,604 views
0 votes
1 answer

How to get the last stopped time & date of EC2 instance?

Hi@akhtar, To get the details of your last ...READ MORE

answered Jun 16, 2020 in AWS by MD
• 95,460 points
14,197 views
+1 vote
3 answers

How to get ARN for s3 Bucket using aws cli .

An ARN is a non-opaque, constructible identifier, ...READ MORE

answered Aug 16, 2018 in AWS by Priyaj
• 58,020 points
5,645 views
0 votes
1 answer
0 votes
1 answer

How to get AWS account/service cost using CloudWatch API?

You can check this link for a ...READ MORE

answered Jul 13, 2018 in AWS by Priyaj
• 58,020 points
923 views
0 votes
1 answer

how to get the list of aws services i am used in aws my account by using the lambda function

Hi@shalk, You can create a session in your ...READ MORE

answered Sep 24, 2020 in AWS by MD
• 95,460 points
2,456 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP