FILE: materi-23.module

Infrastructure as Code

Bye click-and-drag. Define infra dalam code: Terraform, Ansible, CloudFormation.

RUNTIME: 28m LEVEL: advanced STATUS: ACTIVE
> INFRASTRUCTURE AS CODE $ Terraform Ansible [OK] Module loaded successfully [INFO] Ready for next stage

1. Mengapa IaC

Manual config: tidak reproducible, human error, scale issue. IaC: version controlled, reviewable, automated. Spin up identical environment di seconds. Disaster recovery jadi mudah.

2. Terraform

Tool IaC paling populer. Declarative HCL syntax. Multi-cloud (AWS, GCP, Azure, dst). State file track resource. Provider plugin untuk integrasi service. terraform plan dan terraform apply.

3. Ansible

Configuration management. YAML playbook. Agentless (SSH atau WinRM). Idempotent: jalanin lagi tidak break. Role untuk reusability. Inventory untuk define hosts.

4. Cloud Native Tools

AWS CloudFormation. Google Cloud Deployment Manager. Azure ARM atau Bicep. Pulumi (pakai bahasa programming). Crossplane untuk K8s-native IaC. Pilih sesuai cloud strategy.

5. Best Practices

State file di backend remote (S3, Terraform Cloud). Modular code dengan reusable module. Environment terpisah (dev, staging, prod). Code review wajib. Secrets di vault, bukan code.

Practical Mission

  1. Install Terraform
  2. Spin up VPC AWS dengan Terraform
  3. Pelajari Ansible playbook
  4. Modularize Terraform code
  5. Setup remote state di S3

Recap Module