Country or region and language

    Choose your country or region and your language.

    Suggested for you

      All countries and regions

        Choose your character

        It shows in the top bar and on your profile. Change it any time.

        Terraform course

        Existing resource imports

        Opening Terraform
        Your turn

        Terraform import: existing resources and state

        Object identity

        Import connects an existing provider object with a Terraform resource address. A matching name is not enough. Before importing, identify the provider object, the target address and whether another state already manages it.

        resource "lab_server" "dispatch" {
          name = "cedar-dispatch"
          size = 4
        }
        
        import {
          to = lab_server.dispatch
          id = "existing-dispatch-42"
        }

        This is an original example for the course’s fictional provider. It assumes that the supplied object already exists. Real providers define their own import identifiers and supported import behavior.

        The next plan

        After importing, compare configuration with the object. If configuration asks for size 2 while the provider holds size 4, import does not choose which size the owner intended. Read the next plan and settle that difference before applying it.

        The official import guide explains configuration-driven import and its requirements. Continue with state inspection and moved blocks. Removing a binding from state leaves the provider object in place; it is a separate action from destroying that object.

        Your Work Gym account

        Save your progress and pick up on another device. Your browser's progress comes with you.

        or

        You can keep practicing without an account.

        Change your plan

        Checking the price

        Help and feedback

        Ask a question, tell us what is not working, or share an idea. We reply by email.

        What is it about?

        We use it only to reply to you.