async function createSSMParameter()

in source/lambda/services/customhelper/lib/index.js [465:515]


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
      )}`
    );
    await Promise.all(
      data.InvalidParameters.map(async ssmParam => {
        console.log(ssmParam);
        await ssm
          .putParameter({
            Name: ssmParam /* required */,
            Type: 'String' /* required */,
            Value: 'SLACK_DUMMY' /* required */,
          })
          .promise();
      })
    );
    // successful response 👌
    cb('slack ssm parameter creation done');
  } catch (err) {
    LOGGER.log(
      'ERROR',
      `${JSON.stringify(
        {
          SSMParameter: {
            channelKey: channelKey,
            hookKey: hookURLKey,
            response: err,
          }, // an error occurred 🔥
        },
        null,
        2
      )}`
    );
    cb(err);
  }
}