Skip to main content

Import an existing resource

If you want to import in the Elestio state an existing project or service already running, you can use the terraform import command.


Project

# Import a project by specifying the project ID.
terraform import elestio_project.myawesomeproject project_id


    Declare the resource in your .tf file
    resource "elestio_project" "example_project" {
      name = "example-project"
      # ...
    }


      Retrieve your ProjectID on the projects list page.

      Screenshot 2023-01-08 at 02.01.12.png

        Execute the import command

        terraform import elestio_project.exemple_project 2434

        Then you can run a terraform apply command and elestio will handle your project resource as an update and not a new resource to create.

        Service

        # Import a service by specifying the Project ID it belongs to, and the service ID (spaced by a comma).
        terraform import elestio_service.myawesomeservice project_id,service_id


          Declare the resource in your .tf file
          resource "elestio_postgres" "exemple_postgres" {
            project_id    = elestio_project.exemple_project.id
            # ...
          }


            Retrieve your ProjectID on the projects list page.

            Retrieve your ServiceID on the service page.

            Screenshot 2023-01-08 at 02.04.26.png

              Execute the import command

              terraform import elestio_postgres.exemple_postgres 2434,27265610

              Then you can run a terraform apply command and elestio will handle your service resource as an update and not a new resource to create.