无服务器YAML步骤函数:类型错误:无法读取未定义的属性'配置文件 [英] Serverless YAML stepFunctions: TypeError: Cannot read property 'profile' of undefined

查看:0
本文介绍了无服务器YAML步骤函数:类型错误:无法读取未定义的属性'配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用无服务器在AWS上创建一个Step函数。我已按照所有说明操作,但始终收到错误:&Quot;TypeError:无法读取未定义&Quot;的属性‘Profile’。YAML使用Step Fuction代码运行,但没有 插件中的";-serverless-Step-Functions";(显然不会创建SteFunction)


service: suqinn-python
app: suquinn-be
plugins:
  - '@serverless/enterprise-plugin'
  - serverless-pseudo-parameters
  - serverless-step-functions

package:
  exclude:
    - 'node_modules/**'


#----------------------------------------------PROVIDERS------------------------------------------------------

provider:
  name: aws
  runtime: python3.8
  profile: ${opt:profile,"AlexisLefebvreMelqart"}
  region: ${opt:region,"eu-west-2"} # serverless deploy --region us-east-2
  stage: ${opt:stage,"dev"}
  environment:
    STAGE: ${self:provider.stage}
    REGION: ${self:provider.region}
    DYNAMODB_SECURITIES_TABLE: ${self:custom.DynamoDBSecuritiesTableName}
  iamRoleStatements:
    - Effect: 'Allow'
      Action:
        - dynamodb:PutItem
        - dynamodb:Query
        - dynamodb:Scan
        - dynamodb:GetItem
        - dynamodb:UpdateItem
        - dynamodb:DeleteItem
      Resource: 
        - arn:aws:dynamodb:${self:provider.region}:#{AWS::AccountId}:table/${self:custom.DynamoDBTradesTableName}
        - arn:aws:dynamodb:${self:provider.region}:#{AWS::AccountId}:table/${self:custom.DynamoDBWiTradesTableName}
        - arn:aws:dynamodb:${self:provider.region}:#{AWS::AccountId}:table/${self:custom.DynamoDBReportTableName}
        - arn:aws:dynamodb:${self:provider.region}:#{AWS::AccountId}:table/${self:custom.DynamoDBBooksTableName}
        - arn:aws:dynamodb:${self:provider.region}:#{AWS::AccountId}:table/${self:custom.DynamoDBCounterpartiesTableName}
        - arn:aws:dynamodb:${self:provider.region}:#{AWS::AccountId}:table/${self:custom.DynamoDBCalculationTableName}

    - Effect: 'Allow'
      Action:
        - s3:GetObject
      Resource: 
        - arn:aws:s3:::*

#----------------------------------------------DYNAMO------------------------------------------------------

#dynamo DB
resources:
  Resources:
    tradesTable:
      Type: 'AWS::DynamoDB::Table'
      Properties:
        TableName: ${self:custom.DynamoDBTradesTableName}
        AttributeDefinitions:
          - AttributeName: book
            AttributeType: S
          - AttributeName: tradeID
            AttributeType: S
        KeySchema:
          - AttributeName: book
            KeyType: HASH
          - AttributeName: tradeID
            KeyType: RANGE
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
    WItradesTable:
      Type: 'AWS::DynamoDB::Table'
      Properties:
        TableName: ${self:custom.DynamoDBWiTradesTableName}
        AttributeDefinitions:
          - AttributeName: book
            AttributeType: S
          - AttributeName: tradeID
            AttributeType: S
        KeySchema:
          - AttributeName: book
            KeyType: HASH
          - AttributeName: tradeID
            KeyType: RANGE
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
    ReportTable:
      Type: 'AWS::DynamoDB::Table'
      Properties:
        TableName: ${self:custom.DynamoDBReportTableName}
        AttributeDefinitions:
          - AttributeName: report
            AttributeType: S
          - AttributeName: client
            AttributeType: S
        KeySchema:
          - AttributeName: report
            KeyType: HASH
          - AttributeName: client
            KeyType: RANGE
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
    BooksTable:
      Type: 'AWS::DynamoDB::Table'
      Properties:
        TableName: ${self:custom.DynamoDBBooksTableName}
        AttributeDefinitions:
          - AttributeName: bookName
            AttributeType: S
        KeySchema:
          - AttributeName: bookName
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
    CounterpartiesTable:
      Type: 'AWS::DynamoDB::Table'
      Properties:
        TableName: ${self:custom.DynamoDBCounterpartiesTableName}
        AttributeDefinitions:
          - AttributeName: counterparty 
            AttributeType: S
          - AttributeName: holding 
            AttributeType: S
        KeySchema:
          - AttributeName: counterparty
            KeyType: HASH
          - AttributeName: holding
            KeyType: RANGE
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
    CalculationTable:
      Type: 'AWS::DynamoDB::Table'
      Properties:
        TableName: ${self:custom.DynamoDBCalculationTableName}
        AttributeDefinitions:
          - AttributeName: priceID 
            AttributeType: S
          - AttributeName: priceKey 
            AttributeType: S
        KeySchema:
          - AttributeName: priceID 
            KeyType: HASH
          - AttributeName: priceKey 
            KeyType: RANGE
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1

