Adding input variables.tf doesn't change infra

I’ve been following the AWS tutorial. AWS instances spins up fine and changes when I amend main.tf. However, when I amend main.tf to reference an input varialbe and add a variables.tf file, the instance isn’t changed.

$ terraform -v
Terraform v1.1.1
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v3.70.0

Console output

$ terraform apply
aws_instance.app_server: Refreshing state... [id=i-0eb77b679b65d2a35]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

If I create the main.tf and variables.tf on a fresh build it works as expected.

Is there a step I am missing?

Hi @eft,

Unless the value you’ve assigned to the variable is different than the value you had previously hard-coded, it’s correct that Terraform would detect no changes, because it’s comparing your real infrastructure to the current configuration rather than comparing the current configuration to the previous configuration. (Terraform cannot actually see the original configuration, only its result as reflected in the remote system and in Terraform’s own state.)

If you have changed the value of the variable compared to what was set before and are still seeing no change, it would help to see the configuration files you’re working with or else it’s not really possible to guess what’s going on here.