Description:
- has some feature of imperative: loop, dynamic, locals,…
- Top to bottom, need to performs the dependencies first
- An execution plan describing what it will do to reach the desired state, and then executes it to build the described infrastructure.
- As the configuration changes, Terraform can determine what changed and create incremental execution plans that can be applied.
- Terraform lifecycle: Code → init → plan → validate → apply → destroy
- Files
terraform.tfvars or *.vars
terraform.tfstate
.terraform.tfstate.lock.info
.terraform.lock.hcl
.terraformignore
- Drifts:
- Types of errors:
- language
- state
- core
- provider
- Registry
- Best practices
- Docs
Introduction:
- Declarative Programming for Infrastructure management from low-level to high-level resources
- How does terraform work:
- Terraform goes through Terraform Provider which talks to target API of that cloud/service
- Workflow:
- Write: define resources, can be multi cloud
- Plan: to create execution plan, including create/update/destroy
- Apply
Use cases
- Multi-Cloud Deployment
- Application Infrastructure Deployment, Scaling, and Monitoring Tools
- Self-service clusters: lets product teams manage their own infrastructure independently
- Policy Compliance and Management
- PaaS Application Setup
- Software Defined Networking
- Kubernetes
- Parallel Environments
- Software demos
Manage infrastructure
Collaborate:
Develop and Share
Plugin development
- How Terraform works with plugins
- Terraform Core:
- written in Go Language
- responsibilities:
- Infrastructure as code
- Resource state management
- Construction of the Terraform Resource Graph
- Plan execution
- Communication with plugins over RPC
- Terraform Plugin:
- Invoked by Terraform Core
- Each plugin exposes an implementation for a specific service, such as AWS, or provisioner, such as bash.
- All Terraform Provisioners and Terraform Provisioners used in Terraform configurations are plugins
- responsibilities of Provider Plugins are:
- Initialization of any included libraries used to make API calls
- Authentication with the Infrastructure Provider
- Define managed resources and data sources that map to specific services
- Define functions that enable or simplify computational logic for practitioner configurations
Modules