Files
hapi/infra/Makefile
T
Bobby 494f38c1f3 01a: update Linode Terraform for provider v2
- Update all modules to use Linode provider v2 (linode/linode ~> 2.0)
- Replace deprecated cluster attribute with region in all modules
- Update firewall to use ipv4/ipv6 instead of cidrs (TCP/UDP protocols)
- Update LKE endpoint output to use api_endpoints[0] instead of deprecated hostname
- Add OBJECT_STORAGE_CLUSTER variable for object storage configuration
- Update Makefile with new variables and validate target
- Add storage/outputs.tf for standardized object storage outputs
- Update .env and .env.example with clean format (no inline comments)
- Update all terraform.tfvars.example files for consistency
2026-11-17 22:09:31 -05:00

71 lines
2.1 KiB
Makefile

# Makefile for HAPI Terraform infrastructure
.PHONY: init plan apply destroy output env
# Environment defaults
ENV ?= staging
REGION ?= us-east
OBJECT_STORAGE_CLUSTER ?= us-east-1
# 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=${OBJECT_STORAGE_CLUSTER}
# Generate plan
plan:
@echo "Generating Terraform plan for ${ENV}..."
terraform plan -var="environment=${ENV}" -var="linode_object_storage_cluster=${OBJECT_STORAGE_CLUSTER}"
# Apply changes
apply:
@echo "Applying Terraform changes for ${ENV}..."
terraform apply -var="environment=${ENV}" -var="linode_object_storage_cluster=${OBJECT_STORAGE_CLUSTER}"
# Apply with auto-approve
apply-auto:
@echo "Applying Terraform changes for ${ENV} (auto-approve)..."
terraform apply -var="environment=${ENV}" -var="linode_object_storage_cluster=${OBJECT_STORAGE_CLUSTER}" -auto-approve
# Destroy infrastructure
destroy:
@echo "Destroying Terraform infrastructure for ${ENV}..."
terraform destroy -var="environment=${ENV}" -var="linode_object_storage_cluster=${OBJECT_STORAGE_CLUSTER}"
# Show outputs
output:
@echo "Terraform outputs:"
terraform output -json | jq -r 'to_entries | .[] | "\(.key) = \(.value.value)"' 2>/dev/null || terraform output
# Load environment variables
env:
@echo "Environment variables:"
@echo " ENV=${ENV}"
@echo " REGION=${REGION}"
@echo " OBJECT_STORAGE_CLUSTER=${OBJECT_STORAGE_CLUSTER}"
@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
# Validate configuration
validate:
@echo "Validating Terraform configuration..."
terraform validate
# Clean up local state
clean:
@echo "Cleaning local Terraform files..."
rm -rf .terraform/
rm -f .terraform.lock.hcl