Is it possible to use terraform with IBM classic infrastructure?

359 Views Asked by At

I'm trying to create a classic virtual server using terraform by following below two articles but I'm getting an error.

Articles

  1. https://cloud.ibm.com/docs/ibm-cloud-provider-for-terraform?topic=ibm-cloud-provider-for-terraform-getting-started

  2. https://cloud.ibm.com/docs/ibm-cloud-provider-for-terraform?topic=ibm-cloud-provider-for-terraform-sample_infrastructure_config

Error

Error: Error ordering virtual guest: Error generating order template: SoftLayer_Exception_Public: Access Denied. (HTTP 401)

provider.tf

terraform {
  required_providers {
    ibm = {
      source = "IBM-Cloud/ibm"
      version = "1.21.2"
    }
  }
}

variable "ibmcloud_api_key" {}
variable "iaas_classic_username" {}
variable "iaas_classic_api_key" {}

provider "ibm" {
  ibmcloud_api_key   = var.ibmcloud_api_key
  region             = "sng01"
  iaas_classic_username = var.iaas_classic_username
  iaas_classic_api_key  = var.iaas_classic_api_key
}

classic-vsi.tf

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

terraform.tfvars


ibmcloud_api_key = ""
iaas_classic_username = "emailID"
iaas_classic_api_key = ""

for iaas_classic_api_key I followed this article

for ibmcloud_api_key I followed this article

Is it possible to use terraform OR it is deprecated in favor of VPC2 Infrastructure?

Please help.

UPDATE

fixed the 401 error by replacing the value of iaas_classic_username from email-ID to IBM account six-digit unique ID. check the User-name by following the below article.

Reference article: https://cloud.ibm.com/docs/account?topic=account-vpnpassword

Now I'm getting the below error.

Error: Error ordering virtual guest: SoftLayer_Exception_Order_Item_Unavailable: Debian GNU/Linux 8.x jessie/Stable - Minimal Install (64 bit) is not available as of 09/12/2020 (Item #(6195). (HTTP 500)

1

There are 1 best solutions below

0
On

That error indicates that the OS image you are trying to order is no longer available. You will need to use Debian 9 or 10.

⇒  slcli vs create-options | grep -i 'Debian 9'
Debian 9.0.0-64 LAMP for VSI                                            OS_DEBIAN_9_X_STRETCH_LAMP_64_BIT                       DEBIAN_9_64
Debian 9.0.0-64 Minimal for VSI                                         OS_DEBIAN_9_X_STRETCH_MINIMAL_64_BIT                    DEBIAN_9_64

⇒  slcli vs create-options | grep -i 'Debian 10'
Debian 10.0.0-64 Minimal for VSI                                        OS_DEBIAN_10_X_BUSTER_MINIMAL_64_BIT_VSI                DEBIAN_10_64

If you had a specific need to use Jessie, you can use your own OS with a classic VSI. This guide outlines the process preparing a custom image for import.

On another note, you will want to use flavor_key_name in place of setting core and memory values directly. The core/memory combo is still supported by the Classic API but does not support new features like suspended billing and may be deprecated in the future.