GoogleCloudPlatform / cloud-run-button

Let anyone deploy your GitHub repos to Google Cloud Run with a single click
https://cloud.run
Apache License 2.0
526 stars 91 forks source link

Enable precreate to Provision Resources #129

Open jamesward opened 4 years ago

jamesward commented 4 years ago

Once we get #76 any resource provisioning will have to happen in postcreate because there is no way to propagate the config to the create command or env vars. This means the app is created with missing resources which could cause the app deployment to fail (depending on how the app is built). It's tough to generalize the passing of config from precreate scripts to our cloudshell_open because sometimes an env var is needed, sometimes multiple, and sometimes additional params for gcloud run deploy. So while it'd be really nice to do provisioning in precreate I don't really see a good way to make it work. The only way I can come up with so far is to have precreate optionally write a /tmp/create-$K_SERVICE file that could contain something like:

{
    "envs": {
        "CLOUD_SQL_CONNECTION_NAME": "foo-project:us-central1:my-foo-db"
    },
    "params": [
        "--set-cloudsql-instances=my-foo-db"
    ]
}

Then if that file exists our cloudshell_open would merge that config with it's own for service creation. But I don't love this approach.

This would be an alternative to #74