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

d/lb_listener: get listener from load balancer and listener port #2886

Merged
merged 1 commit into from
Jan 30, 2018

Conversation

loivis
Copy link
Contributor

@loivis loivis commented Jan 6, 2018

Attempt to fix #2885

The code itself works as I wanted but help is needed with acceptance test.

I added a few tests and data sources with arguments of load_balancer_arn and port but got complains. It seems like the new data source was not created. I'm not sure if I missed anything.

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccDataSourceAWSLBListener_basic -timeout 120m
=== RUN   TestAccDataSourceAWSLBListener_basic
--- FAIL: TestAccDataSourceAWSLBListener_basic (298.25s)
	testing.go:503: Step 0 error: After applying this step and refreshing, the plan was not empty:

		DIFF:

		CREATE: data.aws_lb_listener.from_lb_and_port
		  certificate_arn:   "" => "<computed>"
		  default_action.#:  "" => "<computed>"
		  load_balancer_arn: "" => "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/testlistener-basic-caq0p2ni9w7t6/7ff6e128ac7481fb"
		  port:              "" => "80"
		  protocol:          "" => "<computed>"
		  ssl_policy:        "" => "<computed>"

		STATE:

		aws_lb.alb_test:
		  ID = arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/testlistener-basic-caq0p2ni9w7t6/7ff6e128ac7481fb
		  access_logs.# = 0
		  arn = arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/testlistener-basic-caq0p2ni9w7t6/7ff6e128ac7481fb
		  arn_suffix = app/testlistener-basic-caq0p2ni9w7t6/7ff6e128ac7481fb
		  dns_name = internal-testlistener-basic-caq0p2ni9w7t6-158504234.us-west-2.elb.amazonaws.com
		  enable_deletion_protection = false
		  idle_timeout = 30
		  internal = true
		  ip_address_type = ipv4
		  load_balancer_type = application
		  name = testlistener-basic-caq0p2ni9w7t6
		  security_groups.# = 1
		  security_groups.3305298391 = sg-971a3feb
		  subnets.# = 2
		  subnets.13837635 = subnet-d3022a9b
		  subnets.2632197195 = subnet-dda3aabb
		  tags.% = 1
		  tags.TestName = TestAccAWSALB_basic
		  vpc_id = vpc-cca76fb5
		  zone_id = Z1H1FL5HABSF5

		  Dependencies:
		    aws_security_group.alb_test
		    aws_subnet.alb_test.*
		aws_lb_listener.front_end:
		  ID = arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/testlistener-basic-caq0p2ni9w7t6/7ff6e128ac7481fb/9fc3720c0e60225b
		  arn = arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/testlistener-basic-caq0p2ni9w7t6/7ff6e128ac7481fb/9fc3720c0e60225b
		  default_action.# = 1
		  default_action.0.target_group_arn = arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/testtargetgroup-b2pysi8cr0/15b98e136e37e60f
		  default_action.0.type = forward
		  load_balancer_arn = arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/testlistener-basic-caq0p2ni9w7t6/7ff6e128ac7481fb
		  port = 80
		  protocol = HTTP
		  ssl_policy =

		  Dependencies:
		    aws_lb.alb_test
		    aws_lb_target_group.test
		aws_lb_target_group.test:
		  ID = arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/testtargetgroup-b2pysi8cr0/15b98e136e37e60f
		  arn = arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/testtargetgroup-b2pysi8cr0/15b98e136e37e60f
		  arn_suffix = targetgroup/testtargetgroup-b2pysi8cr0/15b98e136e37e60f
		  deregistration_delay = 300
		  health_check.# = 1
		  health_check.0.healthy_threshold = 3
		  health_check.0.interval = 60
		  health_check.0.matcher = 200-299
		  health_check.0.path = /health
		  health_check.0.port = 8081
		  health_check.0.protocol = HTTP
		  health_check.0.timeout = 3
		  health_check.0.unhealthy_threshold = 3
		  name = testtargetgroup-b2pysi8cr0
		  port = 8080
		  protocol = HTTP
		  stickiness.# = 1
		  stickiness.0.cookie_duration = 86400
		  stickiness.0.enabled = false
		  stickiness.0.type = lb_cookie
		  tags.% = 0
		  target_type = instance
		  vpc_id = vpc-cca76fb5

		  Dependencies:
		    aws_vpc.alb_test
		aws_security_group.alb_test:
		  ID = sg-971a3feb
		  description = Used for ALB Testing
		  egress.# = 1
		  egress.482069346.cidr_blocks.# = 1
		  egress.482069346.cidr_blocks.0 = 0.0.0.0/0
		  egress.482069346.description =
		  egress.482069346.from_port = 0
		  egress.482069346.ipv6_cidr_blocks.# = 0
		  egress.482069346.prefix_list_ids.# = 0
		  egress.482069346.protocol = -1
		  egress.482069346.security_groups.# = 0
		  egress.482069346.self = false
		  egress.482069346.to_port = 0
		  ingress.# = 1
		  ingress.482069346.cidr_blocks.# = 1
		  ingress.482069346.cidr_blocks.0 = 0.0.0.0/0
		  ingress.482069346.description =
		  ingress.482069346.from_port = 0
		  ingress.482069346.ipv6_cidr_blocks.# = 0
		  ingress.482069346.protocol = -1
		  ingress.482069346.security_groups.# = 0
		  ingress.482069346.self = false
		  ingress.482069346.to_port = 0
		  name = allow_all_alb_test
		  owner_id = 123456789012
		  revoke_rules_on_delete = false
		  tags.% = 1
		  tags.TestName = TestAccAWSALB_basic
		  vpc_id = vpc-cca76fb5

		  Dependencies:
		    aws_vpc.alb_test
		aws_subnet.alb_test.0:
		  ID = subnet-d3022a9b
		  assign_ipv6_address_on_creation = false
		  availability_zone = us-west-2a
		  cidr_block = 10.0.1.0/24
		  map_public_ip_on_launch = true
		  tags.% = 1
		  tags.TestName = TestAccAWSALB_basic
		  vpc_id = vpc-cca76fb5

		  Dependencies:
		    aws_vpc.alb_test
		    data.aws_availability_zones.available
		aws_subnet.alb_test.1:
		  ID = subnet-dda3aabb
		  assign_ipv6_address_on_creation = false
		  availability_zone = us-west-2b
		  cidr_block = 10.0.2.0/24
		  map_public_ip_on_launch = true
		  tags.% = 1
		  tags.TestName = TestAccAWSALB_basic
		  vpc_id = vpc-cca76fb5

		  Dependencies:
		    aws_vpc.alb_test
		    data.aws_availability_zones.available
		aws_vpc.alb_test:
		  ID = vpc-cca76fb5
		  assign_generated_ipv6_cidr_block = false
		  cidr_block = 10.0.0.0/16
		  default_network_acl_id = acl-1215516b
		  default_route_table_id = rtb-0cc02474
		  default_security_group_id = sg-44e5c038
		  dhcp_options_id = dopt-30a2c254
		  enable_classiclink = false
		  enable_classiclink_dns_support = false
		  enable_dns_hostnames = false
		  enable_dns_support = true
		  instance_tenancy = default
		  main_route_table_id = rtb-0cc02474
		  tags.% = 1
		  tags.TestName = TestAccAWSALB_basic
		data.aws_availability_zones.available:
		  ID = 2018-01-06 19:07:56.409056 +0000 UTC
		  names.# = 3
		  names.0 = us-west-2a
		  names.1 = us-west-2b
		  names.2 = us-west-2c
		data.aws_lb_listener.front_end:
		  ID = arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/testlistener-basic-caq0p2ni9w7t6/7ff6e128ac7481fb/9fc3720c0e60225b
		  arn = arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/testlistener-basic-caq0p2ni9w7t6/7ff6e128ac7481fb/9fc3720c0e60225b
		  default_action.# = 1
		  default_action.0.target_group_arn = arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/testtargetgroup-b2pysi8cr0/15b98e136e37e60f
		  default_action.0.type = forward
		  load_balancer_arn = arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/testlistener-basic-caq0p2ni9w7t6/7ff6e128ac7481fb
		  port = 80
		  protocol = HTTP
		  ssl_policy =

		  Dependencies:
		    aws_lb_listener.front_end
