-
-
Notifications
You must be signed in to change notification settings - Fork 674
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
feat: Add target group attachment capabilities #191
feat: Add target group attachment capabilities #191
Conversation
Why is it necessary? (Bug fix, feature, improvements?) - Allow attaching EC2 instance(s) and Lambda functions to the target groups created by this module so all resources can be managed in one location How does the change address the issue? - Allows for the creation of a "targets" index inside the target_groups variable, where the parameters of the attachment can be defined. - The same arguments that are used for the target_group_attachment resource, are the same arguments that should/can be defined. Any additional arguments are created during the "product mapping", but are not used in the resource, but allows for easy upgrading in the future if more arguments are added (only have to update on the resource function) https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group_attachment#argument-reference What side effects does this change have? - This should be backwards compatible, if no "targets" are defined on the target_group variable, no attachments are created. Include a link to the ticket, if any. - N/A
@bryantbiggs - was curious how do you test your change for e5f2627 ? I don't even know if that is the problem that I'm facing. I just saw a previous PR that didn't look like it was failing (like mine is) 8 days ago, your fix 4 days ago, and my PR 2 days ago and its failing - so I started looking if that was causing it. I'm trying to debug why my pre-commit build is failing for the Max TF pre-commit (0.14.9). Everything locally is passing for me after checking w/ a couple TF versions.
I tried downloading act to debug some more, but I'm running into this yaml: unmarshal error now. So I was just curious how you test things?
It's just complaining that it can't find terraform-docs
|
figured it out
The grep on the latest version doesn't allow for patches and is hardcoded to |
Why is it necessary? (Bug fix, feature, improvements?) - the latest release will not always be tied to the v0.12.0 tag. Allow patches to the release How does the change address the issue? - use a regex to search for patches What side effects does this change have? - As soon as the latest release goes above the v0.12 version, this is going to break. A better way to do this will be to fetch all the tags and correlate the highest v0.12 release via the API, but thats going to take a little more work, as there's currently no way to fetch releases associated to a major/minor version that I can see. - https://docs.github.com/en/rest/reference/repos#list-repository-tags - https://docs.github.com/en/rest/reference/repos#get-a-release-by-tag-name Include a link to the ticket, if any. - N/A
oy, this damn terraform docs - my apologies @veilig2000 , let me see what I can do |
lol - I just updated it - it worked fine on the latest ubuntu docker image locally (just getting the tf-docs pulled down), now some other weird error is being generated :/ |
@antonbabenko, this look good to merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing piece of code! Just a few comments and questions.
outputs.tf
Outdated
|
||
output "target_group_attachments" { | ||
description = "ARNs of the target group attachment IDs." | ||
value = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to have this as a map
so that users can identify both target_group (as a key) and a list of attachments (as a value)
examples/complete-alb/main.tf
Outdated
@@ -293,6 +303,14 @@ module "alb" { | |||
name_prefix = "l1-" | |||
target_type = "lambda" | |||
lambda_multi_value_headers_enabled = true | |||
targets = [ | |||
{ | |||
target_id = "arn:aws:lambda:us-east-1:123456789012:function:lambda_function_1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it work if you specify non-existing ARN? If not, we need to update the code to create a real Lambda function and use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ bs
I'll get all these reviewed quickly so we can merge, just been buried with work |
@veilig2000 I will work on this later today. |
Thanks for your contribution, @veilig2000 ! v5.14.0 has been just released. |
this PR introduces a breaking change
because of the updated version constraint IMO, this should have been a major version change |
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. |
Description
Allows for the creation of a "targets" index inside the target_groups variable, where the parameters of the attachment can be defined. The same arguments that are used for the target_group_attachment resource, are the same arguments that should/can be defined. Any additional arguments are created during the "product mapping", but are not used in the resource, but allows for easy upgrading in the future if more arguments are added (only have to update on the resource function)
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group_attachment#argument-reference
Motivation and Context
Allow attaching EC2 instance(s) and Lambda functions to the target groups created by this module so all resources can be managed in one location. Currently, there's no functionality to add any attachments to the target groups this module creates and everything needs to be additionally defined/coded
Breaking Changes
This should be backwards compatible, if no "targets" are defined on the target_group variable, no attachments are created.
How Has This Been Tested?
[x] I have tested and validated these changes using one or more of the provided examples/* projects
This was manually tested in a sandbox AWS environment on actual ALB/EC2 resources. I currently don't work w/ lambda function attached to any type of LB, so I did not test that. But since the function calls are the same on the target_group_attachment resource between an EC2 instance and a Lambda Function and this is just a mapping of parameters to that function, I really don't anticipate any issues.
variable definition can look like this now