1.9.1 • Published 1 year ago
common-aws-utils v1.9.1
AWS Node Utilities
This project contains common services to simplify working with the AWS node sdk. It includes services for the following AWS services:
- SSM (e.g. find parameter values)
- S3 (e.g. read/write objects)
- Email (e.g. send email)
- API Gateway (e.g. REST API calls)
Installation
To leverage this utility in other projects run the following commands:
# Core util
npm --registry=https://registry.npmjs.org/ install common-aws-utils
# Needed to sign API calls
npm install aws4
If this is being used in a AWS lambda then the following packages should be installed as dev only since it is included by default in the lambda runtime and the zip should be as small as possible
npm install --save-dev aws-sdk
Example (how to use this library)
const API_SRV = require('common-aws-utils').AwsApiService;
const SSM_SRV = require('common-aws-utils').AwsSsmService;
const S3_SRV = require('common-aws-utils').AwsS3Service;
const EMAIL_SRV = require('common-aws-utils').AwsEmailService;
// SSM service
const SSM_PATH = process.env.SSM_PATH;
const ssmParams = await SSM_SRV.getParamsByPath(SSM_PATH, true);
// API service
const response = await API_SRV.post(base, path, data, params, headers);
// S3 service
const s3Data = await S3_SRV.getObject(bucket, key);
// Email service
const emailResponse = await EMAIL_SRV.sendEmail(
'"Reporting Teams" <aziz.ahmed@act.org>',
userEmail,
`${ssmParams.EMAIL_NOTIFICATION_SUBJECT}`,
JSON.stringify(message)
);