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

reference modules: config: unknown module referenced #697

Closed
xueshanf opened this issue Dec 19, 2014 · 4 comments
Closed

reference modules: config: unknown module referenced #697

xueshanf opened this issue Dec 19, 2014 · 4 comments

Comments

@xueshanf
Copy link

I am trying to make module references between two subfolders to work, but could not get it to work. I might have missed something really simple.

There is simplified setup:

%terraform get
Get: file:///Users/..../projects/vpc
Get: file:///Users/..../projects/etcd

Under projects (root level), main.cf

 module "vpc" {
   source = "./vpc"
}
module "etcd" {
   source = "./etcd"
}

Subfolder ./vpc/subnet-etcd.tf, in addition to an empty main.cf:

resource "aws_subnet" "docker-etcd-a" {
    vpc_id = ....
    cidr_block = ...
}
output "docker_etcd_a" {
  value = "${aws_subnet.docker-etcd-a.id}"
}

Subfolder ./etcd/etcd-a-01.tf

resource "aws_instance" "etcd-a-01" {
    ami = ...
    instance_type = ..
    subnet_id = "${module.vpc.docker_etcd_a}"
}

%terraform plan --module-depth=-1

There are warnings and/or errors related to your configuration. Please
fix these before continuing.

Errors:

  • module etcd.root: 1 error(s) occurred:
  • resource 'aws_instance.etcd-a-01' config: unknown module referenced: vpc

Any ideas what's wrong with the setup? Thanks!

@zdexter
Copy link

zdexter commented Dec 24, 2014

I have the same issues when using an AWS EIP public_ip output to fill a cloudflare record. The former is one folder deeper than the root, and the latter is also one folder deeper than the root, in a different module. So basically the same setup as the OP.

@mitchellh
Copy link
Contributor

Hi @xueshanf! This looks to be working as intended: you can only reference modules that are defined within your own module scope. It looks like the etcd module is trying to access the vpc module which was defined in the root module. This can't happen. You'll have to pass in the VPC ID as a parameter to the module. HTH!

@xueshanf
Copy link
Author

Got it. Thanks. I used a script to generate tf vars from the output of the vpc's module so they are available to other modules.

Xueshan

On Feb 17, 2015, at 13:26, Mitchell Hashimoto [email protected] wrote:

Hi @xueshanf! This looks to be working as intended: you can only reference modules that are defined within your own module scope. It looks like the etcd module is trying to access the vpc module which was defined in the root module. This can't happen. You'll have to pass in the VPC ID as a parameter to the module. HTH!


Reply to this email directly or view it on GitHub.

@ghost
Copy link

ghost commented May 4, 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 May 4, 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