Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/438.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AWS Serverless中的环境变量验证错误_Javascript_Aws Lambda_Serverless Framework_Serverless_Aws Serverless - Fatal编程技术网

Javascript AWS Serverless中的环境变量验证错误

Javascript AWS Serverless中的环境变量验证错误,javascript,aws-lambda,serverless-framework,serverless,aws-serverless,Javascript,Aws Lambda,Serverless Framework,Serverless,Aws Serverless,当我试图在AWS上部署我的服务时。它显示了环境变量中的验证错误。但是我的所有变量都是正确的格式,因为以前它工作得很好 An error occurred: AuthenticateUserLambdaFunction - Resource handler returned message: "1 validation error detected: Value at 'environment.variables' failed to satisfy constraint: Map k

当我试图在AWS上部署我的服务时。它显示了环境变量中的验证错误。但是我的所有变量都是正确的格式,因为以前它工作得很好

An error occurred: AuthenticateUserLambdaFunction - Resource handler returned message: "1 validation error detected: Value at 'environment.variables' failed to satisfy constraint: Map 
keys must satisfy constraint: [Member must satisfy regular expression pattern: [a-zA-Z]([a-zA-Z0-9_])+] (Service: Lambda, Status Code: 400, Request ID: 91e93afc-3abc-49c7-b38b-c0ef7832022e, Extended Request ID: null)" (RequestToken: e0b9e74e-629f-1ce8-f0a9-f718e67fb974, HandlerErrorCode: InvalidRequest).
我的Serverless.yml文件内容如下

frameworkVersion: "2.35.0"
useDotenv: true
unresolvedVariablesNotificationMode: error
configValidationMode: error

plugins:
  - serverless-offline
  - serverless-plugin-git-variables
  - serverless-dotenv-plugin
  - serverless-domain-manager

custom:
  domains:
    local: local-api.carierx.app
    develop: develop-api.carierx.app
    staging: staging-api.carierx.app
    prod: api.carierx.app
  stageVariables:
    gitBranch: ${opt:stage, git:branch}
  customDomain:
    domainName: ${self:custom.domains.${self:provider.stage}}
    basePath: "administration"
    stage: ${self:provider.stage}
    createRoute53Record: true