#dynamo table names
custom:
  client: "melqart"
  DynamoDBTradesTableName: ${self:custom.client}-trades-${self:provider.stage}
  DynamoDBWiTradesTableName: ${self:custom.client}-witrades-${self:provider.stage}
  DynamoDBReportTableName: ${self:custom.client}-reports-parameters-${self:provider.stage}
  DynamoDBBooksTableName: ${self:custom.client}-books-${self:provider.stage}
  DynamoDBCounterpartiesTableName: ${self:custom.client}-counterparties-${self:provider.stage}
  DynamoDBCalculationTableName: ${self:custom.client}-temp
  s3reportsName: ${self:custom.client}-reports-${self:provider.stage}
  DynamoDBSecuritiesTableName: suquinn-securities-${self:provider.stage}
  DynamoDBMasterTableName: suquinn-master-${self:provider.stage}



#----------------------------------------------FUNCTIONS------------------------------------------------------
#lambdas layers
layers:
  pythonLibraries:
    path: python-dependencies #  directory contains all python dependencies
    compatibleRuntimes:     # supported runtime
      - python3.8
  internalLibraries:
    path: internal-libraries #  directory contains all python dependencies
    compatibleRuntimes:     # supported runtime
      - python3.8


#functions
functions:
  create:
    handler: lambda_create.create
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    environment:
      STAGE: ${self:provider.stage}
    events:
      - http:
          path: form
          method: post
          cors: true
  get:
    handler: lambda_get.get
    timeout: 600
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    environment:
      STAGE: ${self:provider.stage}
    events:
      - http:
          path: form
          method: get
          cors: true
  delete:
    handler: lambda_delete.delete
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    environment:
      STAGE: ${self:provider.stage}
    events:
      - http:
          path: form
          method: delete
          cors: true

  pricing_setup:
    handler: lambda_pricing_setup.buildexecfile
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    environment:
      STAGE: ${self:provider.stage}  

  histoData:
    handler: lambda_histo_data.get_histo
    timeout: 600
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    environment:
      STAGE: ${self:provider.stage}  

  histoCorrel:
    handler: lambda_histo_correl.correl_matrix
    timeout: 600
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    environment:
      STAGE: ${self:provider.stage}  

  foldTrades:
    handler: lambda_stepFunction.foldTrades
    timeout: 300
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    environment:
      STAGE: ${self:provider.stage}  

  publishReport:
    handler: lambda_stepFunction.publishReport
    timeout: 300
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    environment:
      STAGE: ${self:provider.stage}  

  foldTradesVaR:
    handler: lambda_stepFunction.foldTradesVaR
    timeout: 300
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    environment:
      STAGE: ${self:provider.stage}  

  createLadder:
    handler: lambda_stepFunction.createLadder
    timeout: 300
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    environment:
      STAGE: ${self:provider.stage}  

  sliceBook:
    handler: lambda_stepFunction.sliceBook
    timeout: 300
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    environment:
      STAGE: ${self:provider.stage}  

  refreshMD:
    handler: lambda_refreshMD.refresh_MD
    timeout: 300
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    environment:
      STAGE: ${self:provider.stage}  

  stress_test:
    handler: reports.Stress_Test.stress_test
    timeout: 300
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    environment:
      STAGE: ${self:provider.stage}  

  varswaps:
    handler: reports.Varswaps.get_put_deltas
    timeout: 300
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    environment:
      STAGE: ${self:provider.stage}  

  FX_Carry:
    handler: reports.FX_Carry.FX_Carry
    timeout: 300
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    environment:
      STAGE: ${self:provider.stage}  

  price_greeks:
    handler: reports.Greeks.price_greeks
    timeout: 300
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    environment:
      STAGE: ${self:provider.stage}  


  spot_ladder:
    handler: reports.Risk_Matrices.spot_ladder
    timeout: 300
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    environment:
      STAGE: ${self:provider.stage}  

  webSocketConnectionHandler:
    handler: lambda_websocket.webSocketConnectionHandler
    timeout: 900
    memorySize: 1024
    layers:
      - {Ref: PythonLibrariesLambdaLayer}
      - {Ref: InternalLibrariesLambdaLayer}
      - arn:aws:lambda:eu-west-2:142628438157:layer:AWSLambda-Python38-SciPy1x:29
    events:
      - websocket:
          route: pricing
      - websocket:
          route: $connect
      - websocket:
          route: $disconnect
    environment:
      STAGE: ${self:provider.stage}
   

#----------------------------------------------SETPFUNCTIONS------------------------------------------------------

