Giter VIP home page Giter VIP logo

Comments (2)

ricoli avatar ricoli commented on August 29, 2024

Indeed, I've seen this same behaviour more than a year later, using version 1.0.0 of this provider

from terraform-provider-template.

apparentlymart avatar apparentlymart commented on August 29, 2024

Hi all,

The cause of this is actually in Terraform Core itself rather than in the provider. The issue is that depends_on for data resources currently forces Terraform to always defer the data source read to apply time, since depends_on doesn't give enough information for Terraform to know whether the resource is depending on an apply-time side-effect of the dependency. This limitation is captured in hashicorp/terraform#17034.

The workaround for now is to use implicit rather than explicit dependencies, which tells Terraform a specific attribute of the other object that is needed before the data resource can be processed and thus allows Terraform to recognize that it is safe to read it during the plan step. In this case this can be achieved by reading the bucket name through the other data resource, thus creating that dependency:

data "aws_s3_bucket_object" "archive" {
  bucket = "${var.bucket}"
  key    = "${var.product}/${var.service}/${var.service}-${var.version}.zip"
}

data "template_file" "user_data" {
  template   = "${file("${path.module}/templates/userdata.ps1")}"

  vars = {
    bucket  = "${data.aws_s3_bucket_object.archive.bucket}"
    key     = "${var.product}/${var.service}/${var.service}-${var.version}.zip"
    service = "${var.service}"
    version = "${var.version}"
  }
}

To eventually resolve hashicorp/terraform#17034 in Terraform Core we intend to adjust the lifecycle of data sources slightly so that the steps can happen in the right order to allow depends_on to work in a more useful way. That work has been on hold while we've been working on the 0.12 release but we will dig into some further design/prototyping for it afterwards.

from terraform-provider-template.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.