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 ...

Get Getting Started with Terraform now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.