Advertisement
Guest User

Untitled

a guest
Oct 13th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. PROJECT = myProject
  2. FUNCTION = $(PROJECT)
  3. REGION = ap-southeast-1
  4. ROLE = arn:aws:iam::123456789012:role/service-role/myLambdaRole
  5.  
  6. createFunction:
  7. aws lambda create-function \
  8. --region $(REGION) \
  9. --function-name $(PROJECT) \
  10. --zip-file fileb://$(FUNCTION).zip \
  11. --role $(ROLE) \
  12. --environment Variables="{HOST='0.0.0.0',PORT=22,USERNAME='user',PASSWORD='password',REMOTEFILE='to/remote/file'}" \
  13. --handler $(PROJECT).handler \
  14. --runtime python2.7 \
  15. --profile <adminuser> \
  16. --timeout 10 \
  17. --memory-size 1024
  18.  
  19. packageDependencies:
  20. zip -r9 $(FUNCTION).zip $(PROJECT).py
  21. mkdir -p site-packages
  22. virtualenv $(FUNCTION)
  23. . $(FUNCTION)/bin/activate; pip install -r requirements.txt;\
  24. cd site-packages; cp -r $$VIRTUAL_ENV/lib/python2.7/site-packages/ ./;\
  25. cp -r $$VIRTUAL_ENV/lib64/python2.7/site-packages/ ./;\
  26. cd site-packages; zip -r9 ../../$(FUNCTION).zip .
  27.  
  28. updateFunction:
  29. aws lambda update-function-code \
  30. --region $(REGION) \
  31. --function-name $(PROJECT) \
  32. --zip-file fileb://$(FUNCTION).zip \
  33. --publish\
  34. --profile <adminuser>
  35. manualInvoke:
  36. aws lambda invoke \
  37. --invocation-type RequestResponse \
  38. --function-name $(FUNCTION) \
  39. --region $(REGION) \
  40. --profile <adminuser> \
  41. outputfile.txt
  42.  
  43. deleteFunction:
  44. aws lambda delete-function \
  45. --function-name $(FUNCTION) \
  46. --region $(REGION) \
  47. --profile <adminuser>
  48.  
  49. # Schedule the Lambda Function
  50. # Step 1:
  51. createRule:
  52. aws events put-rule \
  53. --region $(REGION) \
  54. --name $(FUNCTION)-rule \
  55. --schedule-expression 'cron(0/5 8-17 ? * MON-FRI *)' \
  56. --profile <adminuser>
  57.  
  58. # $(ARNRULE) is taken from the put-rule target output and parsed in
  59. # ARNRULE=arn:aws:events:.....
  60. # Step 2:
  61. addPermission:
  62. aws lambda add-permission \
  63. --region $(REGION) \
  64. --function-name $(FUNCTION) \
  65. --statement-id $(FUNCTION)-event \
  66. --action 'lambda:InvokeFunction' \
  67. --principal events.amazonaws.com \
  68. --source-arn $(ARNRULE) \
  69. --profile <adminuser>
  70.  
  71. putTargets:
  72. aws events put-targets \
  73. --region $(REGION) \
  74. --rule $(FUNCTION)-rule \
  75. --targets file://targets.json \
  76. --profile <adminuser>
  77.  
  78. clean:
  79. rm -r $(FUNCTION)
  80. rm -r $(FUNCTION).zip
  81. rm -r site-packages
  82. rm -r outputfile.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement