title: SAM build - does it also build layers?
body: <p>I'm new to both lambda's and also SAM - so if I've screwed anything simple up don't yell :D.</p>
  
  <p><strong>Summary:</strong> I can't get <code>sam build</code> to build a layer specified in <code>template.yaml</code>, it only builds the lambda function.</p>
  
  <p><strong>Background</strong>: I'm trying to build a lambda function in python3.7 that uses the skimage (<code>scikit-image</code>) module.  To do that, I'm trying to use SAM to build and deploy it all.  <em>...this is working</em></p>
  
  <p>I'm trying to deploy the scikit-image module as a layer (and also build with SAM), rather than having it included in the lambda function direction  <em>...this isn't working</em></p>
  
  <hr>
  
  <p>As a start, I'm simply extending the standard SAM <code>Hello World</code> app.</p>
  
  <p>I've got skimage working by simply add it to <code>requirements.txt</code> , then using <code>sam build -u</code>, then manually removing the numpy/scipy dependencies from the built package directory (I've got the AWS scipy/numpy layer included).</p>
  
  <p>(I added import numpy, scipy.ndimage and skimage.draw to the standard hello world app, and included some test function calls to each)</p>
  
  <p>requirements.txt:</p>
  
  <pre><code>requests
  scikit-image
  </code></pre>
  
  <p>After that, everything works fine (running locally and/or on AWS).</p>
  
  <hr>
  
  <p>However, I'd now like to move the skimage module out of my app and into a new custom layer (I'd like to have skimage in a layer to re-use for a few functions)</p>
  
  <p>To set that up, I've created a dependencies directory and moved requirements.txt into there (leaving empty requirements.txt in the app directory).
  I then updated template.yaml to also specify the new layer:</p>
  
  <pre><code>AWSTemplateFormatVersion: '2010-09-09'
  Transform: AWS::Serverless-2016-10-31
  Description: &gt;
    sam-app
  
    Sample SAM Template for sam-app
  
  # More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
  Globals:
    Function:
      Timeout: 3
  
  Resources:
    HelloWorldFunction:
      Type: AWS::Serverless::Function
      Properties:
        CodeUri: hello_world/
        Handler: app.lambda_handler
        Runtime: python3.7
        Layers:
                - arn:aws:lambda:us-west-2:420165488524:layer:AWSLambda-Python37-SciPy1x:2
                - !Ref SkimageLayer
        Events:
          HelloWorld:
            Type: Api
            Properties:
              Path: /hello
              Method: get
  
    SkimageLayer:
      Type: AWS::Serverless::LayerVersion
      Properties:
        LayerName: Skimage
        Description: Skimage module layer
        ContentUri: dependencies/
        CompatibleRuntimes:
                - python3.7
        RetentionPolicy: Retain
      DependsOn:
              - Skimage
  </code></pre>
  
  <p>directory structure:</p>
  
  <pre><code>▾ dependencies/                
      requirements.txt (responses and scikit-image)          
  ▸ events/                      
  ▾ hello_world/                 
      __init__.py                
      app.py                     
      requirements.txt (now empty)          
  ▸ tests/                       
    README.md                    
    template.yaml                 
  </code></pre>
  
  <p>However, when I run <code>sam build -u</code> with that template file, nothing gets built for the layer specified in <code>./dependencies</code>: <code>SkimageLayer</code> in the template.yml file.  However the <code>HelloWorldFunction</code> still gets built correctly (now of course without any included modules)</p>