package:
  excludeDevDependencies: true
  exclude:
    - /node_modules/** # no need to add this yourself, this plugin does it for you

provider:
  stage: ${opt:stage, git:branch}
  name: aws
  runtime: nodejs12.x
  region: ${env:AWS_REGION_CRED, 'us-east-1'}
  versionFunctions: false
  tags:
    project: rxd-administration
  lambdaHashingVersion: 20201221

functions:
  - ${file(./tenant/serverless.yml)}
  - ${file(./auth/serverless.yml)}

resources:
  Outputs:
    AuthorizeUserLambdaFuncExport:
      Value:
        # Ref: SharedLambdaLayer
        Ref: AuthorizeUserLambdaFunction
      Export:
        Name: AuthorizeUserLambdaFunction
Serverless: Running "serverless" installed locally (in service node_modules)
Serverless: DOTENV: Loading environment variables from .env.local, .env.local:
Serverless:      - STAGE
Serverless:      - SLA_DROPOFF_AFTER_MINS
Serverless:      - AWS_ACCOUNT_CRED
Serverless:      - AWS_ACCESS_KEY_ID_CRED
Serverless:      - AWS_SECRET_ACCESS_KEY_CRED
Serverless:      - AWS_REGION_CRED
Serverless:      - LOGLEVEL
Serverless:      - LYFT_REFRESH_TOKEN
Serverless:      - LYFT_ACCESS_TOKEN
Serverless:      - LYFT_CLIENT_ID
Serverless:      - LYFT_CLIENT_SECRET
Serverless:      - LYFT_WEBHOOK_VERIFICATION_KEY
Serverless:      - SMS_APPLICATION_ID
Serverless:      - SMS_REGISTERED_KEY_WORD
Serverless:      - CLIENT_APP_URL
Serverless:      - SECRET_NAME_FOR_LYFT_REFRESH_TOKEN
Serverless:      - SECRET_NAME_FOR_LYFT_ACCESS_TOKEN
Serverless:      - LYFT_ACCESS_TOKEN_ROTATION
Serverless:      - AWS_XRAY_CONTEXT_MISSING
Serverless:      - _X_AMZN_TRACE_ID
Serverless:      - PHARMACY_LOGO_URL
Serverless: Deprecation warning: CLI options definitions were upgraded with "type" property (which could be one of "string", "boolean", "multiple"). Below listed plugins do not predefine type for introduced options:
             - ServerlessOffline for "apiKey", "corsAllowHeaders", "corsAllowOrigin", "corsDisallowCredentials", "corsExposedHeaders", "disableCookieValidation", "enforceSecureCookies", "hideStackTraces", "host", "httpPort", "httpsProtocol", "lambdaPort", "noPrependStageInUrl", "noAuth", "ignoreJWTSignature", "noTimeout", "prefix", "printOutput", "resourceRoutes", "useChildProcesses", "useWorkerThreads", "websocketPort", "webSocketHardTimeout", "webSocketIdleTimeout", "useDocker", "layersDir", "dockerReadOnly", "functionCleanupIdleTimeSeconds", "allowCache", "dockerHost", "dockerHostServicePath", "dockerNetwork"
            Please report this issue in plugin issue tracker.
            Starting with next major release, this will be communicated with a thrown error.
            More Info: https://www.serverless.com/framework/docs/deprecations/#CLI_OPTIONS_SCHEMA
Serverless: Deprecation warning: Support for "package.include" and "package.exclude" will be removed with next major release. Please use "package.patterns" instead            More Info: https://www.serverless.com/framework/docs/deprecations/#NEW_PACKAGE_PATTERNS
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service rxd-administration.zip file to S3 (127.64 KB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
..............................
Serverless: Operation failed!
Serverless: View the full error output: https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stack/detail?stackId=arn%3Aaws%3Acloudformation%3Aus-east-1%3A212556752574%3Astack%2Frxd-administration-local%2F51d7b540-9dd8-11eb-a5b7-0e706f74ed45

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

  An error occurred: AuthenticateUserLambdaFunction - Resource handler returned message: "1 validation error detected: Value at 'environment.variables' failed to satisfy constraint: Map 
keys must satisfy constraint: [Member must satisfy regular expression pattern: [a-zA-Z]([a-zA-Z0-9_])+] (Service: Lambda, Status Code: 400, Request ID: 91e93afc-3abc-49c7-b38b-c0ef7832022e, Extended Request ID: null)" (RequestToken: e0b9e74e-629f-1ce8-f0a9-f718e67fb974, HandlerErrorCode: InvalidRequest).

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

  Your Environment Information ---------------------------
     Operating System:          win32
     Node Version:              12.19.0
     Framework Version:         2.35.0 (local)
     Plugin Version:            4.6.0
     SDK Version:               4.2.2
     Components Version:        3.9.2
我运行这个命令slsdeploy-sllocal,它的完整输出如下

frameworkVersion: "2.35.0"
useDotenv: true
unresolvedVariablesNotificationMode: error
configValidationMode: error

plugins:
  - serverless-offline
  - serverless-plugin-git-variables
  - serverless-dotenv-plugin
  - serverless-domain-manager

custom:
  domains:
    local: local-api.carierx.app
    develop: develop-api.carierx.app
    staging: staging-api.carierx.app
    prod: api.carierx.app
  stageVariables:
    gitBranch: ${opt:stage, git:branch}
  customDomain:
    domainName: ${self:custom.domains.${self:provider.stage}}
    basePath: "administration"
    stage: ${self:provider.stage}
    createRoute53Record: true

package:
  excludeDevDependencies: true
  exclude:
    - /node_modules/** # no need to add this yourself, this plugin does it for you

provider:
  stage: ${opt:stage, git:branch}
  name: aws
  runtime: nodejs12.x
  region: ${env:AWS_REGION_CRED, 'us-east-1'}
  versionFunctions: false
  tags:
    project: rxd-administration
  lambdaHashingVersion: 20201221

functions:
  - ${file(./tenant/serverless.yml)}
  - ${file(./auth/serverless.yml)}

resources:
  Outputs:
    AuthorizeUserLambdaFuncExport:
      Value:
        # Ref: SharedLambdaLayer
        Ref: AuthorizeUserLambdaFunction
      Export:
        Name: AuthorizeUserLambdaFunction
Serverless: Running "serverless" installed locally (in service node_modules)
Serverless: DOTENV: Loading environment variables from .env.local, .env.local:
Serverless:      - STAGE
Serverless:      - SLA_DROPOFF_AFTER_MINS
Serverless:      - AWS_ACCOUNT_CRED
Serverless:      - AWS_ACCESS_KEY_ID_CRED
Serverless:      - AWS_SECRET_ACCESS_KEY_CRED
Serverless:      - AWS_REGION_CRED
Serverless:      - LOGLEVEL
Serverless:      - LYFT_REFRESH_TOKEN
Serverless:      - LYFT_ACCESS_TOKEN
Serverless:      - LYFT_CLIENT_ID
Serverless:      - LYFT_CLIENT_SECRET
Serverless:      - LYFT_WEBHOOK_VERIFICATION_KEY
Serverless:      - SMS_APPLICATION_ID
Serverless:      - SMS_REGISTERED_KEY_WORD
Serverless:      - CLIENT_APP_URL
Serverless:      - SECRET_NAME_FOR_LYFT_REFRESH_TOKEN
Serverless:      - SECRET_NAME_FOR_LYFT_ACCESS_TOKEN
Serverless:      - LYFT_ACCESS_TOKEN_ROTATION
Serverless:      - AWS_XRAY_CONTEXT_MISSING
Serverless:      - _X_AMZN_TRACE_ID
Serverless:      - PHARMACY_LOGO_URL
Serverless: Deprecation warning: CLI options definitions were upgraded with "type" property (which could be one of "string", "boolean", "multiple"). Below listed plugins do not predefine type for introduced options:
             - ServerlessOffline for "apiKey", "corsAllowHeaders", "corsAllowOrigin", "corsDisallowCredentials", "corsExposedHeaders", "disableCookieValidation", "enforceSecureCookies", "hideStackTraces", "host", "httpPort", "httpsProtocol", "lambdaPort", "noPrependStageInUrl", "noAuth", "ignoreJWTSignature", "noTimeout", "prefix", "printOutput", "resourceRoutes", "useChildProcesses", "useWorkerThreads", "websocketPort", "webSocketHardTimeout", "webSocketIdleTimeout", "useDocker", "layersDir", "dockerReadOnly", "functionCleanupIdleTimeSeconds", "allowCache", "dockerHost", "dockerHostServicePath", "dockerNetwork"
            Please report this issue in plugin issue tracker.
            Starting with next major release, this will be communicated with a thrown error.
            More Info: https://www.serverless.com/framework/docs/deprecations/#CLI_OPTIONS_SCHEMA
Serverless: Deprecation warning: Support for "package.include" and "package.exclude" will be removed with next major release. Please use "package.patterns" instead            More Info: https://www.serverless.com/framework/docs/deprecations/#NEW_PACKAGE_PATTERNS
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service rxd-administration.zip file to S3 (127.64 KB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
..............................
Serverless: Operation failed!
Serverless: View the full error output: https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stack/detail?stackId=arn%3Aaws%3Acloudformation%3Aus-east-1%3A212556752574%3Astack%2Frxd-administration-local%2F51d7b540-9dd8-11eb-a5b7-0e706f74ed45

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

  An error occurred: AuthenticateUserLambdaFunction - Resource handler returned message: "1 validation error detected: Value at 'environment.variables' failed to satisfy constraint: Map 
keys must satisfy constraint: [Member must satisfy regular expression pattern: [a-zA-Z]([a-zA-Z0-9_])+] (Service: Lambda, Status Code: 400, Request ID: 91e93afc-3abc-49c7-b38b-c0ef7832022e, Extended Request ID: null)" (RequestToken: e0b9e74e-629f-1ce8-f0a9-f718e67fb974, HandlerErrorCode: InvalidRequest).

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

  Your Environment Information ---------------------------
     Operating System:          win32
     Node Version:              12.19.0
     Framework Version:         2.35.0 (local)
     Plugin Version:            4.6.0
     SDK Version:               4.2.2
     Components Version:        3.9.2
我的无服务器安装版本详细信息

Framework Core: 2.41.2
Plugin: 5.0.0
SDK: 4.2.2
Components: 3.9.2

基本上,在我的环境变量中,名为
\u X\u AMZN\u TRACE\u ID
的格式是错误的。它与此模式不匹配
[a-zA-Z]([a-zA-Z0-9))+
。在此之后,我更改了变量名,现在它工作正常。

错误消息非常清楚。您的env变量的键与
[a-zA-Z]([a-zA-Z0-9))+
某处不匹配。您尚未提供所有信息,但上面出现了
\u X\u AMZN\u TRACE\u ID
,这似乎不符合该模式。@ArslanAli请自己写答案并接受它,或者让Chase写答案并接受他的答案。这使其他人更容易知道已为您的问题找到了解决方案。
An error occurred: AuthenticateUserLambdaFunction - Resource handler returned message: "1 validation error detected: Value at 'environment.variables' failed to satisfy constraint: Map 
keys must satisfy constraint: [Member must satisfy regular expression pattern: [a-zA-Z]([a-zA-Z0-9_])+] (Service: Lambda, Status Code: 400, Request ID: 91e93afc-3abc-49c7-b38b-c0ef7832022e, Extended Request ID: null)" (RequestToken: e0b9e74e-629f-1ce8-f0a9-f718e67fb974, HandlerErrorCode: InvalidRequest).