An open API service indexing awesome lists of open source software.

https://github.com/btp-automation-scenarios/btp-terraform-opa

Sample for using Open Policy Agent with Terraform and SAP BTP
https://github.com/btp-automation-scenarios/btp-terraform-opa

btp gh-actions opa sap terraform

Last synced: 7 months ago
JSON representation

Sample for using Open Policy Agent with Terraform and SAP BTP

Awesome Lists containing this project

README

          

# BTP Terraform and Open Policy Agent (OPA) Integration

Sample repository for showcasing Open Policy Integration with Terraform.

## Steps to run the code

```bash
cd infra
terraform init
terraform plan --out tfplan.binary
terraform show -json tfplan.binary > tfplan.json
```

## Steps to run the OPA policy

In the root folder execute the following command to evaluate the result of the policy:

```bash
opa exec --decision terraform/analysis/autoexec --bundle policy/ ./infra/tfplan.json
```

To get more details about the OPA policy scoring:

```bash
opa exec --decision terraform/analysis/score --bundle policy/ ./infra/tfplan.json
```

To fetch the result from the JSON you can pipe it to `jq`:

```bash
opa exec --decision terraform/analysis/autoexec --bundle policy/ ./infra/tfplan.json | jq '.result[].result'
opa exec --decision terraform/analysis/score --bundle policy/ ./infra/tfplan.json | jq '.result[].result' regoresult.json
```