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

Provider cannot use variables from resources #3390

Closed
janschumann opened this issue Oct 2, 2015 · 3 comments
Closed

Provider cannot use variables from resources #3390

janschumann opened this issue Oct 2, 2015 · 3 comments

Comments

@janschumann
Copy link
Contributor

It would be great, metadata of an atlas artifact could be used in provider configuration. Please see the following example:

resource "atlas_artifact" "debian7-puppet4-base" {
  name    = "janschumann/debian7-puppet4-base"
  type    = "aws.ami"
  version = "latest"
}

provider "aws" {
  region = "${atlas_artifact.debian7-puppet4-base-eu.metadata_full.region}"
}

resource "aws_instance" "debian7-puppet4-base" {
  ami           = "${atlas_artifact.debian7-puppet4-base.metadata_full.ami_id}"
  instance_type = "t2.medium"
}

The provider seems to be interpreted first and thus, atlas_artifact.debian7-puppet4-base-eu.metadata_full.region is empty.

What do you think?

@apparentlymart
Copy link
Contributor

I think what you're describing here is the issue I wrote up in #2976. I very much agree that the current behavior is sub-optimal and it should be possible to do what you showed in your example, though as you'll see in that other issue there are some non-trivial architectural issues to work through before that can be fully supported.

There is currently a (rather awkward) workaround for this that may allow you to proceed: once the atlas_artifact resource has been created the provider will be interpolated directly, so you can resolve the chicken-and-egg problem by forcing that resource to be created before the others:

  • terraform apply -target="atlas_artifact.debian7-puppet4-base"

After that you should have the artifact resource in the Terraform state and so a subsequent plan/apply of the whole configuration should work. It can then work on subsequent updates because the artifact resource will already exist in the state and so Terraform will refresh it before it makes any plan.

@phinze
Copy link
Contributor

phinze commented Oct 12, 2015

Yep - @apparentlymart is correct that this is specific to atlas_artifact and other resources like it. Keep an eye on #2976, which will indeed address this issue. Closing this thread to keep things consolidated.

@phinze phinze closed this as completed Oct 12, 2015
@ghost
Copy link

ghost commented Apr 30, 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 30, 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