Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some data sources always show diff during plan in 0.13, where they don't in 0.12. #25858

Closed
TonyLovesDevOps opened this issue Aug 14, 2020 · 3 comments
Labels
bug new new issue not yet triaged

Comments

@TonyLovesDevOps
Copy link

Terraform Version

Terraform v0.13.0

Terraform Configuration Files

provider "aws" {
  region  = "us-east-1"
  version = "~> 3.2"
}

data "aws_availability_zones" "available"  {}

Expected Behavior

The plan should have showed no changes.

Actual Behavior

The plan shows changes. In our larger terraform repos with dozens of data resources, this causes a huge amount of noise in the plan output, even when no actual infrastructure changes are going to be made. There seems to be no way to disable the output to show only changes.

Steps to Reproduce

  1. Make sure you have valid AWS credentials set up in ~/.aws/credentials
  2. Save the below script as data_source_lookup.sh:
#!/usr/bin/env bash

cat <<"EOF" | docker run -i --rm -v ~/.aws:/root/.aws --entrypoint sh $1
cat <<TFCODE > /plan.tf
provider "aws" {
  region  = "us-east-1"
  version = "~> 3.2" 
}

data "aws_availability_zones" "available"  {}

TFCODE
terraform init
terraform plan
EOF
  1. Mark the script as executable: chmod +x data_source_lookup.sh
  2. Run the plan with hashicorp/terraform:0.12.29 container and see there is no diff:
$ ./data_source_lookup.sh hashicorp/terraform:0.12.29

Initializing the backend...

Initializing provider plugins...
- Checking for available provider plugins...
- Downloading plugin for provider "aws" (hashicorp/aws) 3.2.0...

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.aws_availability_zones.available: Refreshing state...

------------------------------------------------------------------------

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.
  1. Run the plan with hashicorp/terraform:0.13.0 container and see the diff:
$ ./data_source_lookup.sh hashicorp/terraform:0.13.0                                                                                                                                                      
Initializing the backend...

Initializing provider plugins...
- Finding hashicorp/aws versions matching "~> 3.2"...
- Installing hashicorp/aws v3.2.0...
- Installed hashicorp/aws v3.2.0 (signed by HashiCorp)

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.aws_availability_zones.available: Refreshing state...

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
 <= read (data resources)

Terraform will perform the following actions:

  # data.aws_availability_zones.available will be read during apply
  # (config refers to values not yet known)
 <= data "aws_availability_zones" "available"  {
        group_names = [
            "us-east-1",
        ]
      ~ id          = "2020-08-14 16:39:32.726054182 +0000 UTC" -> "2020-08-14 16:39:34.61159939 +0000 UTC"
        names       = [
            "us-east-1a",
            "us-east-1b",
            "us-east-1c",
            "us-east-1d",
            "us-east-1e",
            "us-east-1f",
        ]
        zone_ids    = [
            "use1-az4",
            "use1-az6",
            "use1-az1",
            "use1-az2",
            "use1-az3",
            "use1-az5",
        ]
    }

Plan: 0 to add, 0 to change, 0 to destroy.

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

Additional Context

References

#17034

@TonyLovesDevOps TonyLovesDevOps added bug new new issue not yet triaged labels Aug 14, 2020
@remilapeyre
Copy link
Contributor

Hi @TonyLovesDevOps, thanks for reporting this!

This is an issue with the Terraform AWS provider not the core of Terraform so it should be reported to https://github.com/terraform-providers/terraform-provider-aws.

An issue for this problem has already be opened at hashicorp/terraform-provider-aws#14579.

@TonyLovesDevOps
Copy link
Author

It looks like this has already been documented in terraform-provider-aws/issues/14579 and #25812, so I believe this can be closed.

@ghost
Copy link

ghost commented Sep 14, 2020

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Sep 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants