| 123456789101112131415161718192021 |
- import { writeFile } from "fs/promises";
- import { join } from "path";
- import { ConfigFileAuthenticationDetailsProvider, InstancePrincipalsAuthenticationDetailsProviderBuilder } from "oci-common";
- import { SecretsClient } from "oci-secrets";
- const configPath = process.env.OCI_CONFIG_PATH;
- const configProfile = process.env.OCI_CONFIG_PROFILE;
- const mountPath = process.env.MOUNT_PATH || "";
- const secretName = process.env.SECRET_NAME || "secret";
- (async () => {
- const authProvider = configPath || configProfile
- ? new ConfigFileAuthenticationDetailsProvider(configPath, configProfile)
- : await new InstancePrincipalsAuthenticationDetailsProviderBuilder().build();
- const vault = new SecretsClient({ authenticationDetailsProvider: authProvider });
- const secretResponse = await vault.getSecretBundleByName({ vaultId: "ocid1.vault.oc1.iad.b5rus2i4aadd4.abuwcljrbitufodxbxctfhkdg3g54svlhxszh6kr5odha2pmtzcjc45waw6q", secretName })
- const secret = Buffer.from(secretResponse.secretBundle.secretBundleContent?.content ?? "", "base64").toString();
- await writeFile(join(mountPath, secretName), secret);
- })();
|