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_rule seems to conflict with alb host-based and path-based routing used together #13776

Closed
earwin opened this issue Apr 19, 2017 · 4 comments · Fixed by hashicorp/terraform-provider-aws#1161

Comments

@earwin
Copy link

earwin commented Apr 19, 2017

Terraform Version

0.9.3

Affected Resource(s)

  • aws_alb_listener_rule

Terraform Configuration Files

variable "listener_arn" {
    type = "string"
}

variable "base_priority" {
    type = "string"
}

variable "host" {
    type = "string"
}

variable "rules" {
    type = "list"
}


resource "aws_alb_listener_rule" "rule" {
    count = "${length(var.rules)}"

    listener_arn = "${var.listener_arn}"
    priority     = "${count.index+var.base_priority}"

    action {
        type             = "forward"
        target_group_arn = "${lookup(var.rules[count.index], "group_arn")}"
    }

    condition {
        field  = "path-pattern"
        values = [ "${lookup(var.rules[count.index], "path")}" ]
    }

    condition {
        field  = "host-header"
        values = [ "${var.host}" ]
    }
}

Debug Output

https://gist.github.com/earwin/96d38e775735635fcfeb408cd83a1e06

Expected Behavior

I expect apply to finish without errors and modifying anything.

Actual Behavior

I get an error. E.g:

2017/04/19 17:35:58 [ERROR] root.stage-api-joom-it: eval: *terraform.EvalSequence, err: aws_alb_listener_rule.rule.0: diffs didn't match during apply. This is a bug with Terraform and should be reported as a GitHub Issue.

Please include the following information in your report:

    Terraform Version: 0.9.3
    Resource ID: aws_alb_listener_rule.rule.0
    Mismatch reason: diff RequiresNew; old: false, new: true
    Diff One (usually from plan): *terraform.InstanceDiff{mu:sync.Mutex{state:0, sema:0x0}, Attributes:map[string]*terraform.ResourceAttrDiff{"condition.0.values.0":*terraform.ResourceAttrDiff{Old:"stage-api.joom.it", New:"/1.0/events", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "condition.0.field":*terraform.ResourceAttrDiff{Old:"host-header", New:"path-pattern", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "condition.1.field":*terraform.ResourceAttrDiff{Old:"path-pattern", New:"host-header", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "condition.1.values.0":*terraform.ResourceAttrDiff{Old:"/1.0/events", New:"stage-api.joom.it", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}}, Destroy:false, DestroyDeposed:false, DestroyTainted:false, Meta:map[string]interface {}(nil)}
    Diff Two (usually from apply): *terraform.InstanceDiff{mu:sync.Mutex{state:0, sema:0x0}, Attributes:map[string]*terraform.ResourceAttrDiff{"listener_arn":*terraform.ResourceAttrDiff{Old:"", New:"arn:aws:elasticloadbalancing:eu-central-1:503529826617:listener/app/joom-it/54faa9466a55fc7c/aa56543aa23efa35", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Sensitive:false, Type:0x0}, "condition.1.values.0":*terraform.ResourceAttrDiff{Old:"", New:"stage-api.joom.it", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "priority":*terraform.ResourceAttrDiff{Old:"", New:"80", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Sensitive:false, Type:0x0}, "condition.0.field":*terraform.ResourceAttrDiff{Old:"", New:"path-pattern", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "condition.1.values.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "condition.1.field":*terraform.ResourceAttrDiff{Old:"", New:"host-header", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "condition.0.values.0":*terraform.ResourceAttrDiff{Old:"", New:"/1.0/events", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "condition.#":*terraform.ResourceAttrDiff{Old:"", New:"2", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "action.0.type":*terraform.ResourceAttrDiff{Old:"", New:"forward", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "action.0.target_group_arn":*terraform.ResourceAttrDiff{Old:"", New:"arn:aws:elasticloadbalancing:eu-central-1:503529826617:targetgroup/stage-api-event-it/5b4080c21b748382", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "condition.0.values.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "arn":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "action.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}}, Destroy:false, DestroyDeposed:false, DestroyTainted:false, Meta:map[string]interface {}(nil)}

Also, at the end of attached gist.

Steps to Reproduce

When aws_alb_listener_rule is used with two conditions (as above), consequent applies first create the rule, and then flip positions of 'host-header' and 'path-pattern' conditions.
After a few flips I get an error as above.

@earwin
Copy link
Author

earwin commented Apr 20, 2017

A sample of 'host-header'/'path-pattern' flickering:

~ module.api-client-joom-it.aws_alb_listener_rule.rule.3
    condition.0.field:    "host-header" => "path-pattern"
    condition.0.values.0: "api-client.joom.it" => "/*"
    condition.1.field:    "path-pattern" => "host-header"
    condition.1.values.0: "/*" => "api-client.joom.it"

~ module.stage-api-joom-it.aws_alb_listener_rule.rule.0
    condition.0.field:    "host-header" => "path-pattern"
    condition.0.values.0: "stage-api.joom.it" => "/1.0/events"
    condition.1.field:    "path-pattern" => "host-header"
    condition.1.values.0: "/1.0/events" => "stage-api.joom.it"

~ module.stage-api-joom-it.aws_alb_listener_rule.rule.3
    condition.0.field:    "host-header" => "path-pattern"
    condition.0.values.0: "stage-api.joom.it" => "/*"
    condition.1.field:    "path-pattern" => "host-header"
    condition.1.values.0: "/*" => "stage-api.joom.it"

@Reimerei
Copy link

Reimerei commented May 11, 2017

I have the same problem with 0.9.4 as soon as there are two conditions in the aws_alb_listener_rule.
The change in order of the rules is shown after plan. apply crashes with the above error afterwards.

@astawiarski
Copy link

I am seeing the same problem in terraform 0.9.8

Whenever the aws_alb_listener_rule has multiple condition blocks, their order seems to be non-deterministic and causes the whole resource to be updated on plan/apply without any changes to the source file.

@ghost
Copy link

ghost commented Apr 8, 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 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants