Refreshing infrastructure
It could be that someone updated the resource managed by Terraform manually, via AWS API or AWS Management Console. If changed attribute is specified inside the template, then you can fix it by running the terraform apply
 command--given that Terraform templates are the source of truth when it comes to the state of the infrastructure. But if this attribute is not managed by Terraform template, then you might still want it to be reflected in your state
file. That's when the terraform refresh
 command comes to the rescue.
Apply the template and then go to AWS Console. Open the VPC section and find the VPC Terraform created. Right-click on this VPC and choose Edit DNS Hostnames. Then change DNS Hostnames to Yes:
Now head back to your console and execute the terraform refresh
 command. Open the terraform.tfstate
file and verify that the change in the state file happened as expected:
"aws_vpc.my_vpc": { "type": "aws_vpc", ...