title: how to invoke bash script with aws lambda function in python?
body: <p>I want to invoke a bash script with name <code>myScript.sh</code> in a newly created lambda function.</p>
  
  <p>Step 1: I created a lambda function with name <code>myLambda.py</code> and the source code like:</p>
  
  <pre><code>import subprocess
  print("start") 
  subprocess.call("./myScript.sh")"
  </code></pre>
  
  <p>Step 2: Create a bash script with name <code>myScript.sh</code> under the same path with <code>myLambda.py</code></p>
  
  <p>Step 3: Click the test button and got the response:</p>
  
  <pre><code>{
    "errorMessage": "[Errno 13] Permission denied: './myScript.sh'"
  }
  </code></pre>
  
  <p>Anybody knows how to deal with the permission denied issue in aws lambda function env?</p>
  
  <p>Since the files are added as the guideline in <a href="https://docs.aws.amazon.com/lambda/latest/dg/code-editor.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/lambda/latest/dg/code-editor.html</a>, it's not helpful to use linux command "chmod +x " to change the file permission.</p>
  
  <p>It's resolved by move myScript.sh to /tmp folder and add permission change command:</p>
  
  <pre class="lang-py prettyprint-override"><code>subprocess.run(["chmod", "+x", "/tmp/myScript.sh"])
  </code></pre>