Skip to content

Invalid variable references as ${source:prop:invalid} are not communicated with error #7921

@imaginaryCorn

Description

@imaginaryCorn

I have a custom.region variable that get the region from either --region or the default 'us-east-1' and is then set to provider.region. If I call serverless deploy -s $ENV without the --region tag, it throws TypeError: region.toLowerCase is not a function.

serverless.yml
# Serverless Framework
# For full config options, check the docs:
#    docs.serverless.com
custom:
  # Variables required per deployment:
  env: ${opt:stage, 'staging'}
  region: ${opt:region, 'us-east-1'}
  ssm_region: ${env:PARAMETER_STORE_REGION, 'us-east-1'}
  ecr_results_bucket: ${ssm.${self:custom.ssm_region}:***-${self:custom.env}/RESULTS_BUCKET}
  min_severity: ${ssm.${self:custom.ssm_region}:***-${self:custom.env}/MINIMUM_SEVERITY}

service: ***

provider:
  name: aws
  runtime: ruby2.7
  region: ${self:custom:region}
  stage: ${self:custom:env}
  deploymentBucket: ***
  memorySize: 256

# you can add statements to the Lambda function's IAM Role here
  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - ecr:DescribeImageScanFindings
      Resource: "*"
    - Effect: "Allow"
      Action:
        - s3:PutObject
      Resource:
        - "arn:aws:s3:::${self:custom.ecr_results_bucket}/*"
        - "arn:aws:s3:::${self:custom.ecr_results_bucket}"

  # Define service wide environment variables:
  environment:
    ENVIRONMENT: ${self:custom.env}
    RESULTS_BUCKET: ${self:custom.ecr_results_bucket}
    MINIMUM_SEVERITY: ${self:custom.min_severity}

package:
  exclude:
    - .drone.yml
    - deploy
  include:
    - vendor/

functions:
  sendresults:
    handler: handler.send_results
    events:
      - eventBridge:
          pattern:
            source:
              - "aws.ecr"
            detail-type:
              - "ECR Image Scan"
SLS_DEBUG=* serverless deploy -s production output
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 rollback
Serverless: Load command rollback:function
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: Load command dev
Serverless: [AWS ssm 200 1.075s 0 retries] getParameter({
  Name: '/sls/service/***/MINIMUM_SEVERITY',
  WithDecryption: false
})
Serverless: [AWS ssm 200 1.092s 0 retries] getParameter({
  Name: '/sls/service/***/RESULTS_BUCKET',
  WithDecryption: false
})
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir

  Type Error ---------------------------------------------

  TypeError: region.toLowerCase is not a function
      at getS3EndpointForRegion (/usr/local/lib/node_modules/serverless/lib/plugins/aws/utils/getS3EndpointForRegion.js:4:28)
      at AwsProvider.isS3TransferAccelerationSupported (/usr/local/lib/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:409:22)
      at AwsPackage.generateCoreTemplate (/usr/local/lib/node_modules/serverless/lib/plugins/aws/package/lib/generateCoreTemplate.js:67:61)
  From previous event:
      at Object.package:initialize [as hook] (/usr/local/lib/node_modules/serverless/lib/plugins/aws/package/index.js:58:56)
  From previous event:
      at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:476:22)
      at PluginManager.spawn (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:496:17)
      at /usr/local/lib/node_modules/serverless/lib/plugins/deploy/deploy.js:122:50
  From previous event:
      at Object.before:deploy:deploy [as hook] (/usr/local/lib/node_modules/serverless/lib/plugins/deploy/deploy.js:102:22)
      at /usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:476:55
  From previous event:
      at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:476:22)
      at /usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:511:24
  From previous event:
      at PluginManager.run (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:511:8)
      at /usr/local/lib/node_modules/serverless/lib/Serverless.js:131:33
  From previous event:
      at Serverless.run (/usr/local/lib/node_modules/serverless/lib/Serverless.js:118:74)
      at /usr/local/lib/node_modules/serverless/bin/serverless.js:80:26
      at processImmediate (internal/timers.js:456:21)
      at process.topLevelDomainCallback (domain.js:137:15)
  From previous event:
      at Object.<anonymous> (/usr/local/lib/node_modules/serverless/bin/serverless.js:80:4)
      at Module._compile (internal/modules/cjs/loader.js:1176:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
      at Module.load (internal/modules/cjs/loader.js:1040:32)
      at Function.Module._load (internal/modules/cjs/loader.js:929:14)
      at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
      at internal/main/run_main_module.js:17:47

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              14.2.0
     Framework Version:         1.74.1
     Plugin Version:            3.6.15
     SDK Version:               2.3.1
     Components Version:        2.31.12

Installed version

Framework Core: 1.74.1
Plugin: 3.6.15
SDK: 2.3.1
Components: 2.31.12

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions