Skip to content

Referencing Layer by parameter arn worked in Sam 0.19.0, after that it broke #1386

@bmschwa

Description

@bmschwa

Description

Had been using the most recent aws-sam-cli to build our projects. Version 0.21.0 & 0.20.0 have an issue when we refer to a layer param whereas version 0.19.0 did not.

Steps to reproduce

Using the following template with the command sam build --use-container --skip-pull-image --debug --template layer_ref_bug.yaml caused the error in versions 0.21, but not in 0.19.0

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  Demo Template; can I reproduce this issue?
  
Parameters:
  aLayer:
    Description: Some Layer
    Type: String
    Default: arn:aws:lambda:us-east-1:764866452798:layer:chrome-aws-lambda:4
Resources:
  aFunctionResource:
    Type: AWS::Serverless::Function
    Properties:
      Timeout: 900
      CodeUri: .
      Handler: resource.handler
      Runtime: python2.7
      Layers:
        - Ref: aLayer

Observed

(from a code deploy build)

Traceback (most recent call last): 
  File "/usr/local/bin/sam", line 10, in <module> 
    sys.exit(cli()) 
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 764, in __call__ 
    return self.main(*args, **kwargs) 
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 717, in main 
    rv = self.invoke(ctx) 
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke 
    return _process_result(sub_ctx.command.invoke(sub_ctx)) 
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 956, in invoke 
    return ctx.invoke(self.callback, **ctx.params) 
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke 
    return callback(*args, **kwargs) 
  File "/usr/local/lib/python3.7/site-packages/click/decorators.py", line 64, in new_func 
    return ctx.invoke(f, obj, *args, **kwargs) 
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke 
    return callback(*args, **kwargs) 
  File "/usr/local/lib/python3.7/site-packages/samcli/lib/telemetry/metrics.py", line 94, in wrapped 
    raise exception  # pylint: disable=raising-bad-type 
  File "/usr/local/lib/python3.7/site-packages/samcli/lib/telemetry/metrics.py", line 65, in wrapped 
    return_value = func(*args, **kwargs) 
  File "/usr/local/lib/python3.7/site-packages/samcli/commands/build/command.py", line 105, in cli 
    skip_pull_image, parameter_overrides, mode)  # pragma: no cover 
  File "/usr/local/lib/python3.7/site-packages/samcli/commands/build/command.py", line 138, in do_cli 
    mode=mode) as ctx: 
  File "/usr/local/lib/python3.7/site-packages/samcli/commands/build/build_context.py", line 65, in __enter__ 
    self._function_provider = SamFunctionProvider(self._template_dict, self._parameter_overrides) 
  File "/usr/local/lib/python3.7/site-packages/samcli/commands/local/lib/sam_function_provider.py", line 52, in __init__ 
    self.functions = self._extract_functions(self.resources) 
  File "/usr/local/lib/python3.7/site-packages/samcli/commands/local/lib/sam_function_provider.py", line 100, in _extract_functions 
    layers = SamFunctionProvider._parse_layer_info(resource_properties.get("Layers", []), resources) 
  File "/usr/local/lib/python3.7/site-packages/samcli/commands/local/lib/sam_function_provider.py", line 263, in _parse_layer_info 
    raise InvalidLayerReference() 
samcli.commands.local.lib.exceptions.InvalidLayerReference: Layer References need to be of type 'AWS::Serverless::LayerVersion' or 'AWS::Lambda::LayerVersion' 
 

Expected result

Working with old version, not with the new one

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Windows 10 (using powershell)
  2. Python 3.7.4
    3a. sam --version: (when it worked): SAM CLI, version 0.19.0
    3b, sam --version: (when it didn't work): SAM CLI, version 0.21.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions