-
Notifications
You must be signed in to change notification settings - Fork 152
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
Module based aws_alb resource not recognized #249
Comments
Hi @eerkunt, Hope you are doing well. Any ideas on this one? |
Having a look on this right now. |
This is a weird problem, still couldn't fix this. I am taking a day off from work tomorrow and will focus on terraform-compliance. Hoping to fix it tomorrow release(s) |
Hi @anthonycolon25, Looks like I was quite confused on this one :) The sentence on Instead of ; Given I have aws_alb resource defined if you change this to ; Given I have aws_alb defined or Given I have aws_alb resource configured It should work :) |
So sorry for that. I should have noticed that as well. I changed the two scenarios above to
It now seems to find the aws_alb resource. It is correctly passing the first test but failing on the second. I do have a "waf_custom" property set to a value of "". If I set a non-empty value for "waf_custom" then the test passes. I would think the following test would pass with an empty string, right?
Does that just check for the tag existence or both existence and non-empty value? In my use-case, waf_custom would only have a value if waf_policy is set to "custom". Otherwise it would be just an empty string but the waf_custom tag is required for aws_alb. I am using terraform-compliance version 1.1.15 |
It won't check a non-empty value. It will check if that Sounds like Couldn't exactly understood the details of your use case, but sounds like you need filtering with ; When its waf_custom is <something> and then execute additional operations. |
I'll give that a try. Just to clarify the use case a bit more.
I hope this helps clarify. |
I looked at the plan.out.json and I see that "waf_custom" key does exist in the tags with an empty value. I also looked into your recommendation above but that seems to only check the value when its non-empty. It doesn't really help just check for key existence. |
Hi @anthonycolon25 , I think you can utilise For e.g. ; Scenario: Precondition check for waf_policy value
Given I have aws_alb defined
When it has tags
Then it must contain tags
And it must contain waf_policy
When its waf_policy is custom
@precondition(test.feature: Precondition check for waf_policy value)
Scenario: Ensure waf_custom is set to name/ID of the waf policy
Given I have aws_alb defined
When it has tags
Then it must contain tags
And it must contain waf_custom
And its value must match the "ABC" regex which the execution will look like ; Scenario: Precondition check for waf_policy value
Given I have aws_alb defined
When it has tags
Then it must contain tags
And it must contain waf_policy
When its waf_policy is internal
@precondition(test.feature: Precondition check for waf_policy value)
Scenario: Ensure waf_custom is set to name/ID of the waf policy
Given I have aws_alb defined
When it has tags
Then it must contain tags
And it must contain waf_policy
When its waf_policy is internal
Given I have aws_alb defined
When it has tags
Then it must contain tags
And it must contain waf_custom
Failure: waf_custom property in module.alb.aws_alb.alb resource does not match with ABC case insensitive regex. It is set to .
Failure: waf_custom property in module.alb.aws_alb.alb resource does not match with ABC case insensitive regex. It is set to .
Failure: waf_custom property in module.alb.aws_alb.alb resource does not match with ABC case insensitive regex. It is set to .
And its value must match the "ABC" regex Let me know if this will fix your issue. |
In addition to @eerkunt's response, could you have a try with 1.2.5? Your original features should pass now. |
I have tested with 1.2.5 and the original feature now passes. Thank you, @Kudbettin and @eerkunt . |
Thanks @anthonycolon25 for re-testing it 🎉 Closing the issue as its solved. Please do not hesitate to create a new one if the problem (or a similar one) occurs. |
This issue's conversation is now locked. If you want to continue this discussion please open a new issue. |
Description :
I have a TF template which calls an ALB module. My tests should check that tags required for aws_alb resources (in addition to other required tags). These steps are being skipped stating it did not find any aws_alb resources.
To Reproduce
Output:
I am attaching my plan.json
plan.out.json.txt
The text was updated successfully, but these errors were encountered: