tfenforce
A simple example written in go of how to enforce policies/standards on terraform resources.
Examples
Generate the plan and run tfenforce:
cd examples/no_violation
terraform init
terraform plan -out tfplan
terraform show -json tfplan > tfplan.json
go run ../../main.go -tfplan ./tfplan.json
This will output nothing.
Generate the plan and run tfenforce:
cd examples/iam_violation
terraform init
terraform plan -out tfplan
terraform show -json tfplan > tfplan.json
go run ../../main.go -tfplan ./tfplan.json
This will output a single violation:
cannot declare '*' IAM permission (aws_iam_policy.service-policy-default)
Generate the plan and run tfenforce:
cd examples/vpc_violation
terraform init
terraform plan -out tfplan
terraform show -json tfplan > tfplan.json
go run ../../main.go -tfplan ./tfplan.json
This will output a single violation:
cannot define aws_vpc resources (aws_vpc.test)