IBM Cloud Docs
Provisioning an IBM Cloud virtual server for classic infrastructure

Provisioning an IBM Cloud virtual server for classic infrastructure

You can provision your virtual server for classic infrastructure by using the IBM Cloud Provider plug-in. Similar to the IBM Cloud virtual server for VPC provision that you provisioned. You need to create another configuration file with the specification for your virtual server instance.

Keep in mind that a virtual server is an IBM Cloud classic infrastructure resource that incurs costs. Be sure to review the available plans before you proceed.

Objectives

In this tutorial, you will:

  • Learn how to configure a virtual server for classic infrastructure with DEBIAN_8_64 Operating System by using IBM Cloud Provider.
  • Learn to configure the latest Terraform version 1.0 and higher in version.tf file.
  • Terraform commands to provision the resource.
  • Destroy the configured virtual server for classic infrastructure.

Audience

This tutorial is intended for system administrators who want to learn how to create an virtual server for classic infrastructure with DEBIAN_8_64 or CENTOS_7_64 Operating System by using IBM Cloud Provider.

Prerequisites

Configure the resource file

  1. Create a configuration file that is named classic-vsi.tf with the following content. Store this file in your folder or Git repository that you created earlier.

    resource "ibm_compute_vm_instance" "vm1" {
    hostname             = "vm1"
    domain               = "example.com"
    os_reference_code    = "DEBIAN_8_64"
    datacenter           = "dal10"
    network_speed        = 10
    hourly_billing       = true
    private_network_only = false
    cores                = 1
    memory               = 1024
    disks                = [25]
    local_disk           = false
    }
    

    For more information, about the description of ibm_compute_vm_instance resource argument and its values, refer to registry documentation of ibm_compute_vm_instance

Configure Terraform and provider version

Create a configuration file that is named versions.tf with the following content. Store this file in your folder or Git repository that you created earlier.

terraform {
    required_version = ">=1.0.0, <2.0"
    required_providers {
        ibm = {
            source = "IBM-Cloud/ibm"
        }
    }
}

Initializing Terraform

Run the Terraform initialization command and observe the successful execution.

 terraform init

Generating Terraform plan

Generate an Terraform on IBM Cloud execution plan. When you execute this command, Terraform on IBM Cloud validates the syntax of your configuration file and resource definitions against the specifications that are provided by the IBM Cloud Provider plug-in.

 terraform plan

Review the execution plan to verify the type of resource that is planned to be provisioned by Terraform on IBM Cloud.

Executing Terraform apply

Create your classic infrastructure virtual server. Confirm the creation by entering yes when prompted.

 terraform apply

Example output

Creating...

ibm_compute_vm_instance.vm1: Still creating... (40s elapsed)
ibm_compute_vm_instance.vm1: Still creating... (50s elapsed)
ibm_compute_vm_instance.vm1: Still creating... (1m0s elapsed)
ibm_compute_vm_instance.vm1: Creation complete after 1m04s (ID: 62364997)

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Running Terraform show

List the classic infrastructure virtual server that is provisioned.

 terraform show

Example output

ibm_compute_vm_instance.vm1:
id = 62364997
block_storage_ids.# = 0
cores = 1
datacenter = dal10
...
wait_time_minutes = 90

Optional: Review your classic virtual server instance in the IBM Cloud is created.

Executing Terraform destroy

Optional: Remove your classic infrastructure virtual server.

 terraform destroy

What's next?