Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. mkdir add
  2. cd add
  3. vim main.py
  4.  
  5. def add(event, context):
  6. return event.get('a') + event.get('b')
  7.  
  8. zip main.zip main.py
  9.  
  10.  
  11.  
  12.  
  13. ### choose any IAM role , edit Trust Relationship
  14. and copy "Policy Document"
  15.  
  16. {
  17. "Version": "2012-10-17",
  18. "Statement": [
  19. {
  20. "Effect": "Allow",
  21. "Principal": {
  22. "Service": "lambda.amazonaws.com"
  23. },
  24. "Action": "sts:AssumeRole"
  25. }
  26. ]
  27. }
  28.  
  29. save it as 'basic_lambda_role.json'
  30. aws iam create-role --role-name basic_lambda_role --assume-role-policy-document file:///tmp/basic_lambda_role.json --profile tayseer
  31.  
  32.  
  33.  
  34. aws lambda create-function --function-name add --zip-file fileb://main.zip --role arn:aws:iam::466775254223:role/basic_lambda_role --handler main.add --runtime python2.7 --profile tayseer
  35.  
  36. aws lambda invoke --function-name add --log-type Tail --payload '{"a":1, "b":2 }' --profile tayseer outputfile.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement