“AWS Secret Manager NodeJS” Respostas de código

Gerente secreto da AWS Nodejs JavaScript

const AWS = require("aws-sdk");
const region = your region;

const credentials = new AWS.SharedIniFileCredentials({
  profile: "secret-manager",
});

AWS.config.credentials = credentials;

const client = new AWS.SecretsManager({
  region: region,
});

const createSecrets = async (params) => {
  const response = await new Promise((resolve, reject) => {
    client.createSecret(params, (err, result) => {
      if (err) reject(err);
      if (result) {
        resolve(result);
      }
    });
  });
  return response;
};

const getSecrets = async (SecretId) => {
  const response = await new Promise((resolve, reject) => {
    client.getSecretValue({ SecretId }, (err, result) => {
      if (err) reject(err);
      if (result) {
        resolve(result.SecretString);
      }
    });
  });
  return JSON.parse(response);
};

module.exports = { getSecrets, createSecrets };
Aayush

AWS Secret Manager NodeJS

const AWS = require("aws-sdk");
const region = your region;

const credentials = new AWS.SharedIniFileCredentials({
  profile: "secret-manager",
});

AWS.config.credentials = credentials;

const client = new AWS.SecretsManager({
  region: region,
});

const createSecrets = async (params) => {
  const response = await new Promise((resolve, reject) => {
    client.createSecret(params, (err, result) => {
      if (err) reject(err);
      if (result) {
        console.log("result", result);
        resolve(result);
      }
    });
  });
  return response;
};

const updateSecrets = async (params) => {
  const response = await new Promise((resolve, reject) => {
    client.updateSecret(params, (err, result) => {
      if (err) reject(err);
      if (result) {
        resolve(result);
      }
    });
  });
  return response;
};

const getSecrets = async (SecretId) => {
  const response = await new Promise((resolve, reject) => {
    client.getSecretValue({ SecretId }, (err, result) => {
      if (err) reject(err);
      if (result) {
        resolve(result.SecretString);
      }
    });
  });
  return JSON.parse(response);
};

module.exports = { getSecrets, createSecrets, updateSecrets };
Determined Dunlin

Respostas semelhantes a “AWS Secret Manager NodeJS”

Perguntas semelhantes a “AWS Secret Manager NodeJS”

Procure respostas de código populares por idioma

Procurar outros idiomas de código