Contents
Terraform is logically split into two main parts: Terraform Core and Terraform Plugins. Terraform Core uses remote procedure calls (RPC) to communicate with Terraform Plugins, and offers multiple ways to discover and load plugins to use.
Terraform Core
Terraform Core is a statically-compiled binary written in the Go programming language.
Primary responsibilities:
- Infrastructure as code: reading and interpolating configuration files and modules
- Resource state management
- Construction of the Resource Graph
- Plan execution
- Communication with plugins over RPC
Terraform Plugins
Terraform Plugins are written in Go and are executable binaries invoked by Terraform Core over RPC.
Provider Plugins are responsible for:
- 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
Provisioner Plugins are responsible for:
- Executing commands or scripts on the designated Resource after creation, or on destruction
Discovery
When terraform init is run, Terraform reads configuration files in the working directory to determine which plugins are necessary, searches for installed plugins in several locations, sometimes downloads additional plugins, decides which plugin versions to use, and writes a lock file to ensure Terraform will use the same plugin versions in this directory until terraform init runs again.
Upgrading Plugins
When terraform init is run with the -upgrade option, it re-checks the Terraform Registry for newer acceptable provider versions and downloads them if available.