title: AWS CLI create Lambda function cannot unzip uploaded file
body: <p>I'm trying to create an AWS Lambda function using the AWS CLI. So I generated the JSON input skeleton for use with the <code>aws lambda create-function</code> function by passing in the <code>--generate-cli-skeleton</code> parameter and then substituting the values accordingly.</p>
  
  <p>The problem is that when I execute the command to create the function it gives me this error:</p>
  
  <p><code>A client error (InvalidParameterValueException) occurred when calling the CreateFunction operation: Could not unzip uploaded file. Please check your file, then try to upload again.</code></p>
  
  <p>This is how I run the command:</p>
  
  <p><code>aws lambda create-function --cli-input-json file://C:\Projects\Automated_Deployment\lambda_function_deploy.json</code></p>
  
  <p>The contents of the <em>.json</em> file are:</p>
  
  <pre><code>{
      "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
  }
  </code></pre>
  
  <p>Surprisingly if I try to create the function without using the JSON file and providing all the parameters in the command-line then it works. So for instance, this works without any issues at all:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>This is the same .zip file. Any hints as to what am I doing wrong here? I have tried replacing <code>"ZipFile": "fileb://C:/Projects/src/zip/MyFunction.zip"</code> with:</p>
  
  <p><code>"ZipFile": "file://C:/Projects/src/zip/MyFunction.zip"</code> and <code>"ZipFile": "C:/Projects/src/zip/MyFunction.zip"</code> but the issue remains.</p>
  
  <p><strong>EDIT:</strong>
  I found out the --debug option which we can pass to the CLI command. The problem is that the tool is not reading the ZipFile properly when we provide the input from JSON. So for instance if I run the command providing all the parameters in the command itself, I can see the zip file properly base64 encoded i.e.:</p>
  
  <pre><code>2016-02-08 10:43:59,831 - MainThread - botocore.endpoint - DEBUG - Making request for &lt;botocore.model.OperationModel object at 0x0000000004149F28&gt; (verify_ssl=True) with params: {'body': '{"Code": {"ZipFile": "UEsDBBQAAAAIAFiGPUiLOeW/nwcAANsdAAAIAAAAaW5kZXguanO1Gdtu2zb0PUD+gdVDI2OOmrZrBzgICi9OC29FYsRpX4pCUCQ65iJLqk 
  .... 
  redacted
  </code></pre>
  
  <p>But when I provide the parameters from the JSON file i.e. --cli-input-json then the command base64 encodes the value of the ZipFile key in the JSON (which is the URI to that file i.e. fileb://C:/Projects/src/zip/MyFunction.zip)</p>
  
  <p>Now I'm not sure what value we need to provide to the ZipFile key, or is it a bug in the tool/command?</p>
  
  <p><strong>EDIT2:</strong> If I provide the base64 encoded string of my zip file, the command will base64 encode that string again which will gave the same error (i.e. cannot unzip.) So my question is what does the field ZipFile require? A URL with file:// protocol or fileb:// ? Zip file's contents base-64 encoded?</p>