@kdcsoftware/aws-policy
v0.2.0
Published
[![ver](https://img.shields.io/npm/v/@kdcsoftware/aws-policy?style=for-the-badge)](https://www.npmjs.com/package/@kdcsoftware/aws-policy) [![build](https://img.shields.io/github/workflow/status/kdcsoftware/aws-policy/build?style=for-the-badge)](https://gi
Downloads
14
Readme
AWS Policy Generator
This package will generate AWS auth policy for API Gateway lambda authorizer.
Install
npm i @kdcsoftware/aws-policy
Usage
const generatePolicy = require('@kdcsoftware/aws-policy');
exports.handler = function (event) {
const user = {
name: 'Ian',
username: 'ian',
role: 'admin',
};
const resources = [
'GET/users',
'POST/users',
'GET/users/*',
'PUT/users/*',
'DELETE/users/*',
];
return generatePolicy({
context: { ...user },
principalId: user.username,
effect: 'Allow',
methodArn: event.methodArn,
resources,
});
};