stepFunctions:
  validate: true
  stateMachines:
    Carry:
      name: Carry-${self:provider.stage}
      definition:
        Comment: "StepFunction running the Carry report"
        StartAt: pricingSetup
        States:
          pricingSetup:
            Type: Task
            Resource:
              Fn::GetAtt: [pricing_setup, Arn]
            Next: setupOK
          setupOK:
            Type: Choice
            Choices: 
            - Variable: "$.statusCode"
              NumericEquals: 200
              Next: Carry
            - Variable: "$.statusCode"
              NumericEquals: 500
              Next: FailedState
          Carry:
            Type: Task
            Resource:
              Fn::GetAtt: [FX_Carry, Arn]
            Next: CarryOK
          CarryOK:
            Type: Choice
            Choices: 
            - Variable: "$.statusCode"
              NumericEquals: 200
              Next: SuccessState
            - Variable: "$.statusCode"
              NumericEquals: 500
              Next: FailedState
          SuccessState:
            Type: Succeed
            End: true
          FailedState:
            Type: FailedState
            End: true

我收到此错误:

PS C:Suquinnsuquinn-python> serverless --aws-profile AlexisLefebvreMelqart deploy
Serverless: Deprecation warning: Starting with version 3.0.0, following property will be replaced:
             "provider.iamRoleStatements" -> "provider.iam.role.statements"
           More Info: https://www.serverless.com/framework/docs/deprecations/#PROVIDER_IAM_SETTINGS
Serverless: Deprecation warning: Resolution of lambda version hashes was improved with better algorithm, which will be used in next major release.
           Switch to it now by setting "provider.lambdaHashingVersion" to "20201221"
           More Info: https://www.serverless.com/framework/docs/deprecations/#LAMBDA_HASHING_VERSION_V2
Serverless: Deprecation warning: Starting with next major version, API Gateway naming will be changed from "{stage}-{service}" to "{service}-{stage}".
           Set "provider.apiGateway.shouldStartNameWithService" to "true" to adapt to the new behavior now.
           More Info: https://www.serverless.com/framework/docs/deprecations/#AWS_API_GATEWAY_NAME_STARTING_WITH_SERVICE

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

 TypeError: Cannot read property 'profile' of undefined
     at Variables.getValueFromOptions (C:UsersAlexis.LefebvreAppDataRoaming
pm
ode_modulesserverlesslibclassesVariables.js:648:37)   
     at Variables.getValueFromSource (C:UsersAlexis.LefebvreAppDataRoaming
pm
ode_modulesserverlesslibclassesVariables.js:579:17)    
     at C:UsersAlexis.LefebvreAppDataRoaming
pm
ode_modulesserverlesslibclassesVariables.js:539:12
     at Array.map (<anonymous>)
     at Variables.overwrite (C:UsersAlexis.LefebvreAppDataRoaming
pm
ode_modulesserverlesslibclassesVariables.js:538:44)
     at Variables.splitAndGet (C:UsersAlexis.LefebvreAppDataRoaming
pm
ode_modulesserverlesslibclassesVariables.js:445:19)
     at C:UsersAlexis.LefebvreAppDataRoaming
pm
ode_modulesserverlesslibclassesVariables.js:384:40
     at Array.map (<anonymous>)
     at Variables.populateMatches (C:UsersAlexis.LefebvreAppDataRoaming
pm
ode_modulesserverlesslibclassesVariables.js:384:20)       
     at Variables.populateValue (C:UsersAlexis.LefebvreAppDataRoaming
pm
ode_modulesserverlesslibclassesVariables.js:415:30)
     at C:UsersAlexis.LefebvreAppDataRoaming
pm
ode_modulesserverlesslibclassesVariables.js:294:12
     at Array.map (<anonymous>)
     at Variables.populateVariables (C:UsersAlexis.LefebvreAppDataRoaming
pm
ode_modulesserverlesslibclassesVariables.js:293:22)     
     at Variables.populateObjectImpl (C:UsersAlexis.LefebvreAppDataRoaming
pm
ode_modulesserverlesslibclassesVariables.js:329:30)    
     at C:UsersAlexis.LefebvreAppDataRoaming
pm
ode_modulesserverlesslibclassesVariables.js:325:40
     at Variables.initialCall (C:UsersAlexis.LefebvreAppDataRoaming
pm
ode_modulesserverlesslibclassesVariables.js:112:12)
     at Variables.populateObject (C:UsersAlexis.LefebvreAppDataRoaming
pm
ode_modulesserverlesslibclassesVariables.js:325:17)        
     at C:Suquinnsuquinn-python
ode_modulesserverless-step-functionslibyamlParser.js:26:62

    For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

 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.18.3
    Framework Version:         2.28.7
    Plugin Version:            4.4.3
    SDK Version:               2.3.2
    Components Version:        3.7.2


Serverless Information ----------------------------------

 ############################################################################################
   # 15002: 0 of 0 promises have settled
   # 15002: 0 are taking longer than expected:
   # This can result from latent connections but may represent a cyclic variable dependency
   ##########################################################################################

推荐答案

在与无服务器团队交谈后,我们认为这是一个在更高版本中修复的错误,因此如果你遇到类似的错误,请确保你已经更新了无服务器应用。

这篇关于无服务器YAML步骤函数:类型错误:无法读取未定义的属性&#39;配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