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

External provider stores full path to command in state file causing thrash when executing on different machines #10777

Closed
lopopolo opened this issue Dec 16, 2016 · 4 comments

Comments

@lopopolo
Copy link

Terraform Version

Terraform v0.8.1

Affected Resource(s)

Please list the resources as a list, for example:

  • external data source

Terraform Configuration Files

data "external" "bastion-ingress" {
  program = ["bash", "${path.module}/external/my-ip.sh"]
}

Expected Behavior

What should have happened?

Terraform stores path relative to terraform root in state file

Actual Behavior

What actually happened?

                "data.external.bastion-ingress": {
                    "type": "external",
                    "depends_on": [],
                    "primary": {
                        "id": "-",
                        "attributes": {
                            "id": "-",
                            "program.#": "2",
                            "program.0": "bash",
                            "program.1": "/Users/lopopolo/x/y/z/terraform/.terraform/modules/ac5c735a3940e3c1dad95eef6511f232/external/my-ip.sh",
                            "result.%": "1",
                            "result.cidr": "x.y.z.a/32"
                        },
                        "meta": {},
                        "tainted": false
                    },
                    "deposed": [],
                    "provider": ""
                }

Steps to Reproduce

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

  1. terraform apply

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

@apparentlymart
Copy link
Contributor

Hi @lopopolo. Sorry for this surprising behavior.

This is a specific case of the issue described in #7927, namely that using path.module anywhere will cause unnecessary diffs when shifting configurations between machines. Also semi-related to #8204, where path.module causes a different but similar problem.

Our best workaround for now is to use the ignore_changes feature to instruct Terraform to not consider changes to this attribute when producing a diff. This is of course not great because it means actually changing the command to run won't do anything, but hopefully this works for you in the mean time.

I'm going to close this to consolidate discussion in #7927, but thanks for taking the time to file this issue!

@wr0ngway
Copy link

In case anyone tries to use ignore_changes, lifecycle blocks don't seem to work on data sources like external

@apparentlymart
Copy link
Contributor

Looking at this again, it occurs to me that the full path being in the state is a little confusing but in most cases should be harmless: since this is a data resource, Terraform will refresh it for each refresh or plan command anyway, discarding the previous state.

My previous comment about ignore_changes was a bad suggestion. I assume at the time that I hadn't noticed we were talking about a data resource, and was instead thinking about the general problem described in #7927, for which that is the workaround.

@ghost
Copy link

ghost commented Apr 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 Apr 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants