How to create a Cloud Foundry SSH Tunnel via Terrafrom?

Hi everyone.
I have created a Maria DB service on Cloud Foundry and I need to load the SQL schema.
In CF, to do that you have to create a service key, and retrieve the parameters to connect from the service key, as explained here Accessing Services with SSH | Cloud Foundry Docs. After that, you have to create an SSH tunnel via cf ssh -L.

I want to do that via a local-exec provisioner, and here is my code.

resource "cloudfoundry_service_key" "external-service-key" {
name = "ext-service-key"
service_instance =
provisioner "local-exec" {
command = "cf ssh -L 63307:${self.credentials["host"]}:3306 my-python-app && mysql -u ${self.credentials["username"]} -h 0 -p${self.credentials["password"]} -D ${self.credentials["name"]} -P 63307 < db_schema.sql"

but I always get an error connection error

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 

Is that possible and if it is, do you know how?