{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/4789","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/4789/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/4789/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/4789/events","html_url":"https://github.com/hashicorp/terraform/issues/4789","id":128028445,"number":4789,"title":"Provider Aliases Not Working w/ Modules?","user":{"login":"tylerFowler","id":5419372,"avatar_url":"https://avatars.githubusercontent.com/u/5419372?v=3","gravatar_id":"","url":"https://api.github.com/users/tylerFowler","html_url":"https://github.com/tylerFowler","followers_url":"https://api.github.com/users/tylerFowler/followers","following_url":"https://api.github.com/users/tylerFowler/following{/other_user}","gists_url":"https://api.github.com/users/tylerFowler/gists{/gist_id}","starred_url":"https://api.github.com/users/tylerFowler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tylerFowler/subscriptions","organizations_url":"https://api.github.com/users/tylerFowler/orgs","repos_url":"https://api.github.com/users/tylerFowler/repos","events_url":"https://api.github.com/users/tylerFowler/events{/privacy}","received_events_url":"https://api.github.com/users/tylerFowler/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hashicorp/terraform/labels/bug","name":"bug","color":"f7c6c7"},{"url":"https://api.github.com/repos/hashicorp/terraform/labels/core","name":"core","color":"cccccc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-21T21:54:06Z","updated_at":"2016-01-22T20:14:02Z","closed_at":null,"body":"I'm having an issue regarding a particular multi-region cluster configuration. Note that I'm currently only using modules to create separation within my configuration rather than focusing on creating reusable modules, so I'll have a root module with variables & providers and then, say, an AWS module that configures things like security groups or S3 buckets.\r\n\r\nSo in my top level (root) module I have a `providers.tf` file like:\r\n```\r\nprovider \"aws\" {\r\n  access_key = \"${var.aws_access_key}\"\r\n  secret_key = \"${var.aws_secret_key}\"\r\n  region = \"${var.aws_region}\"\r\n}\r\n\r\nprovider \"aws\" {\r\n  alias = \"eu\"\r\n  region = \"eu-central-1\"\r\n}\r\n```\r\n\r\nAnd then in a module I use to define bare AWS infrastructure resources I have something like this:\r\n```\r\nresource \"aws_instance\" \"some_us_cluster_node\" {\r\n  # config ...\r\n}\r\n\r\nresource \"aws_instance\" \"some_eu_cluster_node\" {\r\n  provider = \"aws.eu\"\r\n  # config ...\r\n}\r\n\r\n...\r\n```\r\n\r\nHowever when I do this I get an error:\r\n`aws_instance.some_eu_cluster_node: resource depends on non-configured provider 'aws.eu'`\r\n\r\nSo I tried instead defining the provider aliases in the `module` block rather than the root level module (while keeping the default `aws` provider at the root level):\r\n\r\n```\r\nmodule \"aws\" {\r\n  source = \"./aws\"\r\n\r\n  provider \"aws\" {\r\n    alias = \"eu\"\r\n    region = \"eu-central-1\"\r\n  }\r\n}\r\n```\r\n\r\nBut then, interestingly enough, I get no errors but I get a prompt asking me what region to use for the `provider.aws.eu` resource as if I had left it out or as if I'm using a variable without a default value:\r\n```log\r\nprovider.aws.eu.region\r\n  [description...]\r\n\r\n  Default: us-east-1\r\n  Enter a value:\r\n```\r\n\r\nSo am I using the provider incorrectly? Do I need to propagate the provider alias down to the `aws` module like I do with variables? Or can I simply not use top level provider aliases inside of submodules? (which would be surprising since I can use a default `aws` provider defined at the top level inside of my submodules with no problem)\r\n\r\nFinally I am on terraform version `0.6.9`"},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/174034281","html_url":"https://github.com/hashicorp/terraform/issues/4789#issuecomment-174034281","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/4789","id":174034281,"user":{"login":"tylerFowler","id":5419372,"avatar_url":"https://avatars.githubusercontent.com/u/5419372?v=3","gravatar_id":"","url":"https://api.github.com/users/tylerFowler","html_url":"https://github.com/tylerFowler","followers_url":"https://api.github.com/users/tylerFowler/followers","following_url":"https://api.github.com/users/tylerFowler/following{/other_user}","gists_url":"https://api.github.com/users/tylerFowler/gists{/gist_id}","starred_url":"https://api.github.com/users/tylerFowler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tylerFowler/subscriptions","organizations_url":"https://api.github.com/users/tylerFowler/orgs","repos_url":"https://api.github.com/users/tylerFowler/repos","events_url":"https://api.github.com/users/tylerFowler/events{/privacy}","received_events_url":"https://api.github.com/users/tylerFowler/received_events","type":"User","site_admin":false},"created_at":"2016-01-22T20:14:02Z","updated_at":"2016-01-22T20:14:02Z","body":"After playing around a while I finally found that if I placed the aliases (leaving the default at the top level) within the same module as the resources that used them, as opposed to the root or the root's `module` definition, it will work. But I'm under the impression that the correct behavior would be to make root level provider aliases available to submodules, though correct me if I'm wrong."}}