【问题标题】:"An error occurred: LogGroup - <resource name> already exists" while trying to deploy Serverless尝试部署无服务器时出现“发生错误:LogGroup - <资源名称> 已存在”
【发布时间】:2019-10-01 21:30:54
【问题描述】:

像往常一样运行sls deploy -v &amp;&amp; sls s3deploy后,我遇到了这个问题:

...

CloudFormation - CREATE_FAILED - AWS::Logs::LogGroup - CallTextractLogGroup

...

CloudFormation - CREATE_FAILED - AWS::IAM::Role - IamRoleStateMachineExecution
CloudFormation - CREATE_FAILED - AWS::Logs::LogGroup - StartTextractStateMachineLogGroup
CloudFormation - CREATE_FAILED - AWS::Lambda::LayerVersion - Boto3LayerLambdaLayer

...

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

  An error occurred: StartTextractStateMachineLogGroup - /aws/lambda/textract-service-dev-startTextractStateMachine already exists.

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

  Your Environment Information ---------------------------
     OS:                     linux
     Node Version:           12.2.0
     Serverless Version:     1.42.3

我不记得在部署之前根本没有更改任何内容,除了将 Retry 部分添加到我的 Step Function States 中,这根本不应该与 CF 日志混淆。

我尝试运行sls remove,然后再次运行我的部署命令,但没有运气。

还尝试将 cfLogs: true 添加到 YAML 中的 provider 部分,不喜欢!

我尝试在 CloudWatch 控制台中手动删除 LogGroup,但它甚至不存在。

这是我的 serverless.yml:

service: textract-service

provider:
  name: aws
  runtime: python3.7
  timeout: 10
  region: us-east-1
  cfLogs: true
  environment:
    STATE_MACHINE_ARN: ${self:resources.Outputs.TextractStepFunctions.Value}
  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - "s3:PutObject"
        - "states:*"
      Resource:
        Fn::Join:
          - ""
          - - "the-chumiest-bucket-ARN or *"
            - ${self:resources.Outputs.TextractStepFunctions.Value}

plugins:
  - serverless-plugin-existing-s3
  - serverless-step-functions
  - serverless-pseudo-parameters
  - serverless-plugin-existing-s3 
layers:
  boto3Layer:
    package:
      artifact: boto3_layer.zip
    allowedAccounts:
      - "*"

functions:
  startTextractStateMachine:
    handler: src/start_textract_state_machine.lambda_handler
    role: the-chumiest-bucket-role
    layers:
      - {Ref: Boto3LayerLambdaLayer}
    events:
      - existingS3:
          bucket: the-chumiest-bucket
          events:
            - s3:ObjectCreated:*
          rules:
            - prefix: input1/
            - suffix: .pdf
  callTextract:
    handler: src/call_textract.lambda_handler
    role: the-chumiest-bucket-role

    layers:
      - {Ref: Boto3LayerLambdaLayer}
  getTextractOutput:
    handler: src/get_textract_output.lambda_handler
    role: the-chumiest-bucket-role

    layers:
      - {Ref: Boto3LayerLambdaLayer}
  parseTextractOutput:
    handler: src/parse_textract_output.lambda_handler
    role: the-chumiest-bucket-role

    layers:
      - {Ref: Boto3LayerLambdaLayer}

stepFunctions:
  stateMachines:
    textractStepFunc:
      name: TextractStepFunctions
      definition:
        Comment: A state machine for the Textract OCR process.
        StartAt: StartTextractStateMachine
        States:
          StartTextractStateMachine:
            Type: Task
            Resource: "arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:#{AWS::StackName}-startTextractStateMachine"
            Next: CallTextract
            Retry:
              - ErrorEquals:
                - HandledError
                IntervalSeconds: 1
                MaxAttempts: 1
                BackoffRate: 2
              - ErrorEquals:
                - States.ALL
                IntervalSeconds: 1
                MaxAttempts: 1
                BackoffRate: 2
          CallTextract:
            Type: Task
            Resource: "arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:#{AWS::StackName}-callTextract"
            Next: GetTextractOutput
            Retry:
              - ErrorEquals:
                - HandledError
                IntervalSeconds: 1
                MaxAttempts: 1
                BackoffRate: 2
              - ErrorEquals:
                - States.ALL
                IntervalSeconds: 1
                MaxAttempts: 1
                BackoffRate: 2
          GetTextractOutput:
            Type: Task
            Resource: "arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:#{AWS::StackName}-getTextractOutput"
            Next: ParseTextractOutput
            Retry:
              - ErrorEquals:
                - HandledError
                IntervalSeconds: 1
                MaxAttempts: 1
                BackoffRate: 2
              - ErrorEquals:
                - States.ALL
                IntervalSeconds: 1
                MaxAttempts: 1
                BackoffRate: 2
          ParseTextractOutput:
            Type: Task
            Resource: "arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:#{AWS::StackName}-parseTextractOutput"
            Retry:
              - ErrorEquals:
                - HandledError
                IntervalSeconds: 1
                MaxAttempts: 1
                BackoffRate: 2
              - ErrorEquals:
                - States.ALL
                IntervalSeconds: 1
                MaxAttempts: 1
                BackoffRate: 2
            End: true

resources:
  Outputs:
    TextractStepFunctions:
      Description: The ARN of the state machine
      Value:
        Ref: TextractStepFunctions

【问题讨论】:

    标签: amazon-web-services aws-lambda amazon-cloudformation serverless amazon-cloudwatchlogs


    【解决方案1】:

    看起来您有一个来自先前(失败?)部署的日志组,该部署仍然存在于 CloudWatch Logs 中。

    您应该在 CloudWatch 控制台(不是 CloudFormation)中看到此日志组。

    您可以运行此命令 (AWS CLI):

    aws logs delete-log-group --log-group-name /aws/lambda/textract-service-dev-startTextractStateMachine
    

    删除您的日志组,然后重试部署。

    【讨论】:

    • 抱歉,我指的是 CloudWatch 而不是 CloudFormation,用于通过 GUI 删除日志组
    【解决方案2】:

    要删除 CloudWatch 日志组,请使用:

    aws logs delete-log-group --log-group-name foo/error_log
    

    要显示所有可用的日志组,请使用:

    aws logs describe-log-groups
    

    在 AWS CLI 中

    【讨论】:

      【解决方案3】:

      我重命名了服务,只需要删除旧命名服务的 CloudFormation 堆栈。

      【讨论】:

        猜你喜欢
        • 2020-05-24
        • 2019-04-01
        • 2019-07-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-12-18
        • 1970-01-01
        相关资源
        最近更新 更多