Terraform-provider-aws: AWS: diffs didn't match during apply. This is a bug with Terraform and should be reported as a GitHub Issue

Created on 16 Mar 2019  ·  6Comments  ·  Source: hashicorp/terraform-provider-aws

_This issue was originally opened by @iloveicedgreentea as hashicorp/terraform#20710. It was migrated here as a result of the provider split. The original body of the issue is below._


Please include the following information in your report:

Terraform Version: 0.11.10 Resource ID: aws_cloudwatch_metric_alarm.fleet-scale-down Mismatch reason: attribute mismatch: alarm_actions.1437824865 Diff One (usually from plan): *terraform.InstanceDiff{mu:sync.Mutex{state:0, sema:0x0}, Attributes:map[string]*terraform.ResourceAttrDiff{"alarm_actions.1437824865":*terraform.ResourceAttrDiff{Old:"", New:"arn:aws:autoscaling:us-east-1:REDACTED:scalingPolicy:7f2a81b4-fb1d-440a-9d81-fcc9a2bdf4e6:resource/ec2/spot-fleet-request/sfr-7b43f06a-49dc-4edd-8029-374e3ed1a2ca:policyName/scale-down-staging", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "alarm_actions.#":*terraform.ResourceAttrDiff{Old:"0", New:"1", 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{"alarm_actions.#":*terraform.ResourceAttrDiff{Old:"0", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "alarm_actions.1809487444":*terraform.ResourceAttrDiff{Old:"", New:"arn:aws:autoscaling:us-east-1:REDACTED:scalingPolicy:ba5ae522-5db0-4f83-96f9-d6570b59df71:resource/ec2/spot-fleet-request/sfr-02fbb2d2-c36a-48e7-ae43-3a498bf24324:policyName/scale-down-staging", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}}, Destroy:false, DestroyDeposed:false, DestroyTainted:false, Meta:map[string]interface {}(nil)}

```* provider.archive: version = "~> 1.1"

  • provider.aws: version = "~> 2.1"
  • provider.template: version = "~> 2.1"
    ```

I noticed when it creates these resources due to the fleet ID changing, it changes the alarm actions from 0 to 1 and.... it should just not do that.

Deleting the resource had no effect. I believe I will need to manually remove it from the state as it created fine the first time.

bug servicapplicationautoscaling

Most helpful comment

These updates here will be released in version 2.3.0 of the Terraform AWS Provider in the next day or two.

If you are still having trouble after upgrading to version 2.3.0 of the Terraform AWS Provider (when its released) and with a configuration looking similar to the above, please create a new GitHub issue with the relevant details from the issue template and we can further triage. Thanks!

All 6 comments

(More details/investigation in the comments on hashicorp/terraform#20710.)

Thanks so much @apparentlymart 👍 Looks like we are missing a ForceNew: true on the resource_id argument, which leaves the potential for dangling policies if only resource_id changes and the old target remains in addition to introducing the mismatched attributes during apply. 😖

To further help here, I am also going to update our aws_appautoscaling_policy resource documentation to always use the pattern of referencing the aws_appautoscaling_target attributes of the same names since this provides a workaround for this issue and generally makes writing these resource configurations easier since policies are tightly coupled to their targets anyways.

e.g.

resource "aws_appautoscaling_target" "example" {
  # ... other configuration ...
}

resource "aws_appautoscaling_policy" "example" {
 # ... other configuration ...

  resource_id        = "${aws_appautoscaling_target.example.resource_id}"
  scalable_dimension = "${aws_appautoscaling_target.example.scalable_dimension}"
  service_namespace  = "${aws_appautoscaling_target.example.service_namespace}"
}

Resource and documentation updates submitted: https://github.com/terraform-providers/terraform-provider-aws/pull/7982

These updates here will be released in version 2.3.0 of the Terraform AWS Provider in the next day or two.

If you are still having trouble after upgrading to version 2.3.0 of the Terraform AWS Provider (when its released) and with a configuration looking similar to the above, please create a new GitHub issue with the relevant details from the issue template and we can further triage. Thanks!

This has been released in version 2.3.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

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!

Was this page helpful?
0 / 5 - 0 ratings