Skip to content

Instantly share code, notes, and snippets.

@alberts-s
Last active January 31, 2018 16:26
Show Gist options
  • Save alberts-s/3c8ea0acfa7a3ece6263c5908e8b4812 to your computer and use it in GitHub Desktop.
Save alberts-s/3c8ea0acfa7a3ece6263c5908e8b4812 to your computer and use it in GitHub Desktop.
aws_lb_listener_rule
aws_lb_listener_rule.this[1]: Creating...
action.#: "" => "1"
action.0.target_group_arn: "" => "arn:aws:elasticloadbalancing:eu-west-1:123:targetgroup/ruletest/e0a6a30150466170"
action.0.type: "" => "forward"
arn: "" => "<computed>"
condition.#: "" => "2"
condition.2263785189.field: "" => "host-header"
condition.2263785189.values.#: "" => "1"
condition.2263785189.values.0: "" => ""
condition.2874205519.field: "" => "path-pattern"
condition.2874205519.values.#: "" => "1"
condition.2874205519.values.0: "" => "/alldomains"
listener_arn: "" => "arn:aws:elasticloadbalancing:eu-west-1:123:listener/app/tf-lb-20180131154942223800000001/43f10abe3d73532e/985381ef8afc3390"
priority: "" => "101"
2018/01/31 17:53:49 [DEBUG] [aws-sdk-go] DEBUG: Request elasticloadbalancing/CreateRule Details:
---[ REQUEST POST-SIGN ]-----------------------------
POST / HTTP/1.1
Host: elasticloadbalancing.eu-west-1.amazonaws.com
User-Agent: aws-sdk-go/1.12.70 (go1.9.2; linux; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.11.2
Action=CreateRule&
Actions.member.1.TargetGroupArn=arn%3Aaws%3Aelasticloadbalancing%3Aeu-west-1%3A123%3Atargetgroup%2Fruletest%2Fe0a6a30150466170&
Actions.member.1.Type=forward&
Conditions.member.1.Field=host-header&
Conditions.member.1.Values.member.1=& <----------- Value is empty
Conditions.member.2.Field=path-pattern&
Conditions.member.2.Values.member.1=%2Falldomains&
ListenerArn=arn%3Aaws%3Aelasticloadbalancing%3Aeu-west-1%3A123%3Alistener%2Fapp%2Ftf-lb-20180131154942223800000001%2F43f10abe3d73532e%2F985381ef8afc3390&
Priority=101&
Version=2015-12-01
-----------------------------------------------------
2018/01/31 17:53:49 [DEBUG] [aws-sdk-go] DEBUG: Response elasticloadbalancing/CreateRule Details:
---[ RESPONSE ]--------------------------------------
HTTP/1.1 400 Bad Request
Connection: close
Content-Length: 296
Content-Type: text/xml
Date: Wed, 31 Jan 2018 15:53:48 GMT
X-Amzn-Requestid: xxxc3
-----------------------------------------------------
2018/01/31 17:53:49 [DEBUG] [aws-sdk-go] <ErrorResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2015-12-01/">
<Error>
<Type>Sender</Type>
<Code>ValidationError</Code>
<Message>A condition value cannot be empty</Message>
</Error>
<RequestId>xxxc3</RequestId>
</ErrorResponse>
2018/01/31 17:53:49 [DEBUG] [aws-sdk-go] DEBUG: Validate Response elasticloadbalancing/CreateRule failed, not retrying, error ValidationError: A condition value cannot be empty
status code: 400, request id: xxx
provider "aws" {
version = "1.8.0"
region = "eu-west-1"
}
variable "name" {
default = "ruletest"
}
variable "input" {
type = "list"
default = [
{path="/static/*", host="example.com", priority=100},
{path="/alldomains", host="", priority=101}
]
}
module "vpc" {
source = "github.com/terraform-aws-modules/terraform-aws-vpc"
name = "${var.name}"
cidr = "10.0.0.0/16"
azs = ["eu-west-1a", "eu-west-1b"]
public_subnets = ["10.0.0.0/24", "10.0.1.0/24"]
enable_nat_gateway = false
enable_vpn_gateway = false
}
resource "aws_lb" "this" {
subnets = ["${module.vpc.public_subnets}"]
}
resource "aws_lb_listener" "this" {
load_balancer_arn = "${aws_lb.this.arn}"
port = "80"
default_action {
target_group_arn = "${aws_lb_target_group.this.arn}"
type = "forward"
}
}
resource "aws_lb_target_group" "this" {
name = "${var.name}"
port = 80
protocol = "HTTP"
vpc_id = "${module.vpc.vpc_id}"
}
resource "aws_lb_listener_rule" "this" {
count = "${length(var.input)}"
listener_arn = "${aws_lb_listener.this.arn}"
priority = "${lookup(var.input[count.index], "priority")}"
action {
type = "forward"
target_group_arn = "${aws_lb_target_group.this.arn}"
}
condition {
field = "path-pattern"
values = ["${lookup(var.input[count.index], "path")}"]
}
condition {
field = "host-header"
values = ["${lookup(var.input[count.index], "host")}"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment