title: How do i write aws cli commands in python
body: <p>I am new to AWS as well as Python.</p>
  
  <p>AWS CLI, the below command is working perfectly fine:</p>
  
  <pre><code>aws cloudformation package --template-file sam.yaml --output-template-file output-sam.yaml --s3-bucket &lt;&lt;bucket_Name&gt;&gt;
  </code></pre>
  
  <p>The goal is to create automate python script which will run the above command. I tried to google it but none of the solutions is working for me. </p>
  
  <p>Below are the solution that I have tried but not able to upload the artifacts onto the S3 bucket.</p>
  
  <p>test.py file:</p>
  
  <pre><code>import subprocess
  command= ["aws","cloudformation","package","--template-file","sam.yaml","--output-template-file","output-sam.yaml","--s3-bucket","&lt;&lt;bucket_name&gt;&gt;"]
  print(subprocess.check_output(command, stderr=subprocess.STDOUT))
  </code></pre>