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

Remove max target group limit #36095

Merged
merged 2 commits into from
Mar 5, 2024

Conversation

ADeakinELS
Copy link
Contributor

Description

Registering VPC Lattice target groups to a listener rule is limited to a max of 2 by the provider. However, it's perfectly possible to add more than 2 to a rule using AWS CLI.

aws vpc-lattice create-rule \
--action '{"forward":{"targetGroups":[{"targetGroupIdentifier":"tg-xxxx","weight":1},{"targetGroupIdentifier":"tg-yyyy","weight":1},{"targetGroupIdentifier":"tg-zzzz","weight":1}]}}' \
--listener-identifier "arn:aws:vpc-lattice:us-east-1:..." \
--match '{"httpMatch":{"pathMatch":{"caseSensitive":false,"match":{"prefix":"/"}}}}' \
--name "ms-1" \
--priority 10 \
--service-identifier "arn:aws:vpc-lattice:us-east-1:..."

Attempting this with the current provider leads to an error:

│ Error: Too many target_groups blocks
│ 
│   on main.tf line 55, in resource "aws_vpclattice_listener_rule" "lattice_listener_rule":
│   55:       target_groups {
│ 
│ No more than 2 "target_groups" blocks are allowed

Removing this restriction allows more target groups to be added. I'm not sure if there is some max resource quota for the number of target groups that can be registered on a listener rule but I didn't come across any issues adding more than 2. At the very least, the limit should be raised to a number greater than 2 seeing as this is possible using CLI commands.

Relations

References

Output from Acceptance Testing

I can't afford any acceptance testing but i was able to check that 3 target groups were able to be added to a listener rule by removing the max limit:

resource "aws_vpclattice_service" "lattice_service" {
 
  name               = "ms-1-svc"
  auth_type          = "NONE"
  certificate_arn    = "arn:aws:acm:us-east-1:..."
  custom_domain_name = "ms-1.example.com"

}

resource "aws_vpclattice_service_network_service_association" "lattice_service_association" {
   service_identifier         = aws_vpclattice_service.lattice_service.id
   service_network_identifier = "sn-xxx"
}

resource "aws_vpclattice_listener" "lattice_listener" {
  name               = "http-80"
  protocol           = "HTTP"
  service_identifier = aws_vpclattice_service.lattice_service.id
  default_action {
    fixed_response {
      status_code = 404
    }
  }
}

resource "aws_vpclattice_listener_rule" "lattice_listener_rule" {
  name                = "ms-1-http"
  listener_identifier = aws_vpclattice_listener.lattice_listener.listener_id
  service_identifier  = aws_vpclattice_service.lattice_service.id
  priority            = 10
  match {
    http_match {
      path_match {
        case_sensitive = false
        match {
          exact = "/"
        }
      }
    }
  }
  action {
    forward {
      target_groups {
        target_group_identifier = "tg-xxx"
        weight                  = 1
      }
      target_groups {
        target_group_identifier = "tg-yyy"
        weight                  = 1
      }
      target_groups {
        target_group_identifier = "tg-zzz"
        weight                  = 1
      }
    }
  }
}

Apply Terraform:

Terraform will perform the following actions:

  # aws_vpclattice_listener_rule.lattice_listener_rule will be created
  + resource "aws_vpclattice_listener_rule" "lattice_listener_rule" {
      + arn                 = (known after apply)
      + id                  = (known after apply)
      + listener_identifier = "listener-03c30421c2048c3a6"
      + name                = "ms-1-http"
      + priority            = 10
      + rule_id             = (known after apply)
      + service_identifier  = "svc-055e08f58e907dbdd"
      + tags_all            = (known after apply)

      + action {
          + forward {
              + target_groups {
                  + target_group_identifier = "tg-0f2e9b98e62b97d12"
                  + weight                  = 1
                }
              + target_groups {
                  + target_group_identifier = "tg-005c0cdc9c7e27486"
                  + weight                  = 1
                }
              + target_groups {
                  + target_group_identifier = "tg-0ad9ab430a3751d4a"
                  + weight                  = 1
                }
            }
        }

      + match {
          + http_match {
              + path_match {
                  + case_sensitive = false

                  + match {
                      + exact = "/"
                    }
                }
            }
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

aws_vpclattice_listener_rule.lattice_listener_rule: Creating...
aws_vpclattice_listener_rule.lattice_listener_rule: Creation complete after 0s [id=svc-055e08f58e907dbdd/listener-03c30421c2048c3a6/rule-0398c8603d8676e87]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

image

Copy link

github-actions bot commented Mar 5, 2024

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 the size/XS Managed by automation to categorize the size of a PR. label Mar 5, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Mar 5, 2024
@github-actions github-actions bot added the service/vpclattice Issues and PRs that pertain to the vpclattice service. label Mar 5, 2024
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome @ADeakinELS 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTOR guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@ewbankkit ewbankkit added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Mar 5, 2024
Copy link
Contributor

@ewbankkit ewbankkit 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 TESTARGS='-run=TestAccVPCLatticeListenerRule_basic' PKG=vpclattice
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/vpclattice/... -v -count 1 -parallel 20  -run=TestAccVPCLatticeListenerRule_basic -timeout 360m
=== RUN   TestAccVPCLatticeListenerRule_basic
=== PAUSE TestAccVPCLatticeListenerRule_basic
=== CONT  TestAccVPCLatticeListenerRule_basic
--- PASS: TestAccVPCLatticeListenerRule_basic (85.69s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/vpclattice	92.814s

@ewbankkit
Copy link
Contributor

@ADeakinELS Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit c241b3b into hashicorp:main Mar 5, 2024
33 checks passed
@github-actions github-actions bot added this to the v5.40.0 milestone Mar 5, 2024
@ADeakinELS ADeakinELS deleted the b-target-group-max-limit branch March 6, 2024 10:23
Copy link

github-actions bot commented Mar 7, 2024

This functionality has been released in v5.40.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 Apr 7, 2024

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 Apr 7, 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. service/vpclattice Issues and PRs that pertain to the vpclattice 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.

None yet

2 participants