FAIL
exit status 1
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	298.309s
make: *** [testacc] Error 1

@radeksimko radeksimko added bug Addresses a defect in current functionality. enhancement Requests to existing resources that expand the functionality or scope. and removed bug Addresses a defect in current functionality. labels Jan 8, 2018
@bflad bflad added the service/elbv2 Issues and PRs that pertain to the elbv2 service. label Jan 11, 2018
@kl4w
Copy link
Contributor

kl4w commented Jan 12, 2018

@loivis looks like a dependency issue on the listener, if you modify the port value to references rather than explicit values, that should fix your dependency issue. I've attached the patch
data_lb_listener_test.patch.zip

make testacc TEST=./aws TESTARGS='-run=TestAccDataSourceAWSLBListener'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccDataSourceAWSLBListener -timeout 120m
=== RUN   TestAccDataSourceAWSLBListener_basic
--- PASS: TestAccDataSourceAWSLBListener_basic (197.47s)
=== RUN   TestAccDataSourceAWSLBListenerBackwardsCompatibility
--- PASS: TestAccDataSourceAWSLBListenerBackwardsCompatibility (217.06s)
=== RUN   TestAccDataSourceAWSLBListener_https
--- PASS: TestAccDataSourceAWSLBListener_https (205.93s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	620.503s

@loivis
Copy link
Contributor Author

loivis commented Jan 12, 2018

thanks, @kl4w
Applied your patch and pushed the change, although I didn't figure out how implicit reference dependency works differently with explicit dependency.

@loivis loivis changed the title [WIP] d/lb_listener: get listener from load balancer and listener port d/lb_listener: get listener from load balancer and listener port Jan 13, 2018
@loivis
Copy link
Contributor Author

loivis commented Jan 30, 2018

I almost forgot this myself. Anyone could review this PR?

Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay in reviewing this and thanks for the contribution! LGTM

make testacc TEST=./aws TESTARGS='-run=TestAccDataSourceAWSLBListener'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccDataSourceAWSLBListener -timeout 120m
=== RUN   TestAccDataSourceAWSLBListener_basic
--- PASS: TestAccDataSourceAWSLBListener_basic (213.33s)
=== RUN   TestAccDataSourceAWSLBListenerBackwardsCompatibility
--- PASS: TestAccDataSourceAWSLBListenerBackwardsCompatibility (211.89s)
=== RUN   TestAccDataSourceAWSLBListener_https
--- PASS: TestAccDataSourceAWSLBListener_https (224.47s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	649.738s

@bflad bflad added this to the v1.9.0 milestone Jan 30, 2018
@bflad bflad merged commit 10bf438 into hashicorp:master Jan 30, 2018
bflad added a commit that referenced this pull request Jan 30, 2018
@loivis loivis deleted the d-lb-listener branch January 30, 2018 20:12
@bflad
Copy link
Contributor

bflad commented Feb 9, 2018

This has been released in terraform-provider-aws version 1.9.0. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@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 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 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/elbv2 Issues and PRs that pertain to the elbv2 service.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

d/lb_listener: possibility to get listener from load balancer and listener port
4 participants