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
- Host: GitHub
- URL: https://github.com/btp-automation-scenarios/btp-terraform-opa
- Owner: btp-automation-scenarios
- License: apache-2.0
- Created: 2024-03-25T14:46:37.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-25T15:21:53.000Z (over 1 year ago)
- Last Synced: 2025-01-23T13:08:06.434Z (9 months ago)
- Topics: btp, gh-actions, opa, sap, terraform
- Language: HCL
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
```