{"id":13677138,"url":"https://github.com/Blokje5/validating-terraform-with-conftest","last_synced_at":"2025-04-29T10:32:04.275Z","repository":{"id":115266449,"uuid":"198064848","full_name":"Blokje5/validating-terraform-with-conftest","owner":"Blokje5","description":"Example Code along with the blog post at https://blokje5/dev","archived":false,"fork":false,"pushed_at":"2019-07-21T14:14:14.000Z","size":2,"stargazers_count":23,"open_issues_count":0,"forks_count":12,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-14T17:51:10.689Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Blokje5.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-07-21T14:13:49.000Z","updated_at":"2023-08-20T11:24:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"30422e15-1fbb-4b3c-9b4a-5848f7b3b89b","html_url":"https://github.com/Blokje5/validating-terraform-with-conftest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Blokje5%2Fvalidating-terraform-with-conftest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Blokje5%2Fvalidating-terraform-with-conftest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Blokje5%2Fvalidating-terraform-with-conftest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Blokje5%2Fvalidating-terraform-with-conftest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Blokje5","download_url":"https://codeload.github.com/Blokje5/validating-terraform-with-conftest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251483996,"owners_count":21596637,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T13:00:37.446Z","updated_at":"2025-04-29T10:31:59.248Z","avatar_url":"https://github.com/Blokje5.png","language":"HCL","funding_links":[],"categories":["HCL"],"sub_categories":[],"readme":"# Validating Terraform plans using the Open Policy Agent\n\nThis repository contains the code for the blog post here: https://blokje5.dev/posts/validating-terraform-plans/\n\n## Requirements\n\nThe following tools are needed in order to execute the code:\n\n- [Terraform](https://www.terraform.io/)\n- [Conftest](https://github.com/instrumenta/conftest)\n\nAdditionally, if you want to execute the [unit tests](https://www.openpolicyagent.org/docs/latest/how-do-i-test-policies/) for the policies, the [OPA binary](https://github.com/open-policy-agent/opa/releases) needs to be installed.\n\n## Generating a terraform plan\n\nexecute the following commands (note that valid AWS credentials need to be available, as we are deploying AWS resources).\n \n```bash\nterraform init\nterraform plan -out=tfplan\nterraform show -json ./tfplan \u003e tfplan.json\n```\n\n## Evaluating the plan\n\n```bash\nconftest test ./tfplan.json\n```\n\nWhich returns the following output:\n\n```bash\n./tfplan.json\n   Invalid tags (missing minimum required tags) for the following resources: [\"aws_s3_bucket.helm_repo\"]\n   Invalid tags (not pascal case) for the following resources: [\"aws_s3_bucket.terraform_state_bucket\"]\n```\n\n## Unit testing Rego policies\n\n```bash\ncd policy\nopa test -v *.rego\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBlokje5%2Fvalidating-terraform-with-conftest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBlokje5%2Fvalidating-terraform-with-conftest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBlokje5%2Fvalidating-terraform-with-conftest/lists"}