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

String is not interpolated for resource provider alias #14273

Closed
scriptjs opened this issue May 7, 2017 · 2 comments
Closed

String is not interpolated for resource provider alias #14273

scriptjs opened this issue May 7, 2017 · 2 comments

Comments

@scriptjs
Copy link

scriptjs commented May 7, 2017

The provider cannot be interpolated from an expression to look up the appropriate provider alias.

Terraform Version

0.9.4

Affected Resource(s)

Please list the resources as a list, for example:

  • openstack_images_image_v2

Terraform Configuration Files

variable openstack_tenants {
  default = [
    "openstack.aliased_tenant_0",
    "openstack.aliased_tenant_1"
  ]
}
variable name {}
variable local_file_path {}
variable name {}

provider "openstack" {}
provider "openstack" {
  alias = "aliased_tenant_0"
  tenant_name = "aliased_tenant"
}
provider "openstack" {
  alias = "aliased_tenant_1"
  tenant_name = "another_tenant"
}

resource "openstack_images_image_v2" "tenant_images" {
  provider = "${element(var.openstack_tenants, count.index)}"
  name = "${var.name}"
  local_file_path = "${var.local_file_path}"
  container_format = "bare"
  disk_format = "qcow2"
  visibility = "private"
  min_ram_mb = "384"
  min_disk_gb = "8"
  region = "${var.region}"
  count = "${length(var.openstack_tenants)}"
}

Expected Behavior

Interpret the expression to produce the provider alias in the resource to enable execution of the loop.

Actual Behavior

Throws an error:

Error asking for user input: 1 error(s) occurred:

* openstack_images_image_v2.tenant_images: provider ${element(var.openstack_tenants, count.index)} couldn't be found

Steps to Reproduce

  1. terraform plan

NOTE: This works when provider in the resource is set to what ought to be interpolated ie. provider = "openstack.aliased_tenant_0" but does not work when an expression is used that ought to be first evaluated. "openstack.aliased_tenant_0" and "openstack.aliased_tenant_1" are contrived in the above example so as not to leak identities of tenants on the private cloud.

@apparentlymart
Copy link
Contributor

Hi @scriptjs!

At present this is an intentional limitation due to the fact that providers need to be known very early on in Terraform's lifecycle, before interpolation is possible. This might change in future, but there are no immediate plans for this.

The existing issue #3656 is already covering this request, so I'm going to close this one just to consolidate the discussion over there.

@ghost
Copy link

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

No branches or pull requests

3 participants