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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access