title: Use Google Cloud Secrets when initializing code
body: <p>I have this code to retrieve the secrets:</p>
  <pre><code>import {SecretManagerServiceClient} from &quot;@google-cloud/secret-manager&quot;;
  
  const client = new SecretManagerServiceClient();
  
  async function getSecret(secret: String, version = &quot;latest&quot;) {
      const projectID = process.env.GOOGLE_CLOUD_PROJECT;
      const [vs] = await client.accessSecretVersion({
          name: `projects/${projectID}/secrets/${secret}/versions/${version}`
      });
      const secretValue = JSON.parse(vs.payload.data.toString());
      return secretValue;
  }
  
  export {getSecret};
  </code></pre>
  <p>I would like to replace the <code>process.env.SENTRY_DNS</code> with <code>await getSecrets(&quot;SENTRY_DNS&quot;)</code> but I can't call a promise (<code>await</code>) outside an <code>async</code> function.</p>
  <pre><code>Sentry.init({
      dsn: process.env.SENTRY_DNS,
      environment: Config.isBeta ? &quot;Beta&quot; : &quot;Main&quot;
  });
  
  function sentryCreateError(message, contexts) {
      Sentry.captureMessage(message, {
          level: &quot;error&quot;, // one of 'info', 'warning', or 'error'
          contexts
      });
  }
  </code></pre>
  <p>What are the best practices with Google Secrets?  Should I be loading the secrets once in a &quot;config&quot; file and then call the values from there?  If so, I'm not sure how to do that, do you have an example?</p>