Skip to main content

Import an existing resource

You can use the terraform import command to import in the Elestio state an existing project or service already running.


Project

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


  1. Declare the resource in your terraform file
resource "elestio_project" "example_project" {
  name = "example-project"
  ...
}
  1. Retrieve your ProjectID on the projects list page.

    Screenshot 2023-01-08 at 02.01.12.png

  2. Execute the import command

    terraform import elestio_project.exemple_project 2434

    Then you can run a terraform apply command and Terraform 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


  1. Declare the resource in your terraform file
resource "elestio_postgres" "exemple_postgres" {
  project_id    = elestio_project.exemple_project.id
  ...
}
  1. Retrieve your ProjectID on the projects list page.

  2. Retrieve your ServiceID on the service page.

Screenshot 2023-01-08 at 02.04.26.png

  1. Execute the import command

    terraform import elestio_postgres.exemple_postgres 2434,27265610

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