Skip to content

Instantly share code, notes, and snippets.

@yicr
Last active June 12, 2020 10:39
Show Gist options
  • Save yicr/1959d21ad5e4445a7000583abecb2589 to your computer and use it in GitHub Desktop.
Save yicr/1959d21ad5e4445a7000583abecb2589 to your computer and use it in GitHub Desktop.
const generatePolicy = function(principalId, effect, resource) {
const authResponse = {};
authResponse.principalId = principalId;
if (effect && resource) {
const policyDocument = {};
policyDocument.Version = '2012-10-17'; // default version
policyDocument.Statement = [];
const statementOne = {};
statementOne.Action = 'execute-api:Invoke'; // default action
statementOne.Effect = effect;
statementOne.Resource = [
// resource,
"arn:aws:execute-api:ap-northeast-1:s:todo/todo/*",
];
policyDocument.Statement[0] = statementOne;
authResponse.policyDocument = policyDocument;
}
return authResponse;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment