title: sam package vs aws cloudformation package
body: <p><a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-deploying.html#serverless-sam-cli-using-package-and-deploy" rel="noreferrer">The</a> docs say they do exactly the same thing:</p>
  
  <blockquote>
    <p>Both the sam package and sam deploy commands described in this section
    are identical to their AWS CLI equivalent commands aws cloudformation
    package and aws cloudformation deploy, respectively.</p>
  </blockquote>
  
  <p>But my experience suggests that isn't quite true. When I run <code>sam deploy</code> for my Java-based Lambda gets an artifact uploaded to S3 with this type of zip structure:</p>
  
  <ul>
  <li>META-INF</li>
  <li>com/example/etc, class files</li>
  <li>logback.groovy, other resources</li>
  <li>lib, which contains all my jars</li>
  </ul>
  
  <p>And this executes nicely in Lambda. But when I follow the <a href="https://docs.aws.amazon.com/lambda/latest/dg/build-pipeline.html" rel="noreferrer">Lambda + CodePipeline docs</a> and use  <code>aws cloudformation</code>, I get this zip structure (which is essentially my git repo):</p>
  
  <ul>
  <li>README.md</li>
  <li>build/</li>
  <li>build.gradle</li>
  <li>buildspec.yml</li>
  <li>events</li>
  <li>gradle/</li>
  <li>gradlew</li>
  <li>gradlew.bat</li>
  <li>src/</li>
  <li>template.yml</li>
  </ul>
  
  <p>Note: this alternative structure happens even outside of CodeBuild, so I am doubtful it has anything to do with what is in <code>buildspec.yml</code>. I can reproduce the two structures simply by invoking the two different package commands on my desktop.</p>
  
  <p>Any ideas why there is a difference? I'd like to understand it, especially since the docs say they should be the same, before I switch my <code>buildspec.yml</code> to use <code>sam deploy</code>. </p>
  
  <p>Thanks!</p>