How to use the aws-sdk.SSM function in aws-sdk

To help you get started, we’ve selected a few aws-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github middyjs / middy / src / middlewares / ssm.js View on Github external
const getSSMInstance = awsSdkOptions => {
  // lazy load aws-sdk and SSM constructor to avoid performance
  // penalties if you don't use this middleware

  // AWS Lambda has aws-sdk included version 2.176.0
  // see https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html
  const { SSM } = require('aws-sdk')
  return new SSM(awsSdkOptions)
}
github awslabs / amplify-video / provider-utils / awscloudformation / cloudformation-templates / livestream-helpers / LambdaFunctions / psdemo-js-live-workflow_v0.4.0 / lib / babelfish.js View on Github external
async deleteParameterStore(ingestEndpoints) {
    try {
      const ssm = new SSM({ apiVersion: '2014-11-06' });
      const promises = ingestEndpoints.map((x, idx) =>
        ssm.deleteParameter({
          Name: `${this.ssmKey}-${idx}`,
        }).promise());
      await Promise.all(promises);
      return true;
    } catch (e) {
      console.error(e);
      return false;
    }
  }
github Dynatrace / AWSDevOpsTutorial / lambdas / utils / dtapiutils.js View on Github external
var getSystemParameter = /*async*/function(paramName, cachedValue, callback) {
    if(cachedValue && (cachedValue != null)) {
        if(callback) callback(null, cachedValue);
        return cachedValue;
    }
    
    if(process.env[paramName]) {
        cachedValue = process.env[paramName];
        if(callback) callback(null, cachedValue);
    } else {
        var ssm = new AWS.SSM();
        /*await*/ssm.getParameter({Name : paramName}).promise()
        .then(data => { 
            cachedValue = data.Parameter["Value"];
            console.log("Successfully retrieved " + paramName + ": " + cachedValue);
            if(callback) callback(null, cachedValue);
        })
        .catch(err => { 
            console.log("Error Retrieving " + paramName + ": " + err);
            cachedValue = null;
            if(callback) callback(err, null);
        });
    }
    
    return cachedValue;
}
github architect / functions / src / tables / lookup-tables.js View on Github external
module.exports = function lookupTables(callback) {
  let ssm = new aws.SSM
  let Path = `/${process.env.ARC_CLOUDFORMATION}`
  ssm.getParametersByPath({Path, Recursive:true}, function done(err, result) {
    if (err) callback(err)
    else {
      let table = param=> param.Name.split('/')[2] === 'tables'
      let tables = result.Parameters.filter(table).reduce((a, b)=> {
        a[b.Name.split('/')[3]] = b.Value
        return a
      }, {})
      callback(null, tables)
    }
  })
}
github communitybridge / easycla / cla-frontend-contributor-console / src / config / scripts / read-ssm.js View on Github external
function requestSSMParameters(variables, stage, region, profile) {
  AWS.config.credentials = new AWS.SharedIniFileCredentials({profile});
  const ssm = new AWS.SSM({region: region});

  const ps = {
    Names: variables,
    WithDecryption: true
  };

  return ssm.getParameters(ps).promise();
}
github awslabs / aws-limit-monitor / source / services / customhelper / lib / index.js View on Github external
async function createSSMParameter(channelKey, hookURLKey, cb) {
  const ssm = new AWS.SSM();
  try {
    const data = await ssm
      .getParameters({Names: [channelKey, hookURLKey], WithDecryption: true})
      .promise();
    LOGGER.log(
      'DEBUG',
      `${JSON.stringify(
        {
          SSMParameter: {
            create: 'true',
            parameters: data.InvalidParameters,
          },
        },
        null,
        2
      )}`
github mattgodbolt / compiler-explorer / lib / aws.js View on Github external
function loadAwsConfig(properties) {
    let region = properties('region');
    if (!region) {
        return Promise.resolve({});
    }
    let ssm = new AWS.SSM({region: region});
    const path = '/compiler-explorer/';
    return ssm.getParametersByPath({
        Path: path
    })
        .promise()
        .then((response) => {
            const map = {};
            response.Parameters.forEach((response) => {
                map[response.Name.substr(path.length)] = response.Value;
            });
            logger.info("AWS info:", map);
            return map;
        })
        .catch((error) => {
            logger.error(`Failed to get AWS info: ${error}`);
            return {};
github ImmutableWebApps / aws-lambda-edge-example / lib / ssm.js View on Github external
const getParameters = ({ region, stage, name }, callback) => {
  try {
    const ssm = new SSM({ region })
    const Names = parameterNames.map(
      k => ['/app', name, stage, k].join('/')
    )
    const params = { Names }
    ssm.getParameters(params, callback)
  } catch (error) {
    callback(error)
  }
}
github Dynatrace / dynatrace-api / third-party-synthetic / aws-cloudwatch / dynatrace-canary-exporter.js View on Github external
async function getParameter(name, region) {
            const config = typeof region === 'string' ? { region } : undefined;
            const parameterStore = new AWS.SSM(config);
            return new Promise((resolve, reject) => parameterStore.getParameter(
                { Name: name, WithDecryption: true },
                (error, data) => error ? reject(error) : resolve(data.Parameter.Value),
            ));
        }