Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable Resolution Error When Running Offline Plugin #1807

Open
JeffBeltran opened this issue Jul 26, 2024 · 0 comments
Open

Variable Resolution Error When Running Offline Plugin #1807

JeffBeltran opened this issue Jul 26, 2024 · 0 comments

Comments

@JeffBeltran
Copy link

Issue Description

When running the serverless application offline, I encounter the following error:

Cannot resolve serverless.yml: Variables resolution errored with:
  - Cannot resolve variable at "provider.environment.FOO_BAR": Value not found at "self" source

This issue is similar to #1227 (at least with the setup of ENV's), but with a different error message.

Environment

  • Node Version: 20.10.0
  • Serverless Version: 3.39.0
  • Plugin Version: 13.6.0

Configuration

Here's my truncated serverless.yml:

frameworkVersion: "3"

provider:
  name: aws
  runtime: nodejs20.x
  stage: ${opt:stage, self:custom.defaultStage}
  profile: ${opt:profile, self:custom.profiles.${self:provider.stage}}
  environment:
    FOO_BAR: ${self:custom.environmentVariables.${self:provider.stage}.foo.bar}

functions:
  siteReviews:
    handler: src/siteReviews.handler
    events:
      - schedule: rate(1 minute)

custom:
  defaultStage: "development"
  profiles:
    development: "redacted-dev"
    production: "redacted-prod"
  environmentVariables:
    production:
      foo:
        bar: "baz"

plugins:
  - serverless-esbuild
  - serverless-offline

Attempted Solutions

  1. I've tried to manually set the stage to "production" using the serverless-offline configuration:
custom:
  # ... (previous custom configuration)
  serverless-offline:
    stage: "production"

However, I'm still encountering the same error.

  1. I discovered that removing ${self:provider.stage} from the FOO_BAR environment variable definition works:
provider:
  # ... (other provider settings)
  environment:
    FOO_BAR: ${self:custom.environmentVariables.foo.bar}

This suggests that the issue is specifically related to resolving ${self:provider.stage} when running offline.

Question

How can I resolve this variable resolution error when running the serverless application offline, particularly when using ${self:provider.stage} in environment variable definitions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant