Terraform provider reference / guides / import
Importing what you already have
Most projects do not start in Terraform. Everything the provider manages can be adopted instead of recreated, and the identifiers you need are the ones the API and the client area already show you.
What the identifier is
| Resource | Identifier to import |
|---|---|
fiberax_server |
the server number, e.g. 11199 |
fiberax_network |
the network number |
fiberax_ip |
the address number (not the address itself) |
fiberax_ssh_key |
the key number |
fiberax_network_interface |
<server>,<card>, e.g. 11199,net1 |
fiberax_server_firewall |
the server number - the firewall is a state OF a server |
fiberax_server_backup_policy |
the server number, for the same reason |
fiberax_disk |
<server>,<slot>, e.g. 11199,scsi1 |
fiberax_project_backup_policy |
the word project - the project is set by the token itself |
fiberax_router_firewall_rule |
<router>,<rule number>, e.g. 11102,2010 |
fiberax_router_port_forward |
<router>,<forward number>, e.g. 11102,2000 |
fiberax_router_wireguard |
the router's server number |
fiberax_router_openvpn |
the router's server number |
fiberax_router_wireguard_device |
<router>,<device>, e.g. 11102,dev1 |
fiberax_router_openvpn_device |
<router>,<device>, e.g. 11102,dev1 - its profile is not recovered |
Composite identifiers are separated by a comma, not a colon. Every resource page in this reference repeats its own identifier in an "Import" section, and that page is the authority if the two ever disagree.
The safe order
-
Write the resource block first, with at least the fields that cannot be guessed (
server_type_id,imageon a server). -
Import:
terraform import fiberax_server.app 11199
-
Run
terraform planand read it as a question, not as a task list. A plan that wants to replace something means the configuration disagrees with the platform on a field that cannot be changed in place - fix the configuration, not the platform. A plan that wants to change a few fields right after an import is normal: see the next section.
What commonly shows up in that first plan
- Fields the platform does not report back. Some fields describe the ORDER, not the object, and
the platform has nowhere to read them from afterwards:
server_type_idoffiberax_ip(the pool an address was taken from), andnetworks,ssh_keys,public_ipv4,accept_license,hostandgpusoffiberax_server(hostis a request; what the platform reports lands incurrent_host, and the cards it reports land ingpu_cards). An import leaves them empty in state, so the first plan asks to write down what your configuration already says. That first apply changes nothing on the platform: it records the values in state, and the plan after it is empty - but it is the only apply that may do so (next point).public_keyoffiberax_ssh_keybehaves the same way for a different reason - the platform stores the key material without the trailing newline your.pubfile ends with, so the first plan asks to write your spelling back; the key is NOT recreated. - Write those fields in the first apply after the import. The allowance lasts until the first
successful apply whose plan shows a change for the imported server (
update in-place), and that apply ends it even when the change only records values in state and changes nothing on the platform. An apply whose plan shows no change for the server - one that only refreshes it, or changes other resources - leaves the allowance in place.networks,public_ipv4,accept_license,hostorgpuswritten in any LATER apply (public_ipv4added after that first apply, say) replaces the server and erases its disks, exactly as on a server Terraform created;ssh_keysnever replaces anything. The plan does not tell you that the allowance is spent: such a change shows only as the usual "forces replacement" - read the plan before you apply. public_ipv4decides whatdestroydoes with the addresses. Whatever form you write after the import is what the provider acts on later: withnew = true, destroying or replacing the server releases EVERY public address it has to the shared pool, for good. For an imported server writeid(usually an importedfiberax_ip) in that first apply, or leave the block out - then destroy keeps the addresses with the project, still billed until you release them. See Public addresses and what they cost.- Size fields on a plan-based type. A type sold as plans sets cores, memory and disk from the
plan; writing them by hand makes the plan want a change forever. Leave them out and keep
plan_id. - The firewall. Import brings the rules in the order the platform holds them, and order is
meaningful: the first matching rule wins. Copy the imported order into the configuration rather
than tidying it. With
enabled = truewrite bothpolicy_inandpolicy_outas the imported state shows them - the provider does not fill a policy in for you. - Addresses. A server created in the client area holds an address that has its own number. If
you want Terraform to manage it, import
fiberax_ipas well and reference it from the server instead of asking for a new one.
Importing a whole project at once
There is no single command for that, and the reason is not politeness: the provider cannot tell which of your existing servers you want managed. Import them one by one, starting with the ones you actually intend to change.
Generated from the provider schema for version 0.11.0. How to install the provider: Terraform provider.