You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the source for the
opa-wasm
Python module which is an SDK for using WebAssembly (wasm) compiled
Open Policy Agent Rego policies using wasmer-python.
Getting Started
Install the module
You may choose to use either the cranelift or llvm compiler package as follows:
pip install opa-wasm[cranelift]
or
pip install opa-wasm[llvm]
If you are using zsh, consider adding double-quote around the package name such as "opa-wasm[cranelift]" or "opa-wasm[llvm]" .
For builds that target AWS Lambda as an execution environment, it is recommended to use cranelift. This avoids
the need to bundle additional binary dependencies as part of the lambda package.
There are only a couple of steps required to start evaluating the policy.
# Import the modulefromopa_wasmimportOPAPolicy# Load a policy by specifying its file pathpolicy=OPAPolicy('./policy.wasm')
# Optional: Set policy datapolicy.set_data({"company_name": "ACME"})
# Evaluate the policyinput= {"user": "alice"}
result=policy.evaluate(input)
Which compiles the example.rego policy file with the result set to
data.example.allow. The result will be an OPA bundle with the policy.wasm
binary included.