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 Not Run When Query Contains Computed Values #19

Closed
danieladams456 opened this issue Jul 12, 2018 · 2 comments
Closed

External Not Run When Query Contains Computed Values #19

danieladams456 opened this issue Jul 12, 2018 · 2 comments

Comments

@danieladams456
Copy link

Terraform Version

Terraform v0.11.7
+ provider.aws v1.27.0
+ provider.external v1.0.0
+ provider.template v1.0.0

Affected Resource(s)

  • data.external

Terraform Configuration Files

In the real setup, I have a data.template_file injecting ARNs and then this python renderer transforming a DSL into a full Swagger spec. However, I was able to condense it down to just the lambda ARN going directly into the external provider.

Working

data "external" "swagger_renderer" {
  program = ["python3", "${path.module}/data/swagger_renderer.py"]
  query = {
    template_input = "${var.lambda_handler_invoke_arn}"
  }
}

Failing

data "external" "swagger_renderer" {
  program = ["python3", "${path.module}/data/swagger_renderer.py"]
  query = {
    # computed value on not yet created resource
    template_input = "${aws_lambda_function.api_handler.invoke_arn}"
  }
}

Debug Output

https://gist.github.com/danieladams456/76cb77fc649bc1dc40746889d8b14bf2

Expected Behavior

Plan should either:

  1. not call external provider
  2. use a placeholder

Based on this core PR (hashicorp/terraform#10670), I tried adding depends_on to defer evaluation until after the lambda function was created, but it didn't seem to change anything.

Actual Behavior

It sees there is no output variable, but the external script is not run. I verified this with file-based logging side effects.
aws_api_gateway_rest_api.api: Resource 'data.external.swagger_renderer' does not have attribute 'result.rendered' for variable 'data.external.swagger_renderer.result.rendered'

Steps to Reproduce

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

  1. terraform plan

References

hashicorp/terraform#10670

Workaround

Put anything the template depends on in a separate module and use outputs/variables to move the data between modules. The external provider works fine with simple variables.

@danieladams456
Copy link
Author

This is actually working as intended per the nice summary in hashicorp/terraform#17034. The problem is the reading of the outputs as stated in #4. At first I didn't realize it applied since when all the inputs were variables it worked.

Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2024
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

1 participant