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

Change min forward target group action rule to one per docs #33727

Merged
merged 3 commits into from
Nov 1, 2023

Conversation

autotune
Copy link
Contributor

@autotune autotune commented Oct 2, 2023

Description

The following would error out because target_group in forward schema was set to a minimum of two. Per the documentation, this should work correctly with a minimum of one.

resource "aws_vpc" "main" {
  cidr_block = "10.0.0.0/16"
}

resource "aws_subnet" "main" {
  vpc_id     = aws_vpc.main.id
  cidr_block = "10.0.1.0/24"


  availability_zone = "us-east-2a"
  tags = {
    Name = "Main"
  }
}

resource "aws_subnet" "secondary" {
  vpc_id     = aws_vpc.main.id
  cidr_block = "10.0.2.0/24"

  availability_zone = "us-east-2b"
  tags = {
    Name = "Main"
  }
}

resource "aws_internet_gateway" "gw" {
  vpc_id = aws_vpc.main.id

  tags = {
    Name = "main"
  }
}

resource "aws_lb" "front_end" {
  name               = "test-lb-tf"
  internal           = false
  load_balancer_type = "application"
  subnets            = [aws_subnet.main.id, aws_subnet.secondary.id]

  enable_deletion_protection = true

  tags = {
    Environment = "production"
  }
}


resource "aws_lb_target_group" "front_end" {
  name     = "tf-example-lb-tg"
  port     = 80
  protocol = "HTTP"
  vpc_id   = aws_vpc.main.id
}


resource "aws_lb_listener" "front_end" {
  load_balancer_arn = aws_lb.front_end.arn
  port              = "80"
  protocol          = "HTTP"

  default_action {
    type             = "forward"
    target_group_arn = aws_lb_target_group.front_end.arn
      forward {
        target_group {
          arn    = aws_lb_target_group.front_end.arn 
          weight = 80
        }
      }
   }
}

resource "aws_lb_listener_rule" "front_end" {
  listener_arn = aws_lb_listener.front_end.arn

  condition {
    path_pattern {
      values = ["/ng/"]
    }
  }

  action {
    type             = "forward"
    target_group_arn = aws_lb_target_group.front_end.arn
      forward {
        target_group {
          arn    = aws_lb_target_group.front_end.arn 
        }
      }
   }
}

Relations

Closes #13636

Output from Acceptance Testing

