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.8k stars 9.15k forks source link

Objects have changed outside of Terraform: Adds "tags = {}" to the resource #37601

Open mehta93 opened 5 months ago

mehta93 commented 5 months ago

Terraform Core Version

1.7.4

AWS Provider Version

5.39.1

Affected Resource(s)

aws_servicecatalog_provisioned_product aws_ssm_parameter

Expected Behavior

Terraform should not find this drift, instead it should take care of adding "tags = {}" during the resource creation itself.

Actual Behavior

When the resource is created terraform adds "tags = null" to the state file. It doesn't detect any changes during a subsequent plan but when a change is made to a resource other than the two affected resources, it shows a message "Note: Objects have changed outside of Terraform" and tries to add "tags = {}" to the resources.

Another issue is that the same message "Note: Objects have changed outside of Terraform" is shown for another resource "aws_route53_zone" as well. This is expected but the problem is that this message is shown when a different resource attribute is updated, example when an EBS volume attribute is updated. That ideally shouldn't be the case isn't it, as per the following article, "Note: Objects have changed outside of Terraform." will only stream in the plan output if the remote changes are related to resources and resource attributes that contributed to the changes Terraform is proposing to make in the current run.

https://support.hashicorp.com/hc/en-us/articles/4405950960147-New-Feature-Objects-have-changed-outside-of-Terraform

Relevant Error/Panic Output Snippet

Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the
last "terraform apply" which may have affected this plan:

module.ssm.aws_ssm_parameter.xxxx has changed
  ~ resource "aws_ssm_parameter" "xxxx" {
        id             = "yyyy"
        name           = "zzzz"
      + tags           = {}
        # (8 unchanged attributes hidden)
    }

Terraform Configuration Files

unable to reproduce the issue directly by creating a single resource

Steps to Reproduce

unable to reproduce the issue directly by creating a single resource

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 5 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue