hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.87k stars 9.21k forks source link

s3 buckets diff didn't match during apply #642

Closed hashibot closed 5 years ago

hashibot commented 7 years ago

This issue was originally opened by @sprutner as hashicorp/terraform#13169. It was migrated here as part of the provider split. The original body of the issue is below.


Saw this request to report issue, so here you go.

Terraform Version

Terraform 0.9.1

Affected Resource(s)

Please list the resources as a list, for example:

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files


resource "aws_s3_bucket" "terraform_state_multi" {
  bucket = "xxxx-terraform-state-${var.environment}"

  versioning {
    enabled = true
  }

  lifecycle {
    prevent_destroy = true
  }

  replication_configuration {
    role = "${aws_iam_role.replication_multi.arn}"
    rules {
        id     = "state_replication_${var.environment}"
        prefix = ""
        status = "Enabled"

        destination {
            bucket        = "${aws_s3_bucket.destination_multi.arn}"
            storage_class = "STANDARD"
        }
    }
  }
}

resource "aws_s3_bucket" "destination_multi" {
    provider = "aws.west"
    bucket   = "xxx-terraform-state-${var.environment}-west"
    region   = "us-west-1"

    versioning {
        enabled = true
    }
}

Debug Output

Please include the following information in your report:

Terraform Version: 0.9.1
Resource ID: aws_s3_bucket.terraform_state_multi
Mismatch reason: attribute mismatch: replication_configuration.0.rules.2160554257.destination.#
Diff One (usually from plan): *terraform.InstanceDiff{mu:sync.Mutex{state:0, sema:0x0}, Attributes:map[string]*terraform.ResourceAttrDiff{"replication_configuration.0.rules.~2160554257.status":*terraform.ResourceAttrDiff{Old:"", New:"Enabled", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "replication_configuration.0.rules.~2160554257.destination.#":*terraform.ResourceAttrDiff{Old:"0", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "replication_configuration.0.rules.~2160554257.destination.~3137164442.storage_class":*terraform.ResourceAttrDiff{Old:"", New:"STANDARD", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "replication_configuration.0.rules.2160554257.destination.#":*terraform.ResourceAttrDiff{Old:"1", New:"0", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "replication_configuration.0.rules.2160554257.status":*terraform.ResourceAttrDiff{Old:"Enabled", New:"", NewComputed:false, NewRemoved:true, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "replication_configuration.0.rules.~2160554257.destination.~3137164442.bucket":*terraform.ResourceAttrDiff{Old:"", New:"${aws_s3_bucket.destination_multi.arn}", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "replication_configuration.0.rules.2160554257.destination.2040754993.bucket":*terraform.ResourceAttrDiff{Old:"arn:aws:s3:::xxx-terraform-state-west-qa", New:"", NewComputed:false, NewRemoved:true, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "replication_configuration.0.rules.2160554257.prefix":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:false, NewRemoved:true, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "replication_configuration.0.rules.2160554257.id":*terraform.ResourceAttrDiff{Old:"state_replication_qa", New:"", NewComputed:false, NewRemoved:true, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "replication_configuration.0.rules.2160554257.destination.2040754993.storage_class":*terraform.ResourceAttrDiff{Old:"STANDARD", New:"", NewComputed:false, NewRemoved:true, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "replication_configuration.0.rules.~2160554257.prefix":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "replication_configuration.0.rules.~2160554257.id":*terraform.ResourceAttrDiff{Old:"", New:"state_replication_qa", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}}, Destroy:false, DestroyDeposed:false, DestroyTainted:false, Meta:map[string]interface {}(nil)}
Diff Two (usually from apply): *terraform.InstanceDiff{mu:sync.Mutex{state:0, sema:0x0}, Attributes:map[string]*terraform.ResourceAttrDiff(nil), Destroy:false, DestroyDeposed:false, DestroyTainted:false, Meta:map[string]interface {}(nil)}

Also include as much context as you can about your config, state, and the steps you performed to trigger this error.

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.

Expected Behavior

Clean apply

Actual Behavior

This error. Re-running apply fixes this.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply
Chhed13 commented 6 years ago

Can not reproduce. @sprutner is it still actual?

bflad commented 5 years ago

Hi @sprutner 👋 Sorry you ran into this confusing error and thank you for reporting it. There have been a lot of relevant changes in the Terraform Core and Terraform AWS Provider codebases since this issue was originally reported so as a first step it might be best to try updating to recent versions of both and seeing if any of those updates may have resolved this issue.

Attempting to troubleshoot these types of errors is very difficult in Terraform 0.11 and earlier as those versions will report this problem (diffs didn't match during apply error) where a problematic configuration value exists or is referenced and not where the Terraform resource with the underlying problem actually exists. We typically will need much more information than the original error message suggests for filing the issue (e.g. the full Terraform configuration). There are also frequent issues in the Terraform 0.11 error reporting where the error message is due to behavior outside the control of the Terraform resources themselves (e.g. lifecycle configurations).

In Terraform 0.12 and later, the "value did not match" type of error can now be found with the newer Provider produced inconsistent result after apply error, which better reports the source of the problem so the provider maintainers and community can more easily work towards a fix of the issue. Other similar errors that fell previously into diffs didn't match during apply errors, but outside problems within the Terraform provider are also better diagnosed before being displayed.

Since the majority of the Terraform code path and reporting structure of these errors has changed between Terraform 0.11 and 0.12, along with the difficult triage process in Terraform 0.11 and earlier, the maintainers prefer to close these older issues to continue troubleshooting and fixing based on Terraform 0.12's error reporting instead. I apologize for this unsatisfying closure of this particular version of the issue.

That said, if the configuration does happen to reproduce the newer Provider produced inconsistent result after apply error in Terraform 0.12 (which requires Terraform AWS Provider version 2.7.0 or later), please do not hesitate to file a new issue and complete all of the information requested in the Bug Report template so we can hopefully get to the root cause for fixing the issue. Thanks again for this bug report and sorry about the additional steps for getting a potential fix implemented.

ghost commented 5 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!