Lambda to migrate the database

As we have seen in Chapter 3, Designing a Kotlin Serverless Application, we are using Liquibase to migrate the database. Also, note that the RDS instance that we created now is in a private subnet in a VPC, and hence does not have any public accessibility. We therefore create a lambda function that can migrate the database. Its configuration is found in/resources/functions/databaseMigrator.yml.

The contents of this are as follows:

databaseMigrator:  handler: com.packt.serverless.kotlin.letspoll.handlers.DatabaseMigrator  environment:    databaseUsername: ${env:LP_DATABASE_USERNAME}    databasePassword: ${env:LP_DATABASE_PASSWORD}    databaseUrl: { Fn::GetAtt: [ "letsPollDatabase", "Endpoint.Address" ] }    databasePort: ${env:LP_DATABASE_PORT} ...

Get Hands-On Serverless Applications with Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.