# "LogGroup - \<resourceName\> already exists" after deploy command

**URL:** <https://forum.serverless.com/t/loggroup-resourcename-already-exists-after-deploy-command/8259>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [May 14, 2019, 5:58pm UTC](https://forum.serverless.com/t/loggroup-resourcename-already-exists-after-deploy-command/8259 "2019-05-14T17:58:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lschmidt](https://avatars.discourse-cdn.com/v4/letter/l/90ced4/32.png) [@lschmidt](https://forum.serverless.com/u/lschmidt)\
**Post date:** [May 14, 2019, 5:58pm UTC](https://forum.serverless.com/t/loggroup-resourcename-already-exists-after-deploy-command/8259/1 "2019-05-14T17:58:04Z")

</div>

after running `sls deploy -v && sls s3deploy` as I normally do, I ran into this issue:

```auto
  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

```

I don’t remember changing anything at all before deployment, other than adding `Retry` sections to my Step Function States, which shouldn’t have messed with CF logs at all.

I tried running `sls remove` and then my deployment command again, no luck there.

Also tried adding `cfLogs: true` to my `provider` section in the YAML, no love!

I tried manually deleting the LogGroup in CloudFormation, but it’s not even there in the AWS CloudFormation Console.

Here is my serverless.yml:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![DataWearsAHood](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/datawearsahood/32/4331_2.png) [@DataWearsAHood](https://forum.serverless.com/u/DataWearsAHood)\
**Post date:** [January 3, 2020, 1:54am UTC](https://forum.serverless.com/t/loggroup-resourcename-already-exists-after-deploy-command/8259/2 "2020-01-03T01:54:05Z")

</div>

FWIW, I’ve seen _sls remove_ fail to completely pull down a stack, leaving some crumbs behind.  
I was noy able to get this teardown working 100%, but try logging into cloudformation and the you can:

- see logs for hints as to what is blocking the stack deletion, or
- retry deleting the stack manually

---

<div class="post-metadata">

**Author:** ![Pawel](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/pawel/32/1850_2.png) [@Pawel](https://forum.serverless.com/u/Pawel)\
**Post date:** [January 28, 2020, 1:48pm UTC](https://forum.serverless.com/t/loggroup-resourcename-already-exists-after-deploy-command/8259/3 "2020-01-28T13:48:44Z")

</div>

Recently, I run into same problem several times.

Probably this is a # **bug** of #serverless-framework . It looks like it didn’t remove **LogGroup**

I removed previous deployment using `sls removed` and subsequent deployment failed due to

 ![Screenshot 2020-01-28 at 15.14.31](https://canada1.discourse-cdn.com/flex036/uploads/serverless/original/2X/c/c67e5dfb736d22f29b6a8b363a11d7d79ecc5944.png)

---

<div class="post-metadata">

**Author:** ![shederman](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@shederman](https://forum.serverless.com/u/shederman)\
**Post date:** [March 13, 2020, 7:47am UTC](https://forum.serverless.com/t/loggroup-resourcename-already-exists-after-deploy-command/8259/4 "2020-03-13T07:47:31Z")

</div>

Guys,

In a secured environment you **cannot** remove log groups. Our deployer permissions allow log group creation but not removal. How it _should_ work is:

1. If the log group does not exist, create it
2. If the log group does exist, use it
3. Have a boolean that specifies whether to remove log groups

---

<div class="post-metadata">

**Author:** ![ChrisHarveyHub](https://avatars.discourse-cdn.com/v4/letter/c/858c86/32.png) [@ChrisHarveyHub](https://forum.serverless.com/u/ChrisHarveyHub)\
**Post date:** [March 20, 2020, 12:10am UTC](https://forum.serverless.com/t/loggroup-resourcename-already-exists-after-deploy-command/8259/5 "2020-03-20T00:10:33Z")

</div>

Hey shederman,

How can I correct the situation if that’s not the behavior I’m seeing? I’m getting the error “An error occurred: ApiGatewayLogGroup - /aws/api-gateway/{api\_name} already exists.”

I manually deleted the associated API Gateway object and eventually deleted all Serverless-related items in my AWS environment but the issue still persists.

Any advice?

Thanks
