Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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 };
Comment

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 };
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to check for enter keyPress in react native 
Javascript :: typescript get class list for element 
Javascript :: date picker javascript not working 
Javascript :: how to use iframe for youtube video in react 
Javascript :: add a socket to a room in socket.io 
Javascript :: submit form react js 
Javascript :: Send Email sgMail 
Javascript :: nginx get request method 
Javascript :: manually set jquery text box 
Javascript :: script tags in react 
Javascript :: data fetch with axios 
Javascript :: lenght validation using jquey valisaton 
Javascript :: javascript time difference 
Javascript :: how to replace div element with another in javascript 
Javascript :: how to attach function to button sweetalert2 
Javascript :: classlist.contain in javascript 
Javascript :: javascript formdata 
Javascript :: libuv nodejs 
Javascript :: jquery validation stop form submit 
Javascript :: angular decorators list 
Javascript :: jquery filtering 
Javascript :: in vs of javascript 
Javascript :: Saving values for metaboxes in wordpress 
Javascript :: adding a if stement in jsx 
Javascript :: instanceof javascript 
Javascript :: js overflowy 
Javascript :: isotope js 
Javascript :: js jwt decode 
Javascript :: convert a string array into object using kerys 
Javascript :: clone array 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =