2. Steps
1. Create a new Administrator user in the IAM
2. Create a Role and allow Lambda execution and permissions for S3
operations
3. Take note of the User ARN
4. Deploy 64-bit Amazon Linux EC2 instance
5. SSH in, make project directory/folder
6. Create requirements.txt file, list python packages (except boto3)
7. Write the Handler
8. Zip up code and Dependencies
9. Create Lambda Function
10. Manually invoke the Lambda Function
11. Create the schedule
6. Makefile
manualInvoke:
aws lambda invoke
--invocation-type RequestResponse
--function-name $(FUNCTION)
--region $(REGION)
--profile Administrator
outputfile.txt
Manually Invoke the Lambda function to test it
7. Makefile
# Schedule the Lambda Function
# Step 1:
createRule:
aws events put-rule
--region $(REGION)
--name $(FUNCTION)-rule
--schedule-expression 'cron(0/5 8-17 ? * MON-FRI *)'
--profile Administrator
Schedule the Lambda function : Create the rule
8. Makefile
# $(ARNRULE) is taken from the put-rule target output and parsed in
# ARNRULE=arn:aws:events:.....
# Step 2:
addPermission:
aws lambda add-permission
--region $(REGION)
--function-name $(FUNCTION)
--statement-id $(FUNCTION)-event
--action 'lambda:InvokeFunction'
--principal events.amazonaws.com
--source-arn $(ARNRULE)
--profile Administrator
Schedule the function : Give permission to the event
9. Makefile
Schedule the function : Associate the Lambda with the Event
putTargets:
aws events put-targets
--region $(REGION)
--rule $(FUNCTION)-rule
--targets file://targets.json
--profile Administrator
[
{
"Id": "1",
"Arn":"arn:aws:lambda:ap-southeast-1:864962608331:function:sftp2s3"
}
]
targets.json