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.74k stars 9.1k forks source link

[Bug]: fix the missing json normalization rule to the aws_codepipeline resource #37201

Open anujthedevopsguy opened 4 months ago

anujthedevopsguy commented 4 months ago

Terraform Core Version

v1.3.6

AWS Provider Version

5.17.0

Affected Resource(s)

AWS codepipeline terraform resource. aws_codepipeline

Expected Behavior

I have written TF code for the AWS code pipeline. Then, trying to import the existing code pipeline. When I run Terraform Plan, I see a whitespace change in the plan output.

 ~ resource "aws_codepipeline" "codepipeline_ecs" {
        id       = "nuvance-tenant-service-pipeline"
        name     = "nuvance-tenant-service-pipeline"
        tags     = {
            "Environment" = "prod"
            "Managed_By"  = "Terraform"
            "Stackname"   = "api"
        }
        # (3 unchanged attributes hidden)

      ~ stage {
            name = "Build"

          ~ action {
              ~ configuration    = {
                  ~ "EnvironmentVariables" = jsonencode( # whitespace changes
                        [
                            {
                                name  = "DEPLOY_ENV"
                                type  = "PARAMETER_STORE"
                                value = "/nuvance-prod/ng-tenant-service/DEPLOY_ENV"
                            },
                            {
                                name  = "ROLLBACK_COMMIT_ID"
                                type  = "PARAMETER_STORE"
                                value = "/nuvance-prod/tenant/ROLLBACK_COMMIT_ID"
                            },
                        ]
                    )
                    # (1 unchanged element hidden)
                }
                name             = "Build"
                # (9 unchanged attributes hidden)
            }
        }

        # (4 unchanged blocks hidden)
    }

I have verified. All env variables are exactly same. Don't know which whitespace is causing issue.

Actual Behavior

After importing the code pipeline followed by the Terraform plan, it should say that there are no infrastructure changes.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

This file is maintained automatically by "terraform init".

Manual edits may be lost in future updates.

provider "registry.terraform.io/hashicorp/aws" { version = "5.17.0" hashes = [ "h1:U+EDfeUqefebA1h7KyBMD1xH0h311LMi7wijPDPkC/0=", "zh:0087b9dd2c9c638fd63e527e5b9b70988008e263d480a199f180efe5a4f070f0", "zh:0fd532a4fd03ddef11f0502ff9fe4343443e1ae805cb088825a71d6d48906ec7", "zh:16411e731100cd15f7e165f53c23be784b2c86c2fcfd34781e0642d17090d342", "zh:251d520927e77f091e2ec6302e921d839a2430ac541c6a461aed7c08fb5eae12", "zh:4919e69682dc2a8c32d44f6ebc038a52c9f40af9c61cb574b64e322800d6a794", "zh:5334c60759d5f76bdc51355d1a3ebcc451d4d20f632f5c73b6e55c52b5dc9e52", "zh:7341a2b7247572eba0d0486094a870b872967702ec0ac7af728c2df2c30af4e5", "zh:81d1b1cb2cac6b3922a05adab69543b678f344a01debd54500263700dad7a288", "zh:882bc8e15ef6d4020a07321ec4c056977c5c1d96934118032922561d29504d43", "zh:8cd4871ef2b03fd916de1a6dc7eb8a81a354c421177d4334a2e3308e50215e41", "zh:97e12fe6529b21298adf1046c5e20ac35d0569c836a6f385ff041e257e00cfd2", "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", "zh:9f5baf5d59b9f3cf5504d1fa975f10f27da3791896a9e18ece47c258bac17634", "zh:dffafba6731ac1db1c540bdbd6a8c878486b71de9d0ca1d23c5c00a6c3c14d80", "zh:fa7440c3c15a42fc5731444d324ced75407d417bfe3184661ae47d40a9718dce", ] }

Steps to Reproduce

write a terraform code for AWS code pipeline using aws_codepipeline on windows machine and push the code. Later, make some changes on the macbook machine and push the code. Try to run terraform plan

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

similar to https://discuss.hashicorp.com/t/ignore-whitespace-changes/62814/5

Would you like to implement a fix?

None

github-actions[bot] commented 4 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue