Skip to content

Cloudwatch log groups created not deleted on "terraform destroy" #419

@stephanpelikan

Description

@stephanpelikan

Description

I created a rds instance and asked for the Cloudwatch log-groups to be created:

module "db" {
  source                 = "terraform-aws-modules/rds/aws"
  enabled_cloudwatch_logs_exports = ["alert", "audit"]
  create_cloudwatch_log_group     = true
  ...
}

It is created successfully. After running terraform destroy and rerunning terraform apply I got this error:

Error: Creating CloudWatch Log Group failed: ResourceAlreadyExistsException: The specified log group already exists:  The CloudWatch Log Group '/aws/rds/instance/el-vi-rds-oracle/audit' already exists.
  with module.db.module.db_instance.aws_cloudwatch_log_group.this["audit"],
  on .terraform/modules/db/modules/db_instance/main.tf line 138, in resource "aws_cloudwatch_log_group" "this":
  138: resource "aws_cloudwatch_log_group" "this" {

In AWS console I saw that the groups created were not deleted on terraform destroy.

Versions

  • Terraform v1.2.4
  • provider registry.terraform.io/hashicorp/aws v4.22.0
  • provider registry.terraform.io/hashicorp/random v3.3.2
  • RDS 4.7.0

Reproduction Code

  1. Build a RDS instance like shown in the description
  2. Run terraform destroy
  3. Run terraform apply

Expected behavior

The Cloudwatch log groups created by the RDS module are removed on running terraform destroy.

Actual behavior

The Cloudwatch log groups created by the RDS module were not removed on running terraform destroy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions