title: Calling Custom Lambda Layers Functions on Lambda
body: <p>I'm trying to implement a custom AWS Lambda layer in order to use it with my functions.<br>
  It should be a simple layer that gets some parameter from ssm and initialize puresec's <code>function_shield</code> for protection of my services.<br>
  The code looks more less like this:</p>
  
  <pre><code>import os
  import boto3
  import function_shield as shield
  
  
  STAGE = os.environ['stage']
  REGION = os.environ['region']
  PARAMETERS_PREFIX = os.environ['parametersPrefix']
  
  
  class ParameterNotFoundException(Exception):
      pass
  
  
  session = boto3.session.Session(region_name=REGION)
  ssm = session.client('ssm')
  
  # function_shield config
  parameter_path = f"/{PARAMETERS_PREFIX}/{STAGE}/functionShieldToken"
  
  try:
      shield_token = ssm.get_parameter(
          Name=parameter_path,
          WithDecryption=True,
      )['Parameter']['Value']
  
  except Exception:
      raise ParameterNotFoundException(f'Parameter {parameter_path} not found.')
  
  
  policy = {
      "outbound_connectivity": "block",
      "read_write_tmp": "block",
      "create_child_process": "block",
      "read_handler": "block"
  }
  
  
  def configure(p):
      """
      update function_shield policy
      :param p: policy dict
      :return: null
      """
      policy.update(p)
      shield.configure({"policy": policy, "disable_analytics": True, "token": shield_token})
  
  
  configure(policy)
  </code></pre>
  
  <p>I want to be able to link this layer to my functions for it to be protected in runtime.<br>
  I'm using the serverless framework, and it seems like my layer was deployed just fine, as it was with my example function. Also, the AWS console shows me that the layer was linked in my function.  </p>
  
  <p>I named my layer 'shield' and tried to import it by its name on my test function: </p>
  
  <pre><code>import os
  import shield
  
  
  def test(event, context):
      shield.configure(policy)  # this should be reusable for easy tweaking whenever I need to give more or less permissions to my lambda code.
      os.system('ls')
  
      return {
          'rep': 'ok'
      }
  </code></pre>
  
  <p>Ideally, I should get and error on CloudWatch telling me that <code>function_shield</code> has prevented a <code>child_process</code> from running, however I instead receive an error telling me that there is no 'shield' declared on my runtime.</p>
  
  <p>What am I missing?
  I couldn't find any custom code examples being used for layers apart from numpy, scipy, binaries, etc.</p>
  
  <p>I'm sorry for my stupidity...<br>
  Thanks for your kindness!</p>