01: infra
This commit is contained in:
1 parent
ec9bb74be0
commit
341cd05ac5
71 files changed
+2058
-1
No files matched your search
@@ -0,0 +1,63 @@
|
||||
# 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
|
||||
Reference in new issue
Block a user