Hey :slightly_smiling_face: I am looking at deplo...
# general
c
Hey 🙂 I am looking at deploying a Nextjs application as a Google Cloud Run Service. https://next-auth.js.org/ I am using this for authentication, and one of the environment variables that is needed is
NEXTAUTH_URL
which should be the URL used on deployed instance, however, for my staging environment this is dynamic and not known e.g.
Copy code
const app = new gcp.cloudrun.Service(`app`, {
  location,
  template: {
    spec: {
      containers: [
        {
          // Use pushed image from CI (assume local if not)
          image: pulumi.interpolate`<http://gcr.io/${gcp.config.project}/app:${prNumber}|gcr.io/${gcp.config.project}/app:${prNumber}>`,
          ports: [{ containerPort: 3000 }],
          resources: {
            limits: {
              memory: `1Gi`,
            },
          },
        },
      ],
      containerConcurrency: 50,
    },
  },
  metadata: {
    annotations: {
      "<http://run.googleapis.com/cloudsql-instances|run.googleapis.com/cloudsql-instances>": pgInstance.connectionName,
    },
  },
});
e.g. yields https://some-chars.a.run.app and is available as
Copy code
// Export the URL
export const appUrl = app.statuses[0].url;
But I am not sure you can include setting this back to the cloud run env variable?
a
It sounds like you want to use the resource outputs of an object that doesn't exist yet, to create that object. Which is obviously not going to work. Based on https://next-auth.js.org/getting-started/example,
NEXTAUTH_URL
looks intended to be a "friendly" name for a user to interact with. My guess is you need to pick a friendly name
<http://blah.mydomain.com|blah.mydomain.com>
and then create a the dns entry by hand or based on the output of
app.statuses[0].url.get()
.
c
Yeah it looks like best approach is to include a
DomainMapping
and then this way I can categorically know what my domain will be e.g.
<http://staging.domain.com|staging.domain.com>
and not use the dynamic url's that are output, this way it is safe. I think that this has to be set for production deploys rather than for users (AFAIK) - bit of a funny req