What is the suggested way to read json strings from a file in a sentinel policy file?
Also, do json.unmarshal( ) support nested json objects? I got an error; wasn’t sure if there is an issue with the code or there is a limitation w.r.t nested elements
How static is the JSON data that you would like to read? Will it change for each policy evaluation or is it a set-and-forget string value? I can list a couple of different options that are available but before I do, can you confirm if you are writing a policy for Terraform, Vault, Consul, or Nomad?
Looking to parse the plan output to identify policy violations, i.e., terraform show -json plan.out
So, the json won’t be static and will/might change for each policy invocation.
Thanks for confirming. Currently, there’s no elegant way of doing so. Assuming that you want to run this on the command line, you could try the following:
Not sure the issue with plan json. I guess I can use a Python helper to construct the sentinel.hcl by adding in a global block with plan.json as the value. But I guess then I might as well do the whole policy evaluation in Python