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

aws_alb_listener undefined local variable or method `host' #5661

Closed
andrewhertog opened this issue Aug 23, 2018 · 3 comments
Closed

aws_alb_listener undefined local variable or method `host' #5661

andrewhertog opened this issue Aug 23, 2018 · 3 comments

Comments

@andrewhertog
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.11.8
+ provider.aws v1.33.0

Affected Resource(s)

  • aws_alb_listener

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp
resource "aws_alb_listener" "default_listener" {
  default_action {
    type = "redirect"
    redirect {
      port        = "443"
      protocol    = "HTTPS"
      status_code = "HTTP_301"
    }
  }

  load_balancer_arn = "${aws_alb.current_alb.arn}"
  port              = 80
  protocol          = "HTTP"
}

Debug Output

https://gist.github.com/andrewhertog/077efa8e3891b95a03b2697fa7ae815c

Expected Behavior

It should change the listener from the default target listener type to a redirect listener type

Actual Behavior

~ module.alb.aws_alb_listener.default_listener
    default_action.0.redirect.#:               "0" => "1"
/usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/terraform_landscape-0.1.18/lib/terraform_landscape/terraform_plan.rb:167:in `eval': undefined local variable or method `host' for #<TerraformLandscape::TerraformPlan:0x00007fc0a29a7cb0> (NameError)
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/terraform_landscape-0.1.18/lib/terraform_landscape/terraform_plan.rb:167:in `eval'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/terraform_landscape-0.1.18/lib/terraform_landscape/terraform_plan.rb:167:in `display_modified_attribute'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/terraform_landscape-0.1.18/lib/terraform_landscape/terraform_plan.rb:141:in `display_attribute'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/terraform_landscape-0.1.18/lib/terraform_landscape/terraform_plan.rb:89:in `block in display_resource'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/terraform_landscape-0.1.18/lib/terraform_landscape/terraform_plan.rb:86:in `each'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/terraform_landscape-0.1.18/lib/terraform_landscape/terraform_plan.rb:86:in `display_resource'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/terraform_landscape-0.1.18/lib/terraform_landscape/terraform_plan.rb:60:in `block in display'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/terraform_landscape-0.1.18/lib/terraform_landscape/terraform_plan.rb:59:in `each'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/terraform_landscape-0.1.18/lib/terraform_landscape/terraform_plan.rb:59:in `display'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/terraform_landscape-0.1.18/lib/terraform_landscape/printer.rb:76:in `process_string'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/terraform_landscape-0.1.18/lib/terraform_landscape/printer.rb:35:in `process_stream'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/terraform_landscape-0.1.18/lib/terraform_landscape/cli.rb:48:in `print'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/terraform_landscape-0.1.18/lib/terraform_landscape/cli.rb:34:in `block (2 levels) in define_commands'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/commander-4.4.5/lib/commander/command.rb:182:in `call'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/commander-4.4.5/lib/commander/command.rb:153:in `run'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/commander-4.4.5/lib/commander/runner.rb:446:in `run_active_command'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/commander-4.4.5/lib/commander/runner.rb:68:in `run!'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/commander-4.4.5/lib/commander/delegates.rb:15:in `run!'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/terraform_landscape-0.1.18/lib/terraform_landscape/cli.rb:25:in `run'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/gems/terraform_landscape-0.1.18/bin/landscape:7:in `<top (required)>'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/bin/landscape:22:in `load'
        from /usr/local/Cellar/terraform_landscape/0.1.18/libexec/bin/landscape:22:in `<main>'

Steps to Reproduce

  1. Create an ALB with a listener default action of "forward":
resource "aws_alb_listener" "default_listener" {
  "default_action" {
    target_group_arn = "${aws_alb_target_group.default_target_group.arn}"
    type             = "forward"
  }

  load_balancer_arn = "${aws_alb.current_alb.arn}"
  port              = 80
  protocol          = "HTTP”
}
  1. terraform apply
  2. Modify your config so that it redirects
resource "aws_alb_listener" "default_listener" {
  default_action {
    type = "redirect"
    redirect {
      port        = "443"
      protocol    = "HTTPS"
      status_code = "HTTP_301"
    }
  }

  load_balancer_arn = "${aws_alb.current_alb.arn}"
  port              = 80
  protocol          = "HTTP”
}
  1. terraform plan should show the error

References

@bflad
Copy link
Contributor

bflad commented Aug 23, 2018

The error provided above seems to be coming from https://github.com/coinbase/terraform-landscape -- what is the error provided with terraform plan?

@andrewhertog
Copy link
Author

Removing landscape seems to have fixed the issue. Thanks

@ghost
Copy link

ghost commented Apr 3, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants