“AWS Secret Manager NodeJS” Kod odpowiedzi

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

Odpowiedzi podobne do “AWS Secret Manager NodeJS”

Pytania podobne do “AWS Secret Manager NodeJS”

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu