Skip to content

Instantly share code, notes, and snippets.

@beabetterdevv
Created January 9, 2021 02:17
  • Star 13 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save beabetterdevv/487380754349efd0aeac99697c7cc78d to your computer and use it in GitHub Desktop.
DemoHandler
---
def lambda_handler(event, context):
print(event)
return "hello, world!!"
DemoAuthorizer
---
def lambda_handler(event, context):
#1 - Log the event
print('*********** The event is: ***************')
print(event)
#2 - See if the person's token is valid
if event['authorizationToken'] == 'abc123':
auth = 'Allow'
else:
auth = 'Deny'
#3 - Construct and return the response
authResponse = { "principalId": "abc123", "policyDocument": { "Version": "2012-10-17", "Statement": [{"Action": "execute-api:Invoke", "Resource": ["arn:aws:execute-api:us-east-1:YOURACCOUNTNUMBER:2ogoj2ul12/test/GET/customers"], "Effect": auth}] }}
return authResponse
@samindaroshan
Copy link

Thanks for the code shared!!

@Brndcrte
Copy link

Thank you!)

@Frikster
Copy link

How do I tell what the policy document version should be for my case?

@MenukaIshan
Copy link

@Frikster policy document version should be "2012-10-17" it same for everyone

@Subhajit-Paul
Copy link

Thanks Dude for sharing

@avishekpalit
Copy link

Thank you for sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment