How to use the middy/middlewares.ssm function in middy

To help you get started, we’ve selected a few middy 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 theburningmonk / manning-aws-lambda-in-motion / functions / get-index.js View on Github external
cloudwatch.incrCount('RestaurantsReturned', restaurants.length);

  const response = {
    statusCode: 200,
    body: html,
    headers: {
      'content-type': 'text/html; charset=UTF-8'
    }
  };

  callback(null, response);
});

module.exports.handler = wrapper(handler)
  .use(ssm({
    cache: true,
    cacheExpiryInMillis: 3 * 60 * 1000, // 3 mins
    setToContext: true,
    names: {
      restaurants_api: `/bigmouth/${STAGE}/restaurants_api`,
      orders_api: `/bigmouth/${STAGE}/orders_api`
    }
  }))
  .use(secretsManager({
    cache: true,
    cacheExpiryInMillis: 3 * 60 * 1000, // 3 mins
    secrets: {
      cognito: `/bigmouth/${STAGE}/cognito`
    }
  }));
github fourTheorem / ai-as-a-service / chapter7-8 / strategy-service / handler.js View on Github external
Object.keys(exports).forEach(key => {
    module.exports[key] = middy(exports[key])
      .use(
        loggerMiddleware({
          logger: log
        })
      )
      .use(
        ssm({
          cache: true,
          names: {
            FRONTIER_URL: `/${process.env.STAGE}/frontier/url`
          }
        })
      )
  })
}
github fourTheorem / ai-as-a-service / chapter7-8 / scheduler-service / handler.js View on Github external
Object.keys(exports).forEach(key => {
    module.exports[key] = middy(exports[key])
      .use(
        loggerMiddleware({
          logger: log
        })
      )
      .use(
        ssm({
          cache: true,
          names: {
            FRONTIER_URL: `/${process.env.STAGE}/frontier/url`
          }
        })
      )
  })
}
github theburningmonk / lambda-config-demo / functions / withMiddleware.js View on Github external
const middy = require('middy')
const { ssm } = require('middy/middlewares')

const handler = async (event, context) => {
  let resp = {
    foo: process.env.FOO,
    bar: process.env.BAR,
    jet: process.env.JET,
    pack: process.env.PACK,
  }
  return resp
}

module.exports.handler = middy(handler).use(ssm({
  cache: true,
  names: {
    FOO: 'foo',
    BAR: 'bar',
    JET: 'jet',
    PACK: 'pack',
  }
}))
github fourTheorem / slic-starter / slic-tools / middy-util.js View on Github external
Object.keys(exports).forEach(key => {
    const handler = middy(exports[key])
      .use(
        loggerMiddleware({
          logger: log
        })
      )
      .use(httpEventNormalizer())
      .use(jsonBodyParser())
      .use(cors())
      .use(autoProxyResponse())
      .use(httpErrorHandler())

    if (options.ssmParameters && process.env.SLIC_STAGE !== 'test') {
      handler.use(
        ssm({
          cache: true,
          names: options.ssmParameters,
          awsSdkOptions: {
            endpoint: process.env.SSM_ENDPOINT_URL
          }
        })
      )
    }
    result[key] = handler
  })
  return result