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

V4: ${opt:stage} does not resolve when using "-s" but does when using "--stage" #12545

Closed
jaffadog opened this issue May 26, 2024 · 6 comments
Closed
Assignees

Comments

@jaffadog
Copy link

Issue description

when deploying to AWS using:
serverless deploy -s v1

${opt:stage} does not resolve and results in unexpected results when using things like this in you yml:
environment:
bucket: ${self:custom.${opt:stage, self:provider.stage}.bucket}

If instead you deploy to AWS using:
serverless deploy --stage v1

then things wok fine.

Documentation states:
--stage or -s The stage in your service that you want to deploy to.
(ref https://www.serverless.com/framework/docs-providers-aws-cli-reference-deploy)

Context

Serverless ϟ Support

This generates a report from your last Serverless Framework command (including any errors) to use for Github Issues, debugging w/ AI, or creating a support ticket w/ Serverless Inc.

Summary Report -----------------

Service Overview

  • Serverless Framework Version: 4.0.28
  • Service Config File: serverless.yml
  • Service Name: fastseas-oscar2-data
  • Service Runtime: python3.9
  • Service Stage: test
  • Service Region: us-east-1
  • Command: deploy --s v1
  • Error Code: MISSING_VARIABLE_RESULT

Service Path

/home/ec2-user/environment/fastseas/fastseas-get-oscar2-data

Error Message

Cannot resolve '${opt:stage}' variable at 'provider.environment.test1'. None of the variables returned a value and no default value was provided. Please check your variable definitions or provide a default value.

Error Stacktrace

at _ResolverManager.resolve (file:///home/ec2-user/.serverless/releases/4.0.28/package/dist/sf-core.js:1041:21692)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async #handlePlaceholderNode (file:///home/ec2-user/.serverless/releases/4.0.28/package/dist/sf-core.js:1041:20280)
at async file:///home/ec2-user/.serverless/releases/4.0.28/package/dist/sf-core.js:1041:18419
at async processNodeAndHandleCompletion (file:///home/ec2-user/.serverless/releases/4.0.28/package/dist/sf-core.js:1041:13702)

Service Config

service: fastseas-oscar2-data
provider:
  name: aws
  stage: test
  runtime: python3.9
  memorySize: 128
  timeout: 300
  versionFunctions: false
  role: arn:aws:iam::XXXXX:role/fastseas-service-role
  region: ${opt:region, 'us-east-1'}
  deploymentBucket: fastseas-serverless-deployment-${self:provider.region}
  environment:
    bucket: ${self:custom.${opt:stage, self:provider.stage}.bucket}
    HOME: /tmp
    machine: urs.earthdata.nasa.gov
    login: fastseas
    password: XXXXXX
    PODAAC_LOGLEVEL: DEBUG
    test1: ${opt:stage}
custom:
  test:
    bucket: fastseas-gribs-test-${self:provider.region}
    #name: fastseas-get-oscar2-data-test
  v1:
    bucket: fastseas-gribs-${self:provider.region}
    #name: fastseas-get-oscar2-data
functions:
  get:
    handler: handler.lambda_handler
    #name: ${self:custom.${opt:stage, self:provider.stage}.name}
    description: Gets OSCAR grib files from NOAA FTP servers

Above is a summary report of your last Serverless Framework command.

Use it to debug with AI (e.g. ChatGPT) or report a new Github Issue: https://slss.io/issue

@jaffadog jaffadog changed the title ${opt:stage} does not resolve when using "-s" but does when using "--stage" V4: ${opt:stage} does not resolve when using "-s" but does when using "--stage" May 26, 2024
@garethmcc
Copy link
Contributor

@jaffadog Thanks for the report. We will be looking into this.

As an alternative to ${opt:stage, self:provider.stage}, ${sls:stage} is designed to essentially do the same but more reliably as well for future usage.

@garethmcc
Copy link
Contributor

After a quick test I can confirm that ${opt:stage} does not resolve for -s stageName but it DOES resolve for ${sls:stage} with -s stageName

@czubocha czubocha self-assigned this May 27, 2024
@austencollins
Copy link
Member

Thanks @jaffadog. Fix coming shortly.

@jaffadog
Copy link
Author

Super @ac360. Thank you all for the quick fix. Cheers!

@austencollins
Copy link
Member

Release coming with a fix in ~4 hours.

@austencollins
Copy link
Member

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

4 participants