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

re_match(concat("", ["^.*\\.", resource.name, "\\..*$"]), r.properties.subnet_id); is incorrect and need to match with resource.id as per document which is impossible or need to find some other way for validation #189

Closed
rezoan opened this issue Aug 10, 2021 · 3 comments · Fixed by #188
Assignees
Labels
bug Something isn't working

Comments

@rezoan
Copy link
Contributor

rezoan commented Aug 10, 2021

In file https://github.com/prancer-io/prancer-compliance-test/blob/master/azure/terraform/vnetsubnets.rego re_match(concat("", ["^.*\\.", resource.name, "\\..*$"]), r.properties.subnet_id); is incorrect and need to match with resource.id as per https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet_network_security_group_association

matching with id is impossible during compile time as id will only available from tf output file.

We need to find some other way to match the subnet association with vnet.

@rezoan
Copy link
Contributor Author

rezoan commented Aug 10, 2021

@farchide just a thought. checking subnet_id and network_security_group_id for empty value under azurerm_subnet_network_security_group_association should work here if you agree.

Which means if subnet_id and network_security_group_id does not have empty value (could have real id or tf variable reference) we can determine the azurerm_subnet_network_security_group_association will have a subnet_id and will be associated with nsg with id from network_security_group_id

Please confirm.

@farchide
Copy link
Contributor

We cannot look for any specific pattern, because the user may use the data provider to get the resource id.
@rezoan I agree with your approach, just make sure network security group is assigned to the subnet by checking azurerm_subnet_network_security_group_association resource
we expect subnet, NSG and (resource or data provider) and azurerm_subnet_network_security_group_association to be available in a single tf file

@rezoan
Copy link
Contributor Author

rezoan commented Aug 11, 2021

issue been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants