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 alias does not work properly inside module v(0.5.3) #2023

Closed
i0n opened this issue May 20, 2015 · 7 comments · Fixed by #2475
Closed

Provider alias does not work properly inside module v(0.5.3) #2023

i0n opened this issue May 20, 2015 · 7 comments · Fixed by #2475
Assignees

Comments

@i0n
Copy link

i0n commented May 20, 2015

Hey all. I have only tested this with the google provider
Terraform v0.5.3-dev (0d575b7)
I also tested with 0.5.1 with the same behaviour.
main.tf

module "test" {
  source = "./module"
}

./module/main.tf

provider "google" {
  alias = "eu"
  project = "staging"
  account_file = "google.json"
  region = "europe-west1"
}

resource "google_compute_address" "new_ip" {
  provider = "google.eu"
  name = "new_ip"
}

terraform plan produces:

Errors:

  * 1 error(s) occurred:

* module.test: provider google.eu couldn't be found

If I include the provider inside the main.tf file I get the same error.
If I include the provider in both main.tf and ./module/main.tf it works.

@LeftyBC
Copy link
Contributor

LeftyBC commented Jun 17, 2015

I'm hitting this bug as well - we've got a route53 account that's managed by a third party, so we need to have a secondary AWS provider, but can't use an aliased provider inside the module.

@tphummel
Copy link
Contributor

I can reproduce this in a module using the 0.5.3 release on OSX 10.10.3. It works if I move the aliased provider block and the subsequent resources out of the module (into a main.tf).

@rbowlby
Copy link

rbowlby commented Jun 23, 2015

Reproduced as well. Makes re-using a module in multiple regions aws regions impossible. :(

@donotpush
Copy link

Is there a solution for this problem?

@apparentlymart
Copy link
Contributor

Hi @JulianAlves,

The problem as stated here was fixed a couple years ago. If you are seeing a similar problem, please open a new top-level issue with some more information on what you're seeing and we can work on debugging it against the latest version of Terraform.

@git-vp
Copy link

git-vp commented Jul 31, 2017

Hi apparentlymart,

I am seeing the same issue reported by @JulianAlves.
Our use case: we have to create ARM resources in multiple subscriptions (dev, test, sandpit) using ARM. These ARM resources like VNET are created as reusable modules, which are then referred to in in an environment where that resource is required. Therefore, specific to each subscription we have defined a provider like below:

variable "dev_subscription_id" {}
provider "azurerm" {
alias = "dev"
subscription_id = "${var.dev_subscription_id}"
}

A sample module like VNET is defined as below, where the provider alias is given.
resource "azurerm_virtual_network" "vnet" {
....
provider = "${var.provider}"
....
}

This is how the module is referenced:

module "rg" {
source = "../../../../modules/azure/network/rg"
....
provider = "azurerm.sandpit"
.....
}

This gives the following error:

  • module.vnet.azurerm_virtual_network.vnet: provider ${var.provider} couldn't be found

As mentioned in the above thread, if I include provider in each module then it doesn't give this error. Hope to have this fixed soon as it is really nasty to give provider block in each module.

Many thanks,
Venu

@ghost
Copy link

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

Successfully merging a pull request may close this issue.

9 participants