question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

opt:region var default value not resolved on deploy

See original GitHub issue

Bug Report

Description

Hi there, I’m not sure if this is a bug, but after upgrading to v1.53 it seems like the default region value isn’t resolved for me anymore, when using region: ${opt:region, 'eu-central-1'} in the serverless manifest.

This causes my deploy to fail because it can’t find my custom deployment bucket. I noticed the logs print:

This service may not be available in the `${opt:region, 'eu-central-1'}' region.)

Where it prints the “literal” value, not the resolved value. When I run sls print it does resolve the default value correctly to eu-central-1 in the serverless manifest. But deploys only succeed for me when I pass the region explicitly with sls deploy --region eu-central-1.

Is this indeed expected behavior, or am I missing something?

Cheers, Daniël

  1. What did you do?

I ran the command sls deploy

  1. What happened?

I got the error:

ServerlessError: Could not locate deployment bucket.
Error: Inaccessible host: `upstandfm-deployments.s3.'.
This service may not be available in the `${opt:region, 'eu-central-1'}' region.
  1. What should’ve happened?

It should have deployed my service.

  1. What’s the content of your serverless.yml file?
org: upstandfm
app: api
service: files-api

plugins:
  - serverless-domain-manager

custom:
  customDomain:
    domainName: api.upstand.fm
    basePath: files
    stage: ${opt:stage, 'prod'}
    createRoute53Record: false
  cors:
    origin: '*'
  authorizer:
    arn: ${secrets:AUTH0_AUTHORIZER_ARN}
    resultTtlInSeconds: 60
    identitySource: method.request.header.Authorization
    # Note that Bearer must be capitalized
    identityValidationExpression: '^Bearer [-0-9a-zA-z\.]*$'
    type: token

provider:
  name: aws
  runtime: nodejs10.x
  stage: ${opt:stage, 'prod'}
  region: ${opt:region, 'eu-central-1'}
  cfnRole: ${secrets:CFN_ROLE_ARN}
  memorySize: 128
  timeout: 3
  deploymentBucket:
    name: upstandfm-deployments
    serverSideEncryption: AES256 # when using server-side encryption
  environment:
    CORS_ALLOW_ORIGIN: ${self:custom.cors.origin}

package:
  exclude:
    - ./*
    - ./**/*.test.js
  include:
    - node_modules
    - src

functions:
  createUploadUrl:
    handler: src/handler.createUploadUrl
    description: Creates a signed upload URL
    events:
      - http:
          method: post
          path: /
          cors: ${self:custom.cors}
          authorizer: ${self:custom.authorizer}

resources:
  Resources:
    GatewayResponseDefault4XX:
      Type: 'AWS::ApiGateway::GatewayResponse'
      Properties:
        ResponseParameters:
          gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
          gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
        ResponseType: DEFAULT_4XX
        RestApiId:
          Ref: 'ApiGatewayRestApi'
    GatewayResponseDefault5XX:
      Type: 'AWS::ApiGateway::GatewayResponse'
      Properties:
        ResponseParameters:
          gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
          gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
        ResponseType: DEFAULT_5XX
        RestApiId:
          Ref: 'ApiGatewayRestApi'
  1. What’s the output you get when you use the SLS_DEBUG=* environment variable (e.g. SLS_DEBUG=* serverless deploy)
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Installing dependencies for custom CloudFormation resources...
Serverless: Invoke aws:package:finalize
Serverless: [AWS sts 200 0.535s 0 retries] getCallerIdentity({})
platform-sdk fetching: POST https://api.serverless.com/malt/destinations/create
Serverless: Invoke aws:common:moveArtifactsToPackage
Serverless: Invoke aws:common:validate
Serverless: [AWS s3 undefined 0.341s 3 retries] getBucketLocation({ Bucket: 'upstandfm-deployments' })
Serverless: Recoverable error occurred (Inaccessible host: `upstandfm-deployments.s3.'. This service may not be available in the `${opt:region, 'eu-central-1'}' region.), sleeping for 5 seconds. Try 1 of 4
Serverless: [AWS s3 undefined 0.127s 3 retries] getBucketLocation({ Bucket: 'upstandfm-deployments' })
Serverless: Recoverable error occurred (Inaccessible host: `upstandfm-deployments.s3.'. This service may not be available in the `${opt:region, 'eu-central-1'}' region.), sleeping for 5 seconds. Try 2 of 4
Serverless: [AWS s3 undefined 0.13s 3 retries] getBucketLocation({ Bucket: 'upstandfm-deployments' })
Serverless: Recoverable error occurred (Inaccessible host: `upstandfm-deployments.s3.'. This service may not be available in the `${opt:region, 'eu-central-1'}' region.), sleeping for 5 seconds. Try 3 of 4
Serverless: [AWS s3 undefined 0.298s 3 retries] getBucketLocation({ Bucket: 'upstandfm-deployments' })
Serverless: Recoverable error occurred (Inaccessible host: `upstandfm-deployments.s3.'. This service may not be available in the `${opt:region, 'eu-central-1'}' region.), sleeping for 5 seconds. Try 4 of 4
Serverless: [AWS s3 undefined 0.337s 3 retries] getBucketLocation({ Bucket: 'upstandfm-deployments' })

  Serverless Error ---------------------------------------

  ServerlessError: Could not locate deployment bucket. Error: Inaccessible host: `upstandfm-deployments.s3.'. This service may not be available in the `${opt:region, 'eu-central-1'}' region.
      at /Users/daniel/GitHub/upstand.fm/files-api/node_modules/serverless/lib/plugins/aws/deploy/lib/existsDeploymentBucket.js:25:15
  From previous event:
      at AwsDeploy.existsDeploymentBucket (/Users/daniel/GitHub/upstand.fm/files-api/node_modules/serverless/lib/plugins/aws/deploy/lib/existsDeploymentBucket.js:24:13)
      at AwsDeploy.<anonymous> (/Users/daniel/GitHub/upstand.fm/files-api/node_modules/serverless/lib/plugins/aws/deploy/index.js:73:27)
  From previous event:
      at Object.before:deploy:deploy [as hook] (/Users/daniel/GitHub/upstand.fm/files-api/node_modules/serverless/lib/plugins/aws/deploy/index.js:70:12)
      at /Users/daniel/GitHub/upstand.fm/files-api/node_modules/serverless/lib/classes/PluginManager.js:505:55
  From previous event:
      at PluginManager.invoke (/Users/daniel/GitHub/upstand.fm/files-api/node_modules/serverless/lib/classes/PluginManager.js:505:22)
      at /Users/daniel/GitHub/upstand.fm/files-api/node_modules/serverless/lib/classes/PluginManager.js:540:24
  From previous event:
      at PluginManager.run (/Users/daniel/GitHub/upstand.fm/files-api/node_modules/serverless/lib/classes/PluginManager.js:540:8)
      at /Users/daniel/GitHub/upstand.fm/files-api/node_modules/serverless/lib/Serverless.js:115:33
      at processImmediate (internal/timers.js:439:21)
      at process.topLevelDomainCallback (domain.js:131:23)
  From previous event:
      at Serverless.run (/Users/daniel/GitHub/upstand.fm/files-api/node_modules/serverless/lib/Serverless.js:102:74)
      at /Users/daniel/GitHub/upstand.fm/files-api/node_modules/serverless/bin/serverless.js:72:30
      at /Users/daniel/GitHub/upstand.fm/files-api/node_modules/graceful-fs/graceful-fs.js:136:16
      at /Users/daniel/GitHub/upstand.fm/files-api/node_modules/serverless/node_modules/graceful-fs/graceful-fs.js:111:16
      at /Users/daniel/GitHub/upstand.fm/files-api/node_modules/graceful-fs/graceful-fs.js:57:14
      at /Users/daniel/GitHub/upstand.fm/files-api/node_modules/serverless/node_modules/graceful-fs/graceful-fs.js:45:10
      at FSReqCallback.oncomplete (fs.js:157:23)
  From previous event:
      at /Users/daniel/GitHub/upstand.fm/files-api/node_modules/serverless/bin/serverless.js:72:8
      at processImmediate (internal/timers.js:439:21)
      at process.topLevelDomainCallback (domain.js:131:23)
  From previous event:
      at Object.<anonymous> (/Users/daniel/GitHub/upstand.fm/files-api/node_modules/serverless/bin/serverless.js:57:4)
      at Module._compile (internal/modules/cjs/loader.js:936:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
      at Module.load (internal/modules/cjs/loader.js:790:32)
      at Function.Module._load (internal/modules/cjs/loader.js:703:12)
      at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
      at internal/main/run_main_module.js:17:11

  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.10.0
     Framework Version:         1.53.0
     Plugin Version:            3.1.1
     SDK Version:               2.1.1
     Components Core Version:   1.1.1
     Components CLI Version:    1.2.3

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

1reaction
niklaswallerstedtcommented, Jan 29, 2020

@niklaswallerstedt does the new version also fix your issue?

@danillouz Yes, Seems to be working. Tested on 1.62.0.

0reactions
danillouzcommented, Jan 28, 2020

@niklaswallerstedt does the new version also fix your issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Serverless option as default value for option not working
Stage and region each have a default, which can be overridden by an environment variable, which can in turn be overridden by a...
Read more >
Variables - Serverless Framework
Variables. Variables allow users to dynamically replace config values in serverless.yml config. They are especially useful when providing secrets for your ...
Read more >
Record Producer/Variable set default value not showing
Solved : Hi. I have a variable set for a variable type single text even if i put in a test text or...
Read more >
Docker Stack Deploy doesn't resolve environment variables ...
The workaround i ended up doing for docker stack deploy is using envsubst to replace env vars. user@laptop:~$ env $(cat .
Read more >
Default values of C# types - C# reference - Microsoft Learn
Learn the default values of C# types such as bool, char, int, float, ... to initialize a variable with the default value of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found