Junior — Middle
How does Terraform determine the target server for executing its commands?
sobes.tech AI
Answer from AI
Terraform itself does not connect directly to target servers to execute commands. Instead, it interacts with infrastructure providers (such as AWS, Azure, GCP, VMware, etc.) that manage resources.
Terraform uses configuration files that describe which resources need to be created or modified. API providers accept these requests and create or modify the infrastructure. If commands need to be executed on the server (for example, via a provisioner like "remote-exec"), Terraform connects to the server via SSH or WinRM, using connection parameters specified in the configuration (address, login, keys). Thus, the target server is determined by the connection parameters in the Terraform configuration.