Skip to content

AWS::Serverless::LayerVersion does not respect a single String Parameter for CompatibleRuntimes #809

Description

@systemdesignpartners

Description

In a template.yaml specifying AWS::Serverless::LayerVersion, unable to specify a single !Ref ParameterName to CompatibleRuntimes, even if you try to send it as a List (of one item)

template.yaml snippet

Parameters:
MyLambdaRuntimeParam:
Type: String
Default: 'nodejs8.10'

Layer1:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: layer-1
ContentUri:
Bucket: ...
Key: ...
CompatibleRuntimes:
- !Ref MyLambdaRuntimeParam

(You can also try it without a dash in front of !Ref, or with two dashes, or with no dashes and no "!Ref" token, it still fails)

Observed result

-- Two debug runs here, for three different ways of trying it. First run has two different-syntax attempts:
Layer1:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: layer-1
Description: "Bug Example #1"
ContentUri:
Bucket: !Ref MyLambdaBucketNameParam
Key: 'lambda-zips/layer-aws-wrapper_v2_no_xray.zip'
CompatibleRuntimes:
- !Ref MyLambdaRuntimeParam

Layer2:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: layer-2
Description: "Bug Example #2"
ContentUri:
Bucket: !Ref MyLambdaBucketNameParam
Key: 'lambda-zips/layer-aws-wrapper_v2_no_xray.zip'
CompatibleRuntimes:
- - !Ref MyLambdaRuntimeParam

And --debug output when running sam deploy was:

2019-02-12 12:55:33 deploy command is called
Uploading to 84451a0ac75787cc911fcc8331083ae3.template 3288 / 3288.0 (100.00%)
Waiting for changeset to be created..

Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 2. Resource with id [Layer1] is invalid. Type of property 'CompatibleRuntimes' is invalid. Resource with id [Layer2] is invalid. Type of property 'CompatibleRuntimes' is invalid.
2019-02-12 12:55:39 Exception: Command '['aws', 'cloudformation', 'deploy', '--capabilities', 'CAPABILITY_IAM', 'CAPABILITY_NAMED_IAM', 'CAPABILITY_AUTO_EXPAND', '--region', 'us-east-2', '--s3-bucket', 'sdp-yourpitchcount-repl-east2', '--parameter-overrides', 'MyAppPrefixParam=pitchaur', 'MyLambdaBucketNameParam=sdp-yourpitchcount-repl-east2', '--tags', 'deployed-via=p-sdepl-layers.sh', '--stack-name', 'sdp-yourpitchcount-layers', '--template-file', 'packaged-layers.yaml']' returned non-zero exit status 255.

Trying it a third way, we get a little further but still the Stack rolls back:

Layer3:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: layer-3
Description: "Bug Example #3"
ContentUri:
Bucket: !Ref MyLambdaBucketNameParam
Key: 'lambda-zips/layer-aws-wrapper_v2_no_xray.zip'
CompatibleRuntimes:
!Ref MyLambdaRuntimeParam

Throws a Create_Failed event with Status Reason:
Property validation failure: [Value of property {/CompatibleRuntimes} does not match type {Array}]
And the Stack rolls back

Expected result

Expected result was that at least one of these should have worked, and created the LayerVersion (thought that the example "Layer1" above would work)

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

  1. OS: Ubuntu 18
  2. sam --version:
    SAM CLI, version 0.11.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions