0

我正在尝试使用无服务器在 AWS 上创建一个 stepfunction。我已按照所有说明操作,但不断收到错误消息:“TypeError:无法读取未定义的属性 'profile'”。YAML 使用 stepFuction 代码运行,但插件中没有“-serverless-step-functions”(显然不会创建 stepFunction)


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:\Suquinn\suquinn-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:\Users\Alexis.Lefebvre\AppData\Roaming\npm\node_modules\serverless\lib\classes\Variables.js:648:37)   
     at Variables.getValueFromSource (C:\Users\Alexis.Lefebvre\AppData\Roaming\npm\node_modules\serverless\lib\classes\Variables.js:579:17)    
     at C:\Users\Alexis.Lefebvre\AppData\Roaming\npm\node_modules\serverless\lib\classes\Variables.js:539:12
     at Array.map (<anonymous>)
     at Variables.overwrite (C:\Users\Alexis.Lefebvre\AppData\Roaming\npm\node_modules\serverless\lib\classes\Variables.js:538:44)
     at Variables.splitAndGet (C:\Users\Alexis.Lefebvre\AppData\Roaming\npm\node_modules\serverless\lib\classes\Variables.js:445:19)
     at C:\Users\Alexis.Lefebvre\AppData\Roaming\npm\node_modules\serverless\lib\classes\Variables.js:384:40
     at Array.map (<anonymous>)
     at Variables.populateMatches (C:\Users\Alexis.Lefebvre\AppData\Roaming\npm\node_modules\serverless\lib\classes\Variables.js:384:20)       
     at Variables.populateValue (C:\Users\Alexis.Lefebvre\AppData\Roaming\npm\node_modules\serverless\lib\classes\Variables.js:415:30)
     at C:\Users\Alexis.Lefebvre\AppData\Roaming\npm\node_modules\serverless\lib\classes\Variables.js:294:12
     at Array.map (<anonymous>)
     at Variables.populateVariables (C:\Users\Alexis.Lefebvre\AppData\Roaming\npm\node_modules\serverless\lib\classes\Variables.js:293:22)     
     at Variables.populateObjectImpl (C:\Users\Alexis.Lefebvre\AppData\Roaming\npm\node_modules\serverless\lib\classes\Variables.js:329:30)    
     at C:\Users\Alexis.Lefebvre\AppData\Roaming\npm\node_modules\serverless\lib\classes\Variables.js:325:40
     at Variables.initialCall (C:\Users\Alexis.Lefebvre\AppData\Roaming\npm\node_modules\serverless\lib\classes\Variables.js:112:12)
     at Variables.populateObject (C:\Users\Alexis.Lefebvre\AppData\Roaming\npm\node_modules\serverless\lib\classes\Variables.js:325:17)        
     at C:\Suquinn\suquinn-python\node_modules\serverless-step-functions\lib\yamlParser.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
   ##########################################################################################

4

1 回答 1

0

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

于 2021-03-31T14:59:24.847 回答