How to create & seed database with Elastic Beanstalk & Terraform

I’m writing a Terraform configuration to deploy a Rails API on Elastic Beanstalk.

On the first deploy i need to create & seed the database.

How can i achieve this?

  • Ideally i would use EB container commands, but i don’t see any documentation on how you are supposed to declare them inside Terraform.

  • Running a shell script locally & running eb ssh, doesn’t work because there is no way of telling eb what environment i want to connect to without a elastic beanstalk config file.

So what can i do? There must be a way to do this.