Skip to content

Typescript implementation of AWS API Gateway Lambda Custom Authorizer policy creator

License

Notifications You must be signed in to change notification settings

chesterm8/aws-api-auth-policy-typescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aws-api-auth-policy

Typescript implementation of AWS API Gateway Lambda Authorizer policy creator

Install

$ npm install aws-api-auth-policy

Input

import {ApiOptions, AuthPolicy} from "aws-api-auth-policy";

const userId = "12345";
const awsAccountId = "6789";

const apiOptions: ApiOptions = {};
apiOptions.region = "us-east-1";
apiOptions.restApiId = "restApiId";
apiOptions.stage = "stage";

var authPolicy = new AuthPolicy(userId, awsAccountId, apiOptions);
authPolicy.allowAllMethods();
var generated = authPolicy.build();

var policyJson = JSON.stringify(generated);
console.log(policyJson);

Output

{
  "principalId": "12345",
  "policyDocument": {
    "Version": "2012-10-17",
    "Statement": [
      {
        "Action": "execute-api:Invoke",
        "Effect": "Allow",
        "Resource": [
          "arn:aws:execute-api:us-east-1:6789:restApiId/stage/*/*"
        ]
      }
    ]
  }
}

About

Typescript implementation of AWS API Gateway Lambda Custom Authorizer policy creator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published