Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Sync labels
uses: EndBug/label-sync@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-session-token: ${{ secrets.AWS_SESSION_TOKEN }}
aws-region: ${{ secrets.AWS_REGION || 'us-east-1' }}
aws-region: ${{ secrets.AWS_REGION != '' && secrets.AWS_REGION || 'us-east-1' }}

- name: Configure Azure credentials
if: matrix.cloud == 'azure'
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
sudo mv conftest /usr/local/bin/conftest

- name: Evaluate Kubernetes policy pack
run: conftest test k8s/app -p policies/kubernetes
run: conftest test k8s -p policies/kubernetes

- name: Upload Terraform plan artifact
uses: actions/upload-artifact@v6
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
.terraform.lock.hcl
*.tfplan
*.tfplan.json
tfplan*
tfplan-*
crash.log
crash.*.log
override.tf
Expand Down
45 changes: 40 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ TF_DIR=infra/terraform
POLICY_TF_DIR=policies/terraform
POLICY_K8S_DIR=policies/kubernetes
CLOUD?=aws
ARGOCD_NAMESPACE?=argocd
ARGOCD_APP_NAME?=dissertation-sample-api
ARGOCD_APP_MANIFEST?=argocd/application.yaml
ARGOCD_TEST_APP_NAME?=dissertation-test-api
ARGOCD_TEST_APP_MANIFEST?=argocd/test-application.yaml

.PHONY: help tf-init tf-fmt tf-validate tf-plan tf-apply tf-destroy policy-tf policy-k8s clean all
.PHONY: help tf-init tf-fmt tf-validate tf-plan tf-apply tf-destroy policy-tf policy-k8s k8s-dry-run argocd-apply argocd-status argocd-test argocd-test-app-apply argocd-test-app-status argocd-test-app-sync clean all

help: ## Display this help message
@echo "Available targets:"
Expand Down Expand Up @@ -31,11 +36,41 @@ tf-destroy: ## Destroy Terraform resources (use CLOUD=aws|azure|gcp)
terraform -chdir=$(TF_DIR)/$(CLOUD) destroy

policy-tf: ## Evaluate Terraform policies
opa eval --fail-defined --format pretty --data $(POLICY_TF_DIR) --input $(POLICY_TF_DIR)/sample-tfplan.json "data.terraform.deny"
opa eval --fail-defined --format pretty --data $(POLICY_TF_DIR) --input $(POLICY_TF_DIR)/sample-tfplan.json "data.terraform.deny[_]"

policy-k8s: ## Evaluate Kubernetes policies
conftest test k8s/app -p $(POLICY_K8S_DIR)
conftest test k8s -p $(POLICY_K8S_DIR)

k8s-dry-run: ## Validate Kubernetes manifests with kubectl client-side dry run
kubectl apply --dry-run=client -f k8s

argocd-apply: ## Apply ArgoCD Application manifest
kubectl apply -f $(ARGOCD_APP_MANIFEST)

argocd-status: ## Show ArgoCD Application status
kubectl get application -n $(ARGOCD_NAMESPACE) $(ARGOCD_APP_NAME)

argocd-test: ## Apply app and wait until ArgoCD reports Synced + Healthy
kubectl apply -f $(ARGOCD_APP_MANIFEST)
kubectl wait --for=jsonpath='{.status.sync.status}'=Synced application/$(ARGOCD_APP_NAME) -n $(ARGOCD_NAMESPACE) --timeout=300s
kubectl wait --for=jsonpath='{.status.health.status}'=Healthy application/$(ARGOCD_APP_NAME) -n $(ARGOCD_NAMESPACE) --timeout=300s
kubectl get application -n $(ARGOCD_NAMESPACE) $(ARGOCD_APP_NAME)
kubectl get all -n dissertation
Comment on lines +53 to +58

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argocd-test hard-codes the application namespace (dissertation) for the final kubectl get all, while other values are parameterized (e.g., ARGOCD_NAMESPACE, app name, manifest path). This makes the target brittle if the destination namespace changes. Make the destination namespace configurable (e.g., APP_NAMESPACE?=dissertation) and use it here, similar to how the test app uses dissertation-test.

Copilot uses AI. Check for mistakes.

argocd-test-app-apply: ## Apply dedicated test ArgoCD Application manifest
kubectl apply -f $(ARGOCD_TEST_APP_MANIFEST)

argocd-test-app-status: ## Show dedicated test ArgoCD Application status
kubectl get application -n $(ARGOCD_NAMESPACE) $(ARGOCD_TEST_APP_NAME)

argocd-test-app-sync: ## Apply test app and wait until ArgoCD reports Synced + Healthy
kubectl apply -f $(ARGOCD_TEST_APP_MANIFEST)
kubectl wait --for=jsonpath='{.status.sync.status}'=Synced application/$(ARGOCD_TEST_APP_NAME) -n $(ARGOCD_NAMESPACE) --timeout=300s
kubectl wait --for=jsonpath='{.status.health.status}'=Healthy application/$(ARGOCD_TEST_APP_NAME) -n $(ARGOCD_NAMESPACE) --timeout=300s
kubectl get application -n $(ARGOCD_NAMESPACE) $(ARGOCD_TEST_APP_NAME)
kubectl get all -n dissertation-test

clean: ## Clean generated files
rm -f $(TF_DIR)/*.tfplan $(TF_DIR)/*.tfplan.json $(TF_DIR)/.terraform.lock.hcl
rm -rf $(TF_DIR)/.terraform
rm -f $(TF_DIR)/aws/*.tfplan $(TF_DIR)/aws/tfplan $(TF_DIR)/aws/tfplan*.json $(TF_DIR)/azure/*.tfplan $(TF_DIR)/azure/tfplan $(TF_DIR)/azure/tfplan*.json $(TF_DIR)/gcp/*.tfplan $(TF_DIR)/gcp/tfplan $(TF_DIR)/gcp/tfplan*.json
rm -rf $(TF_DIR)/aws/.terraform $(TF_DIR)/azure/.terraform $(TF_DIR)/gcp/.terraform
rm -f $(TF_DIR)/aws/.terraform.lock.hcl $(TF_DIR)/azure/.terraform.lock.hcl $(TF_DIR)/gcp/.terraform.lock.hcl
Comment on lines +74 to +76

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clean target duplicates provider paths and filenames, which will be easy to break (or forget to update) as more clouds/dirs are added. Prefer a small loop over $(CLOUDS) (e.g., aws azure gcp), or a find-based cleanup scoped to $(TF_DIR) to remove tfplan*, .terraform/, and .terraform.lock.hcl per subdirectory.

Copilot uses AI. Check for mistakes.
Loading
Loading