Skip to main content

Terraform overview

What is the Terraform provider?

In addition to its REST API, ECI provides an official Terraform provider, elice-dev/eci. It lets you declaratively define and version-control VMs, block storage, networks, and public IPs.

Do not use the OpenStack provider

ECI is not OpenStack-compatible. Use elice-dev/eci above, not terraform-provider-openstack.


Prerequisites

  • Terraform 1.0 or higher installed
  • A user access token: issue one from Admin > User Access Tokens in the portal (expires in 30/90 days or 6/12 months)
  • A zone ID: the UUID of the zone to deploy VMs in. Get it from Infrastructure > Zones in the portal, or via the eci_zone data source

Provider configuration

# versions.tf
terraform {
required_version = ">= 1.0"
required_providers {
eci = {
source = "elice-dev/eci"
}
}
}

# provider.tf
provider "eci" {
api_endpoint = "https://portal.elice.cloud/api"
api_access_token = var.api_access_token # inject via env var or tfvars
zone_id = var.zone_id
}
FieldDescription
api_endpointPortal API URL. Commercial zone: https://portal.elice.cloud/api; public zone: https://portal.gov.elice.cloud/api; integrated organizations: https://<organization>.elice.io/api
api_access_tokenRequired. Access token issued from the portal. The environment variable TF_VAR_api_access_token is recommended
zone_idRequired. UUID of the zone resources will be placed in
Do not commit the token

Inject api_access_token through a .tfvars (gitignored) file or an environment variable. If a token is committed, delete it from the portal immediately.


Main resources and data sources

ResourceDescription
eci_virtual_machineVM definition (specs, name, credentials)
eci_virtual_machine_allocationAllocates the VM to a host and starts it
eci_block_storageBlock storage (OS disk or data disk)
eci_block_storage_snapshotBlock storage snapshot
eci_virtual_networkVirtual network
eci_subnetSubnet
eci_network_interfaceNetwork interface
eci_public_ipPublic IP
Data sourceDescription
eci_zoneLook up a zone
eci_regionLook up a region
eci_instance_typeInstance type (name → UUID)
eci_pricingPricing (name + pricing_type)
eci_block_storage_imageOS image

For the full schema of each resource, see the official provider docs.


Next steps

  • Quickstart — first VM from creation to SSH
  • Cheatsheet — frequently used commands and patterns
  • Spot VM — automated provisioning at spot pricing