Skip to content

Instantly share code, notes, and snippets.

View theigor's full-sized avatar
:shipit:

Igor Belagorudsky theigor

:shipit:
  • Boston, MA
View GitHub Profile
@theigor
theigor / secrets.ts
Last active May 4, 2020 18:33
Node/Typescript service to get Google Secret Manager secrets by name
import { SecretManagerServiceClient } from '@google-cloud/secret-manager';
// I like to define them explicitly so devs know what's out there.
type SECRETS = "SOME_ENV_VAR" | "SOME_OTHER_ONE";
const client = new SecretManagerServiceClient();
export async function getSecret(name: SECRETS) {
// you can get more sophistacted here with different environments but that wasn't needed for my case
if (process.env.NODE_ENV === "production") {