Terraform overview
Basic concepts
There are some basic components for terraform.
- Resource: one infrastructure element, like a virtual machine. Resource type is defined in a provider.
- Provider: a collection of resource types. Most provider offer resource types on a platform. The example of a provider is AWS, GCP, or Kubernetes.
- Module: a set of resources. In order to use modules, following elements may be used.
- Input variables:, defined as variable.
- Output variables: defined as output.
- Local variables: defined in locals.
- Data Sources: Data defined and used externally from current terraform. This may be a different terraform state.
State
The current infrastructure configuration is stored in state by terraform. Terraform stores the state in terraform.tfstate localy by default, but using backend, state can be stored remotely like AWS S3. The state can contain sensitive data such as a database password. To avoid this, by some backends, encryption or other features are provided.
External web services or tools
Terraform Cloud
The managed service for terraform. See official page for more details.
Terraform registry
https://registry.terraform.io/
Reusable modules published on registry.
GitHub Actions
https://www.terraform.io/docs/github-actions/index.html
Circle CI Orbs
https://circleci.com/orbs/registry/orb/ovotech/terraform
There are many unofficial terraform orbs, but this has check, plan, and apply features with workspace, parallelism, and github comments.
Further readings
See official pages for more details.