Search code examples
google-cloud-rungoogle-cloud-run-jobs

How to pass secrets to cloud run job


How can i pass secrets to cloud rub job using containerOverrides property i can not find any documentation about this.

I am passing env variables like this but this is visible in cloud run jobs UI and i dont want my secrets leaked.

    const [runOperation] = await jobsClient.runJob({
      name: jobPath,
      overrides: {
        containerOverrides: [
          {
            args: jobArguments,
            env: [
              {
                name: "FIRESTORE_DATABASE_URL",
                value: firestoreDatabaseUrl.value(),
              },
            ],
            
          },
        ],
      },
    });

EDIT:

Found this in the source code is there any examples on how to use it.

  interface IEnvVarSource {

                    /** EnvVarSource secretKeyRef */
                    secretKeyRef?: (google.cloud.run.v2.ISecretKeySelector|null);
                }

Solution

  • I was able to figure it out without documentation like everything in GCP -.-

    PLS GOOGLE START WRITING DOCUMENTATION!

    enter image description here

        const [runOperation] = await jobsClient.runJob({
          name: jobPath,
          overrides: {
            containerOverrides: [
              {
                env: [
                  {
                    name: "ELASTIC_ENTERPRISE_AUTH_TOKEN",
                    valueSource: {
                      secretKeyRef: {
                        secret: "ELASTIC_ENTERPRISE_AUTH_TOKEN",
                        version: "latest",
                      },
                    },
                  },
                ],
              },
            ],
          },
        });