Terraform Doesn't Know the Hand-Made DB. Let It Build a New One?

A prod RDS instance was made by hand and Terraform's plan wants to create a new one. A teammate says just apply. Defend what you actually do first.

intermediate12 min4 roundsTerraformDatabases

Answer key reviewed by Branko Petric

Read first: Terraform State Explained

Your decision

You're bringing a manually-created prod RDS instance under Terraform, and because it's not in state, plan shows Terraform wanting to create a new instance. A teammate says just apply it, Terraform will make a matching one, we'll point the app at it and be consistent. What do you do, and why?

The situation

A production database was created by hand in the AWS console months ago and is now being adopted into Terraform. You run terraform plan and it shows a create for the RDS instance: the live resource is not tracked in state, so Terraform plans to build a new one from the HCL. A teammate looks at the green plan and says it is fine.

Context

The RDS instance holds live customer data and has been serving production traffic for months. It exists in the account but not in Terraform state, so Terraform has no knowledge of it. A teammate in chat says: just apply it, Terraform will make a matching one, we point the app at it, delete the old console-made one, and then everything is consistent and codified.

Worked interview answers

More: Terraform scenario interview questions