Skip to content

Commit

Permalink
Managed by Terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWoolfenden committed May 21, 2021
1 parent f9a08ef commit e5d5630
Showing 1 changed file with 77 additions and 77 deletions.
154 changes: 77 additions & 77 deletions example/examplea/Makefile
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
# Makefile
ifdef OS
BLAT = $(powershell -noprofile rm .\.terraform\ -force -recurse)
RM = $(powershell -noprofile rm .\.terraform\ -force -recurse)
else
ifeq ($(shell uname), Linux)
RM = rm .terraform/modules/ -fr
BLAT= rm .terraform/ -fr
endif
endif

.PHONY: all

all: init plan build

init:
$(RM)
terraform init -reconfigure -upgrade

plan:
terraform plan --out tfplan.binary -refresh=true

planned: init
terraform plan -out tf.plan
terraform show -json tf.plan > tf.json
checkov -f tf.json

p:
terraform plan -refresh=true

apply: build

build:
terraform apply -auto-approve

convert:
terraform show -json tfplan.binary > tfplan.json

check: init
terraform plan -detailed-exitcode

destroy: init
terraform destroy -force

docs:
terraform-docs md . > README.md

valid:
-terraform fmt -recursive
-checkov -d . --external-checks-dir ../../checkov
-tfsec .
-terrascan scan
docker pull checkmarx/kics:latest
docker run -v $(CURDIR):/path checkmarx/kics:latest scan --path /path

compare:
-checkov -d . --external-checks-dir ../../checkov -o json >../../output/checkov.json
-terrascan scan -o json -x json >../../output/terrascan.json
-tfsec . --out ../../output/tfsec.json -f json -s
docker pull checkmarx/kics:latest
docker run -v $(CURDIR):/path -v $(CURDIR)/../../output:/output checkmarx/kics:latest scan --path "/path" -o "/output/kics.json"

conftest: plan convert
conftest test ./tfplan.json -p ../../policies

opa: plan convert
opa eval --format pretty --data terraform.rego --input tfplan.json "data.terraform.analysis.authz"

target:
@read -p "Enter Module to target:" MODULE;
terraform apply -target $$MODULE

purge:
$(BLAT)

cost:
infracost breakdown --path . --usage-file infracost-usage.yml --sync-usage-file --show-skipped
# Makefile
ifdef OS
BLAT = $(powershell -noprofile rm .\.terraform\ -force -recurse)
RM = $(powershell -noprofile rm .\.terraform\ -force -recurse)
else
ifeq ($(shell uname), Linux)
RM = rm .terraform/modules/ -fr
BLAT= rm .terraform/ -fr
endif
endif

.PHONY: all

all: init plan build

init:
$(RM)
terraform init -reconfigure -upgrade

plan:
terraform plan --out tfplan.binary -refresh=true

planned: init
terraform plan -out tf.plan
terraform show -json tf.plan > tf.json
checkov -f tf.json

p:
terraform plan -refresh=true

apply: build

build:
terraform apply -auto-approve

convert:
terraform show -json tfplan.binary > tfplan.json

check: init
terraform plan -detailed-exitcode

destroy: init
terraform destroy -force

docs:
terraform-docs md . > README.md

valid:
-terraform fmt -recursive
-checkov -d . --external-checks-dir ../../checkov
-tfsec .
-terrascan scan
docker pull checkmarx/kics:latest
docker run -v $(CURDIR):/path checkmarx/kics:latest scan --path /path

compare:
-checkov -d . --external-checks-dir ../../checkov -o json >../../output/checkov.json
-terrascan scan -o json -x json >../../output/terrascan.json
-tfsec . --out ../../output/tfsec.json -f json -s
docker pull checkmarx/kics:latest
docker run -v $(CURDIR):/path -v $(CURDIR)/../../output:/output checkmarx/kics:latest scan --path "/path" -o "/output/kics.json"

conftest: plan convert
conftest test ./tfplan.json -p ../../policies

opa: plan convert
opa eval --format pretty --data terraform.rego --input tfplan.json "data.terraform.analysis.authz"

target:
@read -p "Enter Module to target:" MODULE;
terraform apply -target $$MODULE

purge:
$(BLAT)

cost:
infracost breakdown --path . --usage-file infracost-usage.yml --sync-usage-file --show-skipped

0 comments on commit e5d5630

Please sign in to comment.