I am trying to use something like this to execute a sql script to create the table and users:
data "local_file" "sql_script" {
filename = "${path.module}../infra-main/db.sql"
}
resource "null_resource" "setup_db" {
depends_on = [aws_db_instance.grafana-db]
provisioner "local-exec" {
command = "mysql -u ${var.username} -p${var.password} -h ${aws_db_instance.grafana-db.address} < ${data.local_file.sql_script.content}"
}
}
But I don't understand what to put for the file path. Everything I try, it says "no such file or directory". The path I'm using is from my IDE.
I figured it out, the specified file path should look like this: "${path.module}/db.sql"