Use `terraform apply` when a configuration is ready to become infrastructure. Terraform executes the actions in an execution plan, walking its dependency graph to bring resources into line with the configuration. It is the deployment step in the usual `init`, `plan`, `apply` workflow. section 5.5 section 1.7
Choose how the plan reaches `apply`:
- Create a plan and pass the saved plan file to the apply command. section 5.5
- Run `terraform apply` without a plan file to generate a plan in the same command. Terraform asks for confirmation by default, leaving a chance to review changes. This mode also accepts planning options, including variable inputs, resource targeting, destroy, and refresh-only. section 5.5.1
Apply a local module in a test workspace
A workspace can call a local module, look up the default AWS VPC and one of its subnets, and pass the selected subnet ID into the module. Run `terraform init` in that workspace, then `terraform apply`; review the proposed changes before confirming. The workspace can expose a module output such as the resulting instance ARN. section 3.8.4
Listing 3.36 Testing our local module
data "aws_vpc" "default" { #1
default = true #1
} #1
data "aws_subnets" "default" { #1
filter { #1
name = "vpc-id" #1
values = [data.aws_vpc.default.id] #1
} #1
} #1
module "test_instance" {
source = "../"
subnet_id = data.aws_subnets.default.ids[0] #2
}
output "aws_instance_arn" { #3
value = module.test_instance.aws_instance_arn
}
The configuration shows the data lookups, relative module source, subnet argument, and output used by the test workspace. section 3.8.4
Avoid `-auto-approve` merely to skip review: without a saved plan file, `apply` creates a plan and immediately acts on it. Even a preceding, separate `terraform plan` may no longer describe the same situation if changes occurred outside the workflow. For automation, `apply -json` emits one JSON event per line as work progresses, so a wrapper can stream messages and handle warnings or errors rather than waiting for one final result. section 5.5.1 section 11.1.7
An apply also matters in Terraform tests: a `run` block applies by default. Switching it to `command = plan` can make assertions fail when they depend on output values unavailable until after application. section 9.4.1