% make testacc TESTS=TestAccELBV2Listener_basic PKG=elbv2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/elbv2/... -v -count 1 -parallel 20 -run='TestAccELBV2Listener_basic'  -timeout 360m
=== RUN   TestAccELBV2Listener_basic
=== PAUSE TestAccELBV2Listener_basic
=== CONT  TestAccELBV2Listener_basic
--- PASS: TestAccELBV2Listener_basic (208.97s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/elbv2	211.154s

@github-actions
Copy link

github-actions bot commented Oct 2, 2023

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added service/elbv2 Issues and PRs that pertain to the elbv2 service. size/XS Managed by automation to categorize the size of a PR. labels Oct 2, 2023
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Oct 2, 2023
@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Oct 26, 2023
@jar-b jar-b self-assigned this Nov 1, 2023
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Nov 1, 2023
Copy link
Member

@jar-b jar-b left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

% make testacc TESTS=TestAccELBV2ListenerRule_ PKG=elbv2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/elbv2/... -v -count 1 -parallel 20 -run='TestAccELBV2ListenerRule_'  -timeout 360m

--- PASS: TestAccELBV2ListenerRule_conditionAttributesCount (441.72s)
=== CONT  TestAccELBV2ListenerRule_changeListenerRuleARNForcesNew
--- PASS: TestAccELBV2ListenerRule_conditionQueryString (902.20s)
=== CONT  TestAccELBV2ListenerRule_oidc
--- PASS: TestAccELBV2ListenerRule_conditionPathPattern (906.63s)
=== CONT  TestAccELBV2ListenerRule_cognito
--- PASS: TestAccELBV2ListenerRule_fixedResponse (915.86s)
=== CONT  TestAccELBV2ListenerRule_conditionHTTPRequestMethod
--- PASS: TestAccELBV2ListenerRule_conditionMultiple (916.77s)
=== CONT  TestAccELBV2ListenerRule_ConditionHTTPHeader_invalid
--- PASS: TestAccELBV2ListenerRule_conditionSourceIP (918.71s)
=== CONT  TestAccELBV2ListenerRule_updateRulePriority
--- PASS: TestAccELBV2ListenerRule_conditionHostHeader (924.70s)
--- PASS: TestAccELBV2ListenerRule_conditionHTTPHeader (935.31s)
--- PASS: TestAccELBV2ListenerRule_ConditionHTTPHeader_invalid (20.89s)
--- PASS: TestAccELBV2ListenerRule_backwardsCompatibility (1074.18s)
--- PASS: TestAccELBV2ListenerRule_basic (1093.57s)
--- PASS: TestAccELBV2ListenerRule_disappears (1108.64s)
--- PASS: TestAccELBV2ListenerRule_Action_order (1128.40s)
--- PASS: TestAccELBV2ListenerRule_ActionOrder_recreates (1157.47s)
=== NAME  TestAccELBV2ListenerRule_priority
    listener_rule_test.go:540: Step 2/8 error: Check failed: Check 2/2 error: aws_lb_listener_rule.last: Attribute 'priority' expected "4", got "1"
--- PASS: TestAccELBV2ListenerRule_updateFixedResponse (1300.54s)
--- PASS: TestAccELBV2ListenerRule_conditionUpdateMultiple (1315.19s)
--- FAIL: TestAccELBV2ListenerRule_priority (1331.41s)
--- PASS: TestAccELBV2ListenerRule_redirect (1512.45s)
--- PASS: TestAccELBV2ListenerRule_conditionHTTPRequestMethod (623.31s)
--- PASS: TestAccELBV2ListenerRule_conditionUpdateMixed (1560.54s)
--- PASS: TestAccELBV2ListenerRule_changeListenerRuleARNForcesNew (1122.80s)
--- PASS: TestAccELBV2ListenerRule_oidc (722.73s)
--- PASS: TestAccELBV2ListenerRule_tags (1671.71s)
--- PASS: TestAccELBV2ListenerRule_forwardWeighted (1679.47s)
--- PASS: TestAccELBV2ListenerRule_cognito (791.57s)
--- PASS: TestAccELBV2ListenerRule_updateRulePriority (836.99s)
FAIL
FAIL    github.com/hashicorp/terraform-provider-aws/internal/service/elbv2      1759.308s
FAIL
make: *** [testacc] Error 1

Failure is unrelated to this change.

@jar-b
Copy link
Member

jar-b commented Nov 1, 2023

CreateRule documentation confirms a single target group argument is valid.

https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_Action.html

ForwardConfig
... If you specify both ForwardConfig and TargetGroupArn, you can specify only one target group using ForwardConfig and it must be the same target group specified in TargetGroupArn.

https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_ForwardActionConfig.html

TargetGroups.member.N
The target groups. For Network Load Balancers, you can specify a single target group.

@jar-b jar-b merged commit c3a64dc into hashicorp:main Nov 1, 2023
42 of 43 checks passed
@jar-b
Copy link
Member

jar-b commented Nov 1, 2023

Thanks for your contribution, @autotune! 👏

@github-actions github-actions bot added this to the v5.24.0 milestone Nov 1, 2023
@github-actions github-actions bot removed the bug Addresses a defect in current functionality. label Nov 2, 2023
Copy link

github-actions bot commented Nov 2, 2023

This functionality has been released in v5.24.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

github-actions bot commented Dec 3, 2023

I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 3, 2023
@justinretzolk justinretzolk added the bug Addresses a defect in current functionality. label Feb 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. service/elbv2 Issues and PRs that pertain to the elbv2 service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lb_listener_rule target group support in 2.65
3 participants