amazon web services - AWS CLI create Lambda function cannot unzip uploaded file -
i'm trying create aws lambda function using aws cli. generated json input skeleton use aws lambda create-function
function passing in --generate-cli-skeleton
parameter , substituting values accordingly.
the problem when execute command create function gives me error:
a client error (invalidparametervalueexception) occurred when calling createfunction operation: not unzip uploaded file. please check file, try upload again.
this how run command:
aws lambda create-function --cli-input-json file://c:\projects\automated_deployment\lambda_function_deploy.json
the contents of .json file are:
{ "functionname": "myfunction", "runtime": "nodejs", "role": "arn:aws:iam::------------:role/lambda_dynamo", "handler": "index.handler", "code": { "zipfile": "fileb://c:/projects/src/zip/myfunction.zip" }, "description": "description goes here", "timeout": 10, "memorysize": 128, "publish": true }
surprisingly if try create function without using json file , providing parameters in command-line works. instance, works without issues @ all:
aws lambda create-function --function-name myfunction --runtime nodejs --role arn:aws:iam::------------:role/lambda_dynamo --handler index.handler --zip-file fileb://c:/projects/src/zip/myfunction.zip
this same .zip file. hints doing wrong here? have tried replacing "zipfile": "fileb://c:/projects/src/zip/myfunction.zip"
with:
"zipfile": "file://c:/projects/src/zip/myfunction.zip"
, "zipfile": "c:/projects/src/zip/myfunction.zip"
issue remains.
edit: found out --debug option can pass cli command. problem tool not reading zipfile when provide input json. instance if run command providing parameters in command itself, can see zip file base64 encoded i.e.:
2016-02-08 10:43:59,831 - mainthread - botocore.endpoint - debug - making request <botocore.model.operationmodel object @ 0x0000000004149f28> (verify_ssl=true) params: {'body': '{"code": {"zipfile": "uesdbbqaaaaiafigpuiloew/nwcaansdaaaiaaaaaw5kzxguano1gdtu2zb0pud+gdvdi2oomrzrbzgici9oc29fysrpx4pcucq65ijlqk .... redacted
but when provide parameters json file i.e. --cli-input-json command base64 encodes value of zipfile key in json (which uri file i.e. fileb://c:/projects/src/zip/myfunction.zip)
now i'm not sure value need provide zipfile key, or bug in tool/command?
edit2: if provide base64 encoded string of zip file, command base64 encode string again gave same error (i.e. cannot unzip.) question field zipfile require? url file:// protocol or fileb:// ? zip file's contents base-64 encoded?
don't know if has solved this. 1 possible solution contents zip file previously. in python can this:
... { "functionname": "myfunction", "runtime": "nodejs", "role": "arn:aws:iam::------------:role/lambda_dynamo", "handler": "index.handler", "code": { "zipfile": "fileb://" + file_get_contents(c:/projects/src/zip/myfunction.zip) }, "description": "description goes here", "timeout": 10, "memorysize": 128, "publish": true } ... def file_get_contents(filename): open(filename) f: return f.read()
i guess can similar in nodejs (https://docs.nodejitsu.com/articles/file-system/how-to-read-files-in-nodejs)
hope helps!!
Comments
Post a Comment