“AWS Secret Manager Nodejs” Ответ

AWS Secret Manager 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

Ответы похожие на “AWS Secret Manager Nodejs”

Вопросы похожие на “AWS Secret Manager Nodejs”

Смотреть популярные ответы по языку

Смотреть другие языки программирования