Created
May 18, 2020 16:24
-
-
Save rhyskentish/df544d306212dba3763bf79478e8e9c1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const { SecretManagerServiceClient } = require('@google-cloud/secret-manager'); | |
const secretManagerclient = new SecretManagerServiceClient(); | |
const parent = 'projects/<YourProjectId>'; | |
const tokenId = <YourTokenId> | |
async function storeAppLevelSecret(appLevelSecretToStore) { | |
const [secret] = await secretManagerclient.createSecret({ | |
parent: parent, | |
secretId: tokenId, | |
secret: { | |
replication: { | |
automatic: {}, | |
}, | |
}, | |
}); | |
console.log(`Created ${secret}`); | |
const payload = Buffer.from(appLevelSecretToStore, 'utf8'); | |
const [version] = await client.addSecretVersion({ | |
parent: secret.name, | |
payload: { | |
data: payload, | |
}, | |
}); | |
console.log(version.name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment