Restore AWS RDS snapshot with Jenkins job

I would like to create a job that can restore a AWS RDS database snapshot. Does anyone have any recommendations on how to do this or examples from somewhere on the web?

How would you do it via cli? Then people can help you automate that

Based on this doc, something like this via the aws cli:

aws rds restore-db-instance-from-db-snapshot \
    --db-instance-identifier db7-new-instance \
    --db-snapshot-identifier db7-test-snapshot \
    --db-instance-class db.t3.small

That seems super straight forward then, in declarative pipeline:

pipeline {
    agent any
    stages {
        stage('Example') {
            steps { 
                sh('''
                    aws rds restore-db-instance-from-db-snapshot \
                    --db-instance-identifier db7-new-instance \
                    --db-snapshot-identifier db7-test-snapshot \
                    --db-instance-class db.t3.small
                ''')
            }
        }
    }
}

What parts would you help with next?

1 Like

Wow straight forward for sure. Looks like it should work. I’m going to make this job once I’m back at the office and report back here and mark as solution assuming it works. Thank you very much.