AWS Lambda

오픈소스·2022년 6월 1일
0
post-thumbnail

http://kyobo.link/w6gU

exports.myHandler = function(event, context, callback) {
	console.log('value =', event.key);
	callback();
}
$ aws iam create-role --role-name basic-lambda-role --assume-role-policy-document file://policy.json
$ zip -r myFunction.zip index.js
$ aws lambda create-function
	--region us-east-2
    --function-name myFunction
    --zip-file fileb://myFunction.zip
    --role arn:aws:iam:00123456789:role/basic-lambda-role
    --handler index.handler
    --runtime nodejs4.3
    --memory-size 128
$ aws lambda invoke
	--invocation-type RequestResponse
    --function-name myFunction
    --region us-east-2
    --log-type Tail
    --payload '{"key": "value"}'
    output.txt
$ aws lambda list-functions

$ aws lambda get-function --function-name <FUNCTION_NAME>
$ aws lambda get-function-configuration --function-name <FUNCTION_NAME>

$ aws logs get-log-events
	--log-group-name "/aws/lambda/myFunction"
    --log-stream-name "2017/02/07/[$LATEST]1ae6ac9c77384794a3202802c683179a"
  • context
    • getRemainingTimeInMills()
    • callbackWaitsForEmptyEventLoop default: true
    • functionName
    • functionVersion
    • memoryLimitInMB
    • logGroupName
    • logStreamName
    • awsRequestID

배포도구

  • APEX
    • $ curl http://raw.githubusercontent.com/apex/apex/master/install.sh | sudo sh
    • $ mkdir workdir && cd workdir
    • $ apex init -r us-east-1
    • $ apex deploy
    • $ apex invoke hello
    • $ apex logs hello
  • Claudia.js
    • $ npm install claudia -g
    • $ claudia create --region us-east-1 --handler index.handle
    • $ claudia test-lambda

Test

  • Mocha
  • Chai
  • harness

0개의 댓글