serverless: Environment variable in serverless.yml throws "Cannot resolve ..." error
The latest version of the serverless framework is no longer working for AWS Lambda deployments and is throwing the following error:
Cannot resolve serverless.yml: “provider.stage” property is not accessible (configured behind variables which cannot be resolved at this stage)
Cannot resolve serverless.yml: “provider.stage” property is not accessible (configured behind variables which cannot be resolved at this stage)
service: <redacted>
unresolvedVariablesNotificationMode: error
useDotenv: true
variablesResolutionMode: 20210326
provider:
name: aws
region: ${env:AWS_LAMBDA_REGION}
stage: ${env:AWS_STAGE}
runtime: nodejs14.x
lambdaHashingVersion: 20201221
memorySize: 512
timeout: 6
profile: <redacted>
httpApi:
cors:
allowedOrigins:
- "*"
allowedHeaders:
- "*"
allowedMethods:
- GET
- PUT
- POST
- DELETE
- OPTIONS
#allowCredentials: true
exposedResponseHeaders:
- "*"
maxAge: 6000 # In seconds
websocketsApiRouteSelectionExpression: $request.body.action
iamRoleStatements:
- Effect: 'Allow'
Action:
- dynamodb:PutItem
- dynamodb:BatchWriteItem
- dynamodb:PartiQLInsert
- dynamodb:PartiQLUpdate
- dynamodb:PartiQLSelect
Resource: 'arn:aws:dynamodb:ca-central-1:<redacted>:table/<redacted>-${env:AWS_STAGE}'
- Effect: Allow
Action:
- "execute-api:ManageConnections"
Resource:
- "arn:aws:execute-api:*:*:**/@connections/*"
functions:
# Read all users
readUsers:
handler: Handler.readUsers
events:
- httpApi:
method: GET
path: /users
# Read individual user
readUser:
handler: Handler.readUser
events:
- httpApi:
method: GET
path: /users/{userId}
# Exchange a Google issued JWT for a <redacted> JWT
exchangeJWT:
handler: Handler.exchangeJWT
events:
- httpApi:
method: GET
path: /users/jwt
# Handle WebSocket (dis)connections
connect:
handler: Handler.connect
events:
- websocket:
route: $connect
- websocket:
route: $disconnect
# Close a class
closeClass:
handler: Handler.closeClass
events:
- websocket:
route: closeClass
plugins:
- serverless-offline
- serverless-dotenv-plugin
package:
include:
- ../<redacted>.pem
AWS_PROFILE=<redacted> npx serverless deploy output
Serverless Error ----------------------------------------
Cannot resolve serverless.yml: "provider.stage" property is not accessible (configured behind variables which cannot be resolved at this stage)
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: linux
Node Version: 14.15.4
Framework Version: 2.52.0 (local)
Plugin Version: 5.4.3
SDK Version: 4.2.3
Components Version: 3.13.4
Installed version
Framework Core: 2.52.0 (local)
Plugin: 5.4.3
SDK: 4.2.3
Components: 3.13.4
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 31 (16 by maintainers)
Commits related to this issue
- test: Deploy as part of CI Ensures that deployment works rather than relying on "invisible" post-merge deployment. Destroys CI stack after run, retrying in case it's in an intermediate state. Unfor... — committed to linz/qgis-plugin-repository by l0b0 a year ago
- test: Deploy as part of CI Ensures that deployment works rather than relying on "invisible" post-merge deployment. Destroys CI stack after run, retrying in case it's in an intermediate state. Unfor... — committed to linz/qgis-plugin-repository by l0b0 a year ago
- test: Deploy as part of CI Ensures that deployment works rather than relying on "invisible" post-merge deployment. Destroys CI stack after run, retrying in case it's in an intermediate state. Unfor... — committed to linz/qgis-plugin-repository by l0b0 a year ago
- test: Deploy as part of CI Ensures that deployment works rather than relying on "invisible" post-merge deployment. Destroys CI stack after run, retrying in case it's in an intermediate state. Unfor... — committed to linz/qgis-plugin-repository by l0b0 a year ago
- test: Deploy as part of CI Ensures that deployment works rather than relying on "invisible" post-merge deployment. Destroys CI stack after run, retrying in case it's in an intermediate state. Unfor... — committed to linz/qgis-plugin-repository by l0b0 a year ago
- test: Deploy as part of CI Ensures that deployment works rather than relying on "invisible" post-merge deployment. Destroys CI stack after run, retrying in case it's in an intermediate state. Unfor... — committed to linz/qgis-plugin-repository by l0b0 a year ago
- test: Deploy as part of CI Ensures that deployment works rather than relying on "invisible" post-merge deployment. Destroys CI stack after run, retrying in case it's in an intermediate state. Unfor... — committed to linz/qgis-plugin-repository by l0b0 a year ago
@tforster good news! Starting with today’s release we will support
envvariables inprovider.stage.