Coder Social home page Coder Social logo

Comments (2)

sfc-gh-swinkler avatar sfc-gh-swinkler commented on July 27, 2024

Hello @spanhotra !

While it is an interesting use case, there isn't much we can do about it, as this is the intended behavior of Terraform providers. Values for configuration arguments to providers must be known during the plan. In this example, the role would not be known until after the apply, so it is rightfully throwing an error about the role not existing. From the official documentation on provider configuration:

https://developer.hashicorp.com/terraform/language/providers/configuration#provider-configuration-1

You can use expressions in the values of these configuration arguments but can only reference values that are known before the configuration is applied. This means you can safely reference input variables but not attributes exported by resources (with an exception for resource arguments that are specified directly in the configuration).

What you could do instead is perform a two-step operation. First, apply without the module, only creating roles you need to use later. Then, you can safely add the module back and use the roles since they will have already been created. You can also use data sources instead of resources, as the values will be known during the plan. Also, you can split this into two workspaces, the first workspaces creating the roles and the second workspace using the roles. I know that none of these suggestions are as convenient as using a single Terraform workspace, but they would at least unblock you.

I could perhaps think of a convoluted way to get this to work, despite the limitations of Terraform, such as delaying the initialization of the client until it's absolutely needed, but it wouldn't work for situations where you already had existing resources or imported resources. I'm not sure we want to go down that path, though.

Hope this helps,
Scott

from terraform-provider-snowflake.

spanhotra avatar spanhotra commented on July 27, 2024

Thank you @sfc-gh-swinkler for your response.
I will go ahead with your suggestion and create 2 step process for this.

May be this could be a feature request, a similar tool called Pulumi does support Dynamic Providers.

from terraform-provider-snowflake.

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.