diff --git a/aws/resource_aws_lb_listener.go b/aws/resource_aws_lb_listener.go index 2678121d48f8..f6e7c5902684 100644 --- a/aws/resource_aws_lb_listener.go +++ b/aws/resource_aws_lb_listener.go @@ -61,6 +61,8 @@ func resourceAwsLbListener() *schema.Resource { elbv2.ProtocolEnumHttps, elbv2.ProtocolEnumTcp, elbv2.ProtocolEnumTls, + elbv2.ProtocolEnumUdp, + elbv2.ProtocolEnumTcpUdp, }, true), }, diff --git a/aws/resource_aws_lb_listener_test.go b/aws/resource_aws_lb_listener_test.go index 8eaf5b698a43..e210cb9f1b77 100644 --- a/aws/resource_aws_lb_listener_test.go +++ b/aws/resource_aws_lb_listener_test.go @@ -43,6 +43,37 @@ func TestAccAWSLBListener_basic(t *testing.T) { }) } +func TestAccAWSLBListener_basicUdp(t *testing.T) { + var conf elbv2.Listener + lbName := fmt.Sprintf("testlistener-basic-%s", acctest.RandStringFromCharSet(13, acctest.CharSetAlphaNum)) + targetGroupName := fmt.Sprintf("testtargetgroup-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "aws_lb_listener.front_end", + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSLBListenerDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSLBListenerConfig_basicUdp(lbName, targetGroupName), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckAWSLBListenerExists("aws_lb_listener.front_end", &conf), + resource.TestCheckResourceAttrSet("aws_lb_listener.front_end", "load_balancer_arn"), + resource.TestCheckResourceAttrSet("aws_lb_listener.front_end", "arn"), + resource.TestCheckResourceAttr("aws_lb_listener.front_end", "protocol", "UDP"), + resource.TestCheckResourceAttr("aws_lb_listener.front_end", "port", "514"), + resource.TestCheckResourceAttr("aws_lb_listener.front_end", "default_action.#", "1"), + resource.TestCheckResourceAttr("aws_lb_listener.front_end", "default_action.0.order", "1"), + resource.TestCheckResourceAttr("aws_lb_listener.front_end", "default_action.0.type", "forward"), + resource.TestCheckResourceAttrSet("aws_lb_listener.front_end", "default_action.0.target_group_arn"), + resource.TestCheckResourceAttr("aws_lb_listener.front_end", "default_action.0.redirect.#", "0"), + resource.TestCheckResourceAttr("aws_lb_listener.front_end", "default_action.0.fixed_response.#", "0"), + ), + }, + }, + }) +} + func TestAccAWSLBListener_BackwardsCompatibility(t *testing.T) { var conf elbv2.Listener lbName := fmt.Sprintf("testlistener-basic-%s", acctest.RandStringFromCharSet(13, acctest.CharSetAlphaNum)) @@ -506,6 +537,82 @@ resource "aws_security_group" "alb_test" { `, lbName, targetGroupName) } +func testAccAWSLBListenerConfig_basicUdp(lbName, targetGroupName string) string { + return fmt.Sprintf(` +resource "aws_lb_listener" "front_end" { + load_balancer_arn = "${aws_lb.alb_test.id}" + protocol = "UDP" + port = "514" + + default_action { + target_group_arn = "${aws_lb_target_group.test.id}" + type = "forward" + } +} + +resource "aws_lb" "alb_test" { + name = "%s" + internal = false + load_balancer_type = "network" + subnets = ["${aws_subnet.alb_test.*.id[0]}", "${aws_subnet.alb_test.*.id[1]}"] + + idle_timeout = 30 + enable_deletion_protection = false + + tags = { + Name = "TestAccAWSALB_basic" + } +} + +resource "aws_lb_target_group" "test" { + name = "%s" + port = 514 + protocol = "UDP" + vpc_id = "${aws_vpc.alb_test.id}" + + health_check { + port = 514 + protocol = "TCP" + } +} + +variable "subnets" { + default = ["10.0.1.0/24", "10.0.2.0/24"] + type = "list" +} + +data "aws_availability_zones" "available" {} + +resource "aws_vpc" "alb_test" { + cidr_block = "10.0.0.0/16" + + tags = { + Name = "terraform-testacc-lb-listener-basic" + } +} + +resource "aws_internet_gateway" "gw" { + vpc_id = "${aws_vpc.alb_test.id}" + + tags = { + Name = "TestAccAWSALB_basic" + } +} + +resource "aws_subnet" "alb_test" { + count = 2 + vpc_id = "${aws_vpc.alb_test.id}" + cidr_block = "${element(var.subnets, count.index)}" + map_public_ip_on_launch = true + availability_zone = "${element(data.aws_availability_zones.available.names, count.index)}" + + tags = { + Name = "tf-acc-lb-listener-basic-${count.index}" + } +} +`, lbName, targetGroupName) +} + func testAccAWSLBListenerConfigBackwardsCompatibility(lbName, targetGroupName string) string { return fmt.Sprintf(` resource "aws_alb_listener" "front_end" { @@ -521,7 +628,7 @@ resource "aws_alb_listener" "front_end" { resource "aws_alb" "alb_test" { name = "%s" - internal = true + internal = false security_groups = ["${aws_security_group.alb_test.id}"] subnets = ["${aws_subnet.alb_test.*.id[0]}", "${aws_subnet.alb_test.*.id[1]}"] diff --git a/aws/resource_aws_lb_target_group.go b/aws/resource_aws_lb_target_group.go index 3f5fba9fb51e..efc321d49699 100644 --- a/aws/resource_aws_lb_target_group.go +++ b/aws/resource_aws_lb_target_group.go @@ -71,6 +71,8 @@ func resourceAwsLbTargetGroup() *schema.Resource { elbv2.ProtocolEnumHttps, elbv2.ProtocolEnumTcp, elbv2.ProtocolEnumTls, + elbv2.ProtocolEnumUdp, + elbv2.ProtocolEnumTcpUdp, }, true), }, diff --git a/aws/resource_aws_lb_target_group_test.go b/aws/resource_aws_lb_target_group_test.go index 285569929802..441f61856a5d 100644 --- a/aws/resource_aws_lb_target_group_test.go +++ b/aws/resource_aws_lb_target_group_test.go @@ -134,6 +134,36 @@ func TestAccAWSLBTargetGroup_basic(t *testing.T) { }) } +func TestAccAWSLBTargetGroup_basicUdp(t *testing.T) { + var conf elbv2.TargetGroup + targetGroupName := fmt.Sprintf("test-target-group-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "aws_lb_target_group.test", + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSLBTargetGroupDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSLBTargetGroupConfig_basicUdp(targetGroupName), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckAWSLBTargetGroupExists("aws_lb_target_group.test", &conf), + resource.TestCheckResourceAttrSet("aws_lb_target_group.test", "arn"), + resource.TestCheckResourceAttr("aws_lb_target_group.test", "name", targetGroupName), + resource.TestCheckResourceAttr("aws_lb_target_group.test", "port", "514"), + resource.TestCheckResourceAttr("aws_lb_target_group.test", "protocol", "UDP"), + resource.TestCheckResourceAttrSet("aws_lb_target_group.test", "vpc_id"), + resource.TestCheckResourceAttr("aws_lb_target_group.test", "health_check.#", "1"), + resource.TestCheckResourceAttr("aws_lb_target_group.test", "health_check.0.port", "514"), + resource.TestCheckResourceAttr("aws_lb_target_group.test", "health_check.0.protocol", "TCP"), + resource.TestCheckResourceAttr("aws_lb_target_group.test", "tags.%", "1"), + resource.TestCheckResourceAttr("aws_lb_target_group.test", "tags.TestName", "TestAccAWSLBTargetGroup_basic"), + ), + }, + }, + }) +} + func TestAccAWSLBTargetGroup_withoutHealthcheck(t *testing.T) { var conf elbv2.TargetGroup targetGroupName := fmt.Sprintf("test-target-group-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) @@ -1148,6 +1178,32 @@ resource "aws_vpc" "test" { }`, targetGroupName) } +func testAccAWSLBTargetGroupConfig_basicUdp(targetGroupName string) string { + return fmt.Sprintf(`resource "aws_lb_target_group" "test" { + name = "%s" + port = 514 + protocol = "UDP" + vpc_id = "${aws_vpc.test.id}" + + health_check { + protocol = "TCP" + port = 514 + } + + tags = { + TestName = "TestAccAWSLBTargetGroup_basic" + } +} + +resource "aws_vpc" "test" { + cidr_block = "10.0.0.0/16" + + tags = { + TestName = "terraform-testacc-lb-target-group-basic" + } +}`, targetGroupName) +} + func testAccAWSLBTargetGroupConfig_withoutHealthcheck(targetGroupName string) string { return fmt.Sprintf(`resource "aws_lb_target_group" "test" { name = "%s" diff --git a/website/docs/r/lb_listener.html.markdown b/website/docs/r/lb_listener.html.markdown index 60bf9ab93636..a7c04c9995a9 100644 --- a/website/docs/r/lb_listener.html.markdown +++ b/website/docs/r/lb_listener.html.markdown @@ -175,7 +175,7 @@ The following arguments are supported: * `load_balancer_arn` - (Required, Forces New Resource) The ARN of the load balancer. * `port` - (Required) The port on which the load balancer is listening. -* `protocol` - (Optional) The protocol for connections from clients to the load balancer. Valid values are `TCP`, `TLS`, `HTTP` and `HTTPS`. Defaults to `HTTP`. +* `protocol` - (Optional) The protocol for connections from clients to the load balancer. Valid values are `TCP`, `TLS`, `UDP`, `TCP_UDP`, `HTTP` and `HTTPS`. Defaults to `HTTP`. * `ssl_policy` - (Optional) The name of the SSL Policy for the listener. Required if `protocol` is `HTTPS` or `TLS`. * `certificate_arn` - (Optional) The ARN of the default SSL server certificate. Exactly one certificate is required if the protocol is HTTPS. For adding additional SSL certificates, see the [`aws_lb_listener_certificate` resource](/docs/providers/aws/r/lb_listener_certificate.html). * `default_action` - (Required) An Action block. Action blocks are documented below. diff --git a/website/docs/r/lb_target_group.html.markdown b/website/docs/r/lb_target_group.html.markdown index 4afc84817173..bfcfb85b4645 100644 --- a/website/docs/r/lb_target_group.html.markdown +++ b/website/docs/r/lb_target_group.html.markdown @@ -62,7 +62,7 @@ The following arguments are supported: * `name_prefix` - (Optional, Forces new resource) Creates a unique name beginning with the specified prefix. Conflicts with `name`. Cannot be longer than 6 characters. * `port` - (Optional, Forces new resource) The port on which targets receive traffic, unless overridden when registering a specific target. Required when `target_type` is `instance` or `ip`. Does not apply when `target_type` is `lambda`. -* `protocol` - (Optional, Forces new resource) The protocol to use for routing traffic to the targets. Should be one of "TCP", "TLS", "HTTP" or "HTTPS". Required when `target_type` is `instance` or `ip`. Does not apply when `target_type` is `lambda`. +* `protocol` - (Optional, Forces new resource) The protocol to use for routing traffic to the targets. Should be one of "TCP", "TLS", "UDP", "TCP_UDP", "HTTP" or "HTTPS". Required when `target_type` is `instance` or `ip`. Does not apply when `target_type` is `lambda`. * `vpc_id` - (Optional, Forces new resource) The identifier of the VPC in which to create the target group. Required when `target_type` is `instance` or `ip`. Does not apply when `target_type` is `lambda`. * `deregistration_delay` - (Optional) The amount time for Elastic Load Balancing to wait before changing the state of a deregistering target from draining to unused. The range is 0-3600 seconds. The default value is 300 seconds. * `slow_start` - (Optional) The amount time for targets to warm up before the load balancer sends them a full share of requests. The range is 30-900 seconds or 0 to disable. The default value is 0 seconds.