Files
hapi/infra/Makefile
T
2026-11-17 14:39:40 -05:00

64 lines
1.5 KiB
Makefile

# Makefile for HAPI Terraform infrastructure
.PHONY: init plan apply destroy output env
# Environment defaults
ENV ?= staging
REGION ?= us-east
# Initialize Terraform
init:
@echo "Initializing Terraform..."
terraform init
# Initialize with backend configuration
init-backend:
@echo "Initializing Terraform with backend..."
terraform init -reconfigure \
-backend-config=bucket=hapi-terraform-state-${ENV} \
-backend-config=key=terraform/${ENV}/terraform.tfstate \
-backend-config=region=${REGION}
# Generate plan
plan:
@echo "Generating Terraform plan for ${ENV}..."
terraform plan -var="environment=${ENV}"
# Apply changes
apply:
@echo "Applying Terraform changes for ${ENV}..."
terraform apply -var="environment=${ENV}"
# Apply with auto-approve
apply-auto:
@echo "Applying Terraform changes for ${ENV} (auto-approve)..."
terraform apply -var="environment=${ENV}" -auto-approve
# Destroy infrastructure
destroy:
@echo "Destroying Terraform infrastructure for ${ENV}..."
terraform destroy -var="environment=${ENV}"
# Show outputs
output:
@echo "Terraform outputs:"
terraform output
# Load environment variables
env:
@echo "Environment variables:"
@echo " ENV=${ENV}"
@echo " REGION=${REGION}"
@echo " LINODE_TOKEN=${LINODE_TOKEN}"
@echo " OBJECT_STORAGE_ACCESS_KEY=${OBJECT_STORAGE_ACCESS_KEY}"
@echo " OBJECT_STORAGE_SECRET_KEY=${OBJECT_STORAGE_SECRET_KEY}"
# Run all checks
check: init plan apply
# Clean up local state
clean:
@echo "Cleaning local Terraform files..."
rm -rf .terraform/
rm -f .terraform.lock.hcl