arvancloud_iaas_server (Resource)
Manages an IaaS cloud server instance.
Example Usage
# Basic server instance with minimal configuration
resource "arvancloud_iaas_server" "example" {
name = "my-server"
availability_zone = "ir-central1-a"
flavor_id = "g1-1-1-0"
image_id = "debian-12-image-id"
disk_size = 25
ha_enabled = false
security_groups = ["security-group-1-id"]
enable_backup = false
# Optional SSH key for remote access
key_name = "my-ssh-key"
# Optional public IP configuration (applied at creation time)
enable_ipv4 = true
enable_ipv6 = false
# Optional private network attachments
private_network_ids = ["private-net-id-1", "private-net-id-2"]
# Optional volume attachments
volume_attachments = ["volume-id-1", "volume-id-2"]
}
# Example: Server with lifecycle management to avoid drift
# Use this pattern when managing networks/volumes through separate attachment resources
resource "arvancloud_iaas_server" "example_with_external_attachments" {
name = "my-server-with-attachments"
availability_zone = "ir-central1-a"
flavor_id = "g1-1-1-0"
image_id = "debian-12-image-id"
disk_size = 25
ha_enabled = false
security_groups = ["security-group-1-id"]
enable_backup = false
key_name = "my-ssh-key"
enable_ipv4 = true
enable_ipv6 = false
# Initial networks and volumes managed at server creation
private_network_ids = ["initial-network-id"]
volume_attachments = ["initial-volume-id"]
# IMPORTANT: Use lifecycle.ignore_changes when managing attachments separately
# This prevents Terraform from detecting "drift" when arvancloud_iaas_network_attachment
# or arvancloud_iaas_volume_attachment resources attach additional resources
lifecycle {
ignore_changes = [
private_network_ids, # Ignore when networks are attached via network_attachment resources
volume_attachments, # Ignore when volumes are attached via volume_attachment resources
]
}
}
# Example: Attach additional network using separate resource
# This won't cause drift because the server has lifecycle.ignore_changes
resource "arvancloud_iaas_network_attachment" "additional_network" {
network_id = "additional-network-id"
server_id = arvancloud_iaas_server.example_with_external_attachments.id
subnet_id = "subnet-id"
ip_address = "192.168.1.100"
enable_port_security = true
availability_zone = "ir-central1-a"
}
# Example: Server without public IP using "parking network" workaround
# Cloud provider requires servers to have either IPv4 enabled OR at least one private network
# This pattern allows you to disable public IP while managing all networks externally
resource "arvancloud_iaas_server" "example_no_public_ip" {
name = "my-server-no-public-ip"
availability_zone = "ir-central1-a"
flavor_id = "g1-1-1-0"
image_id = "debian-12-image-id"
disk_size = 25
ha_enabled = false
security_groups = ["security-group-1-id"]
enable_backup = false
key_name = "my-ssh-key"
# Disable public IPv4 - no public IP will be assigned
enable_ipv4 = false
enable_ipv6 = false
# WORKAROUND: Include a "parking" private network to satisfy the requirement
# that servers must have either IPv4 or a private network
# This network can be a minimal/dummy network that you don't actually use
private_network_ids = ["parking-network-id"]
# CRITICAL: Use ignore_changes to prevent drift when you attach real networks
# via network_attachment resources
lifecycle {
ignore_changes = [private_network_ids]
}
}
# Now attach your actual production networks using network_attachment resources
resource "arvancloud_iaas_network_attachment" "production_network" {
network_id = "production-network-id"
server_id = arvancloud_iaas_server.example_no_public_ip.id
subnet_id = "production-subnet-id"
ip_address = "192.168.10.50"
enable_port_security = true
availability_zone = "ir-central1-a"
}
# Example: Server managing all networks/volumes inline (no lifecycle needed)
resource "arvancloud_iaas_server" "example_fully_managed" {
name = "my-fully-managed-server"
availability_zone = "ir-central1-a"
flavor_id = "g1-1-1-0"
image_id = "debian-12-image-id"
disk_size = 25
ha_enabled = false
enable_backup = false
# All networks and volumes are managed inline - no separate attachment resources
private_network_ids = [
"network-1-id",
"network-2-id",
"network-3-id",
]
volume_attachments = [
"volume-1-id",
"volume-2-id",
]
# No lifecycle.ignore_changes needed when managing everything inline
}
# Outputs for the basic server
output "server_id" {
description = "Unique identifier of the server"
value = arvancloud_iaas_server.example.id
}
output "server_status" {
description = "Current status of the server"
value = arvancloud_iaas_server.example.status
}
output "server_region" {
description = "Region where the server is located"
value = arvancloud_iaas_server.example.region
}
output "server_created" {
description = "Timestamp when the server was created"
value = arvancloud_iaas_server.example.created
}
Schema
Required
availability_zone(String) Availability zone where the server will be created (e.g.ir-central1-a). Changing this will create a new instance in the new AZ and delete the old one.disk_size(Number) Boot disk size in GB. You can only increase the size of the bood disk. Changing this will STOP the server instance till the resize action is completed.enable_backup(Boolean) Whether to enable automatic backups for the server.flavor_id(String) ID of the flavor (server type) to use for the server. Changing this will resize the server instance. Please note that the server will be STOPPED till the resize action is completed.ha_enabled(Boolean) Whether high availability is enabled for the server.Disabling this feature prevents the instance from starting or turning on automatically when an unforeseen problem occurs. Note that this may prolong downtime.Before you proceed, please ensure the necessary backup of the instance has been made.image_id(String) ID of the image to use for the boot disk. You can specify either an image ID or a snapshot ID. Please note that changing the image will destroy and recreate the server.name(String) Name of the server. Can be updated in-place without recreation.
Optional
enable_ipv4(Boolean) Whether to enable Public IPv4 for the server. Note that this will only be applied at the creation. to manage IPv4 address after the server is created, please use network resource to add/remove public IPs to/from your server instance.enable_ipv6(Boolean) Whether to enable Public IPv6 for the server. Note that this will only be applied at the creation. to manage IPv6 address after the server is created, please use network resource to add/remove public IPs to/from your server instance. Please note that enabling IPv6 will require the IPv4 to be enabled as well.key_name(String) Name of the SSH key pair to inject into the server.private_network_ids(List of String) List of network IDs to attach the server to. Changing this will attach (adding new ids) or detach (removing existing ids) the server instance to/from specified networks. Important: If you plan to manage network attachments using separatearvancloud_iaas_network_attachmentresources, addlifecycle { ignore_changes = [private_network_ids] }to prevent drift detection. Workaround for no public IP: If you want to disableenable_ipv4at creation and manage all networks externally, you must initially attach at least one 'parking' private network here (since servers require either IPv4 or a private network), then uselifecycle { ignore_changes = [private_network_ids] }to ignore subsequent attachments made by network_attachment resources.security_groups(List of String) List of security group names to apply to the server. Please note that the server should at least one security group attached and cannot left empty. The securigy groups are only applied at the server creation phase and changing it after that has no impact on the server instance. To manage security group attachments after the server is created, please usearvancloud_iaas_security_group_attachmentresource to attach/detach security groups to/from your server instance.volume_attachments(List of String) List of volume IDs to attach to the server. Changing this will attach/detach the specified volumes to/from the server instance. Important: If you plan to manage volume attachments using separatearvancloud_iaas_volume_attachmentresources, addlifecycle { ignore_changes = [volume_attachments] }to prevent drift detection.
Read-Only
created(String) Timestamp when the server was created.dedicated_server_id(String) ID of the dedicated server, if applicable.id(String) Unique identifier of the server.region(String) Region where the server is located (e.g.ir-central1).status(String) Current status of the server (e.g.ACTIVE,SHUTOFF).task_state(String) Current task state of the server.
Import
Import is supported using the following syntax:
terraform import arvancloud_iaas_server.example ir-central1-a:36eef5e6-e618-4a59-b8a2-97fa08817a29