-
Notifications
You must be signed in to change notification settings - Fork 150
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
metadata attributes do not appear to be working? #475
Comments
Hey @dwilliams782 It looks like you are trying to enforce module use, similar to how I am. Take a look at my issue and feature request here: 456 @eerkunt This is another usecase for my feature request. Just an fyi Unfortunately, metadata filtering doesn't allow us to test for the presence or absence of a a key/value pair within terraform-compliance. If you actually dig into the plan json you will see that module_address only exists within resources that are created with a module. Also metadata is not yet regex searchable, so the when statement you have: Also we can't yet regex ⬆️ Actually this is the symptom of the same thing, no regex for Here is what I do for aws, leveraging the bdd reference below. Since resources that are not built using a module will not have the
Since resources that are not built using a module will not have the |
Hi @mdesmarest, thanks for responding. Yes, your feature request is exactly the sort of thing we are trying to workaround here. Understood about Using your example:
It still fails incorrectly (only one resource should fail):
I wonder if the plan is different between AWS and GCP providers? |
@dwilliams782 can you show me your stash, redact or replace info with junk. and or take a look at the json. Im not a google cloud guy, but HCL is HCL as far as terraform is concerned. most times I work through the stash, sometimes the logic here can get counter intuitive as some of the features I have written can represent pivots. Essentially since you are not able to enforce against a particular module yet, what I do is set up a feature that tests against what you would expect from a resource that is created using the module you desire and then flag on outliers. Missing parameters ETC. I set up a single feature with several different scenarios within it, so that the only way to pass the feature is to pass all the checks for each of the args that the module creates. Hope that makes sense. Its less testing for the module use and more, |
What you're saying makes total sense, but any attempt at referencing any of the |
Not sure why you are having an issue, it should be the same for both of us. What version of terraform-compliance are you running? Also, can you reference the Ultimately the fact that it references Its a game of The style to which you write your features depends on what you hope to accomplish. I cluster scenarios that fail to indicate a certain thing under one feature and a set of specific results. You can break these up into separate features as well. Hope this helps. Def have the big brains here take a peek
Aside from the benefits of using a SPECIFIC module, for versioning purposes. There aren't many ways to VERIFY the module you wish to use until hopefully @eerkunt can incorporate the The best bet is to take an ideal resource that is correct, create either a series of features, or several scenarios under a top level feature that will fail to guide the user to the appropriate module to use. |
Description :
I'm trying to detect whether a gcs bucket is created by a module. I have this very simple use case:
I get the following output:
Using the debug steps, I can see the three buckets (two from a module, one not) in the stash, each with address (I've also tried isolating on the ones that contain
module_address
with no luck). This check should fail only the one resource that isn't from a module.Am I doing something wrong, or is it broken? I've not managed to use any attributes outside of values.
The text was updated successfully, but these errors were encountered: