# Ignore\_changes - removing

**URL:** <https://discuss.hashicorp.com/t/ignore-changes-removing/39759>\
**Category:** AWS\
**Created:** [May 20, 2022, 5:26am UTC](https://discuss.hashicorp.com/t/ignore-changes-removing/39759 "2022-05-20T05:26:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![carl1](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/carl1/32/24144_2.png) [@carl1](https://discuss.hashicorp.com/u/carl1)\
**Post date:** [May 20, 2022, 5:26am UTC](https://discuss.hashicorp.com/t/ignore-changes-removing/39759/1 "2022-05-20T05:26:33Z")

</div>

I have an s3 bucket that was configured with

```auto

lifecycle {
    ignore_changes = [replication_configuration]
  }

```

I want to remove that part now and bring the replication configuration back under control of terraform. However it doesn’t seem to save the new replication configuration I have applied using aws\_s3\_bucket\_replication\_configuration. I have removed the lifecycle config for the s3 bucket. terraform tells me it is going to create the replication configuration before I apply. I then apply it, it is created and I can see it in the AWS console. However the state file only has

```auto

"replication_configuration": [],

```

I am kind of baffled on how to proceed. Then when I run terraform apply again, with the same config where I have the aws\_s3\_bucket\_replication\_configuration tag it tells me it is going to remove the replication configuration. And then it does! It is like it is continuing to get it from the old replication\_configuration setting inside the aws\_s3\_bucket tag. But also combined with ignore\_changes somehow. I am really blocked and out of ideas.

To clarify. I have no lifecycle tag for the s3 bucket config. I have a separate tag for aws\_s3\_bucket\_replication\_configuration. I run terraform apply and it tells me it is going to create the replication configuration. It does. Then I run terraform apply again and it tells me it is going to remove the replication configuration. It does. The I run terraform apply again and it tells me it is going to create the replication configuration …

Any ideas?

I am on terraform 1.1.9. And aws provider 3.75.1.

---

<div class="post-metadata">

**Author:** ![carl1](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/carl1/32/24144_2.png) [@carl1](https://discuss.hashicorp.com/u/carl1)\
**Post date:** [May 20, 2022, 5:40am UTC](https://discuss.hashicorp.com/t/ignore-changes-removing/39759/2 "2022-05-20T05:40:05Z")

</div>

Hmmmm, it also does it for aws\_s3\_bucket\_logging as well. It literally adds it, then removes it, then adds it flicking back and forth each time I run terraform apply. This is very weird but doesn’t look to be related to removing ignore\_changes. It seems confused about whether to follow the deprecated approach or the new approach of using tags like aws\_s3\_bucket\_logging.

---

<div class="post-metadata">

**Author:** ![carl1](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/carl1/32/24144_2.png) [@carl1](https://discuss.hashicorp.com/u/carl1)\
**Post date:** [May 20, 2022, 5:46am UTC](https://discuss.hashicorp.com/t/ignore-changes-removing/39759/3 "2022-05-20T05:46:18Z")

</div>

I recently upgrade to use aws\_s3\_bucket\_versioning tags to replace deprecated versioning config inside aws\_s3\_bucket tag and did not have this problem.

I have tried removing all .terraform files locally and running apply/plan again. Same problems. I must be missing something simple.

State files are definitely being updated as I just added a new s3 bucket and can see it in the state files in s3.

---

<div class="post-metadata">

**Author:** ![carl1](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/carl1/32/24144_2.png) [@carl1](https://discuss.hashicorp.com/u/carl1)\
**Post date:** [May 23, 2022, 4:36am UTC](https://discuss.hashicorp.com/t/ignore-changes-removing/39759/4 "2022-05-23T04:36:40Z")

</div>

Something is seriously busted or I am really missing something very, very obvious (probably the latter). This has nothing to do with ignore\_changes. It is something wrong with aws\_s3\_bucket\_replication\_configuration.

I have stripped this back and made a very simple stack and the same problem keeps happening. The state for the replication config does not update in the state file. So I can run terraform apply and it creates it. Then terraform apply and it removes it.

I am using terraform 1.1.9 and aws provider 3.75.1.

```auto
provider "aws" {
  region = "ap-southeast-2"
}

resource "aws_s3_bucket" "media_backup" {
  bucket = "1234-media-backup"
}

resource "aws_s3_bucket_versioning" "media_backup" {
  bucket = aws_s3_bucket.media_backup.id
  versioning_configuration {
    status = "Enabled"
  }
}

resource "aws_s3_bucket_acl" "media_backup" {
  bucket = aws_s3_bucket.media_backup.id
  acl = "private"
}
resource "aws_s3_bucket" "media" {
  bucket = "1234-media"
  
}

resource "aws_s3_bucket_versioning" "media" {
  bucket = aws_s3_bucket.media.id
  versioning_configuration {
    status = "Enabled"
  }
}

resource "aws_s3_bucket_acl" "media" {
  bucket = aws_s3_bucket.media.id
  acl = "private"
}

resource "aws_iam_role" "media_replication" {
  name = "1234-media-replication"

  assume_role_policy = <<POLICY
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "s3.amazonaws.com"
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}
POLICY
}

resource "aws_s3_bucket_replication_configuration" "media" {
  depends_on = [
      aws_s3_bucket_versioning.media_backup,
      aws_s3_bucket_versioning.media
    ]

  role = aws_iam_role.media_replication.arn
  bucket = aws_s3_bucket.media.id

  rule {
    id = "media-rr"

    status = "Disabled"

    destination {
      bucket = aws_s3_bucket.media_backup.arn
      storage_class = "ONEZONE_IA"
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![carl1](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/carl1/32/24144_2.png) [@carl1](https://discuss.hashicorp.com/u/carl1)\
**Post date:** [May 23, 2022, 4:49am UTC](https://discuss.hashicorp.com/t/ignore-changes-removing/39759/5 "2022-05-23T04:49:01Z")

</div>

Looks like it works properly if I use aws provider 4.15.1.

Perhaps there is some inconsistency with terraform 1.1.9 and aws provider 3.x? Maybe aws provider 3.x only works properly with terraform 1.0? or terraform 0.15?
