Created
May 25, 2023 18:25
-
-
Save cmbirk/36580d20e6ffd0c302289fa0b6734ceb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {SecretManagerServiceClient} from '@google-cloud/secret-manager' | |
const projectId = 'project-id' | |
// Instantiates a client | |
const client = new SecretManagerServiceClient(); | |
export const accessSecretVersion = async (secretName) => { | |
const [version] = await client.accessSecretVersion({ | |
name: `projects/${projectId}/secrets/${secretName}/versions/latest`, | |
}); | |
// Extract the payload as a string. | |
const secretValue = version.payload.data.toString(); | |
return secretValue | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment