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
Add list-remove module #14
Conversation
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.
Handy module!
# b) distinct will discard duplicate items in the order they are found | ||
# => If you slice the new list from the point of the length of the first list in the concat, then you will get the | ||
# second list of concat with all the elements from the first list removed. | ||
# Inspired by https://github.com/hashicorp/terraform/issues/16044#issuecomment-392269246 |
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.
Haha, that's super clever 😁
modules/list-remove/README.md
Outdated
@@ -0,0 +1,27 @@ | |||
# List Remove Module | |||
|
|||
This is a module that can be used to remove items in a given list from another list. |
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.
You might want to mention this is not yet built into Terraform's interpolation functions
terraform.InitAndApply(t, terratestOptions) | ||
|
||
assertOutputEquals(t, "output_list_as_csv", "us-east-1a,us-east-1d,us-east-1e", terratestOptions) | ||
} |
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.
You may want to make the inputs to that example configurable and run through a few more test cases:
- Two empty lists
- One filled list, one empty
- Two identical lists
- Two lists with no overlap
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.
Good idea!
UPDATE 8798f61 :
Will merge and cut release if the build passes. |
Ok build passed. Merging. Thanks for the review! |
This implements a
list-remove
module, which can be used to do list subtraction. In other words, this is a module to be able to remove specific items from a list in terraform.Note: This was inspired from a conversation with a customer in slack.