@kdcio/aws-policy
v0.3.2
Published
Generate AWS auth policy for API Gateway lambda authorizer
Downloads
17
Readme
AWS Policy Generator
This package will generate AWS auth policy for API Gateway lambda authorizer.
Install
npm i @kdcio/aws-policy
Usage
import generatePolicy from '@kdcio/aws-policy';
export const handler = (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,
});
};