Importing individual resources
Terraform supports two ways of importing resources into state. One is inherently imperative and procedural and is typically executed outside of a GitOps process using Terraform’s Command Line Interface (CLI). There is also another, newer option that allows us to declare import operations in code and follow our standard GitFlow process to shepherd these changes into production.
The import command
The import
command allows you to import an existing resource that has already been provisioned outside of Terraform by some other means:
terraform import [options] ADDRESS ID
The Terraform import
command (https://developer.hashicorp.com/terraform/cli/commands/import) takes two key parameters. The various options fall outside of the scope of this book. I recommend that you check the documentation for more details on all of the available options.
The first parameter, the address of the resource within the Terraform code base, is crucial. It...