3
votes

Just a quick question, does anyone know if Terraform will wipe out existing resources on AWS?

For example if I already have an existing VPC with resources, or S3/EFS storage will Terraform ignore these resources when I run it with my configuration files to deploy say another VPC?

Or as Terraform is looking for a desired state will it wipe anything existing?

Am hoping unless you specifically import existing resources Terraform will just leave them alone?

Thanks

1
Terraform apply will fail if resource with the same name exists already. Example: RDS instance. However, VPCs are identified by VPC IDs. Since they are unique, your terraform apply will create new resource. To be safe, run terraform plan command to find out all resources that will be updated / deleted.krishna_mee2004
Thanks Krishna, anything additional created by Terraform will be unique, but yes you are completely right I can just run plan and see what Terraform is planning to doStevieHyperB
@KrishnaKumarR you should consider fleshing your comment out into a full answer.ydaetskcoR

1 Answers

4
votes

It Depends.

It varies from case to case as the responses will be coming from the cloud providers (AWS, Azure).

Ex.

  1. If you create a VPC in terraform, it will generate a new VPC ID (terraform won't allow to use VPC ID in coding). So, it won't affect your existing resources.

  2. If you write a Route53 record in terraform, it could overwrite existing Route53 entries.

But, If you import terraform state form existing resources, it will import its state and map it with the terraform resources. In that case, destroying the resource will remove the actual cloud resource.

Hope I understood your question and answered it.