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

use self variables in module definition #1667

Closed
moosilauke18 opened this Issue Apr 24, 2015 · 3 comments

Comments

Projects
None yet
4 participants
@moosilauke18

Basically I am using modules to define a cluster with each in a different availability zone. One of the variables I define is the availability_zones that is used in the module. I also use the variable subnet_id which I have set per availability zone. The problem is, it I need to send the correct subnet_id based on what availability_zone set is. How can I do that.

Here's the module:

module "us-east-1c" {
    source = "./cluster"
    access_key = "${var.access_key}"
    secret_key = "${var.secret_key}"
    coreos = "${lookup(var.coreos, var.region)}"

    region = "us-east-1"
    vpc_id = "${lookup(var.vpc_id, var.region)}"

    # Here lies the problem
    subnet_id = "${lookup(var.subnet_id, var.availability_zones)}"
    availability_zones = "us-east-1c"
}

I can get past this, by using subnet_id = "${var.subnet_id.us-east-1c}" but I'd prefer if I only had to change the variables in one location. Is this possible currently? I was thinking of doing something like self.availability_zones.

Thanks!!

@phinze

This comment has been minimized.

Show comment
Hide comment
@phinze

phinze Apr 25, 2015

Member

Off the top of my head I can't think of a way to do this today - tagged as an enhancement for now and if I can think of a trick that makes this nicer given the current feature set I'll follow up!

Member

phinze commented Apr 25, 2015

Off the top of my head I can't think of a way to do this today - tagged as an enhancement for now and if I can think of a trick that makes this nicer given the current feature set I'll follow up!

@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh Apr 26, 2015

Member

There have been other issues about this. Its unlikely we'll ever be able to really do this given the current architecture. It'd be a nice to have but I don't see a way to get it done in any near or mid-term release (3, 6, 9 months). I'm going to close at "wontfix" for now. Maybe we can swing back one day.

Member

mitchellh commented Apr 26, 2015

There have been other issues about this. Its unlikely we'll ever be able to really do this given the current architecture. It'd be a nice to have but I don't see a way to get it done in any near or mid-term release (3, 6, 9 months). I'm going to close at "wontfix" for now. Maybe we can swing back one day.

@mitchellh mitchellh closed this Apr 26, 2015

@emyller

This comment has been minimized.

Show comment
Hide comment
@emyller

emyller Apr 9, 2018

@mitchellh Did anything change that would allow us to have this feature nowadays?

emyller commented Apr 9, 2018

@mitchellh Did anything change that would allow us to have this feature nowadays?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment