Unable to find the reference to layer in resource section, especially when we enable the provisionedConcurrency or functionVersion set to true.
if we remove both provisionedConcurrency or functionVersion in serverless script, same code is working fine without any issues
Could not find reference to layer: rtnLayer. Ensure that you are referencing layer defined in your service.
serverless.yml
---
service:
name: rtn
configValidationMode: error
enableLocalInstallationFallback: true
provider:
name: aws
region: us-west-2
stackName: rtn-sls
deploymentBucket:
name: ${self:custom.S3BucketName.${opt:stage}}
maxPreviousDeploymentArtifacts: 10
deploymentPrefix: rtn/deployment
runtime: nodejs12.x
memorySize: 256
timeout: 300
# Lambda Configuration
versionFunctions: false # Lambda Versioning
# X-Ray Configuration
tracing:
lambda: true
custom:
params: ${file(./env/${opt:stage}/parameters.json)}
version: ${self:custom.params.Version}
LayerVersion: ${self:custom.params.LayerVersion}
s3Key: "https://s3.amazonaws.com/${self:custom.S3BucketName.${opt:stage}}/rtn-business-service/${self:custom.version}"
S3BucketName:
devint: rtn-devint
prod: rtn
package:
individually: true
functions:
rtn-api-router:
name: "rtn-api-router"
handler: rtn-api-router.handler
layers:
- !Ref rtnLayer
logForwarding:
enabled: true
package:
artifact: "${self:custom.s3Key}/rtn-api-router-v${self:custom.version}.zip"
provisionedConcurrency: 1
resources:
- Resources:
rtnLayer:
Type: AWS::Lambda::LayerVersion
Properties:
CompatibleRuntimes:
- nodejs12.x
Content:
S3Bucket: ${self:custom.S3BucketName.${opt:stage}}
S3Key: common-nodejs-lambda-layer/common-nodejs-lib-v${self:custom.LayerVersion}.zip
LayerName: rtn-layer
serverless package -c serverless.yml --stage=devint
output
Serverless: To ensure safe major version upgrades ensure "frameworkVersion" setting in service configuration (recommended setup: "frameworkVersion: ^2.52.1")
Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command upgrade
Serverless: Load command uninstall
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Load command output
Serverless: Load command output:get
Serverless: Load command output:list
Serverless: Load command param
Serverless: Load command param:get
Serverless: Load command param:list
Serverless: Load command studio
Serverless: Skipping variables resolution with old resolver (new resolver reported no more variables to resolve)
Serverless: Configuration warning:
Serverless: at 'functions['rtn-api-router']': unrecognized property 'logForwarding'
Serverless: at 'service': unrecognized property 'configValidationMode'
Serverless: at 'service': unrecognized property 'enableLocalInstallationFallback'
Serverless:
Serverless: Learn more about configuration validation here: http://slss.io/configuration-validation
Serverless:
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Packaging service...
Serverless: Downloading rtn-api-router/1.0.1-2/rtn-api-router-v1.0.1-2.zip from bucket rtn-devint
Serverless Error ----------------------------------------
ServerlessError: Could not find reference to layer: rtnLayer. Ensure that you are referencing layer defined in your service.
at /Users/naveen/rtn-api-router/node_modules/serverless/lib/plugins/aws/package/compile/functions.js:739:15
at Array.forEach (<anonymous>)
at extractLayerConfigurationsFromFunction (/Users/naveen/rtn-api-router/node_modules/serverless/lib/plugins/aws/package/compile/functions.js:735:29)
at AwsCompileFunctions.compileFunction (/Users/naveen/rtn-api-router/node_modules/serverless/lib/plugins/aws/package/compile/functions.js:458:9)
at /Users/naveen/rtn-api-router/node_modules/serverless/lib/plugins/aws/package/compile/functions.js:680:64
at Array.map (<anonymous>)
at AwsCompileFunctions.compileFunctions (/Users/naveen/rtn-api-router/node_modules/serverless/lib/plugins/aws/package/compile/functions.js:680:37)
at AwsCompileFunctions.tryCatcher (/Users/naveen/rtn-api-router/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/naveen/rtn-api-router/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/Users/naveen/rtn-api-router/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/Users/naveen/rtn-api-router/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/Users/naveen/rtn-api-router/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/Users/naveen/rtn-api-router/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/Users/naveen/rtn-api-router/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/Users/naveen/rtn-api-router/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues (/Users/naveen/rtn-api-router/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:456:21)
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 12.18.3
Framework Version: 2.52.1 (local)
Plugin Version: 5.4.3
SDK Version: 4.2.6
Components Version: 3.14.2
Serverless: Deprecation warnings:
Starting from next major object notation for "service" property will no longer be recognized. Set "service" property directly with service name.
More Info: https://www.serverless.com/framework/docs/deprecations/#SERVICE_OBJECT_NOTATION
Starting with next major, Serverless will throw on configuration errors by default. Adapt to this behavior now by adding "configValidationMode: error" to service configuration
More Info: https://www.serverless.com/framework/docs/deprecations/#CONFIG_VALIDATION_MODE_DEFAULT```
</details>
<!--
Q4: Provide (in below placeholder) output of serverless --version
-->
<b>Installed version</b>
Serverless: Running “serverless” installed locally (in service node_modules)
Framework Core: 2.52.1 (local)
Plugin: 5.4.3
SDK: 4.2.6
Components: 3.14.2