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

crash retrieving map with interpolated key #9282

Closed
blalor opened this issue Oct 7, 2016 · 2 comments
Closed

crash retrieving map with interpolated key #9282

blalor opened this issue Oct 7, 2016 · 2 comments

Comments

@blalor
Copy link
Contributor

blalor commented Oct 7, 2016

Terraform Version

v0.7.5

Affected Resource(s)

This appears to be an issue with the core.

Terraform Configuration Files

Attached: tf-reproduce.zip

modules/subnets/main.tf contains a map output:

output "vpcs" {
    value = "${map(
        "dev_aws_gen_us-east-1", "10.112.0.0/19"
    )}"
}

It's referenced in main.tf like

resource "aws_vpc" "default" {
    cidr_block = "${module.subnets.vpcs[format("%s_%s_%s_%s", var.environment, var.provider, var.account, var.region)]}"
}

Panic Output

crash.log.txt

Expected Behavior

terraform plan should have shown a plan to create an aws_vpc resource.

Actual Behavior

💣🔥
panic: runtime error: index out of range

Steps to Reproduce

  1. unpack attached zip
  2. run terraform get
  3. run terraform plan

If cidr_block is changed to "${module.subnets.vpcs["dev_aws_gen_us-east-1"]}" the apply works fine.

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

@jbardin
Copy link
Member

jbardin commented Oct 7, 2016

Hi @blalor,

Thanks for the report and reproduction. I don't think this has anything to do with modules, it appears to be the format inside the map index that is throwing off the interpolator.

This reduced config crashes with apply

variable map {
    default = {
        a = "b"
    }
}

output "formatted_index" {
    value = "${var.map[format("%s", "a")]}"
}

@ghost
Copy link

ghost commented Apr 21, 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 21, 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

2 participants