Back to course

Importing Existing Infrastructure

Infrastructure as Code (Terraform & OpenTofu Mastery)

Bringing ClickOps into IaC

If you have a server that was created manually, you can 'bring' it into OpenTofu management.

  1. Write the resource block in your code.
  2. Run the import command: bash tofu import aws_instance.manual_server i-0123456789abcdef0

This maps the existing cloud resource to your state file. Now you can manage it with code.