Skip to content

Commit

Permalink
Merge pull request #19 from Cloud-Schematics/tf/1.0
Browse files Browse the repository at this point in the history
Upgrade to Terraform v1.0
  • Loading branch information
mkm-r authored Feb 24, 2022
2 parents b60b57f + 85a10e5 commit 8feca50
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ You can also choose to customize the default settings for your classic infrastru
|hostname|Enter a host name for your classic infrastructure virtual server instance. This host name is used with the `domain` to create the full URL for your classic infrastructure virtual server instance.|lamp|
|memory|Enter the amount of memory in megabytes that you want to allocate to your classic infrastructure virtual server instance. To find available memory sizes, run `ibmcloud sl vs options` and review the values in the **memory** field. |1026|
|network_speed|Enter the network speed in Mbps for your classic infrastructure virtual server instance. To find available network speeds, run `ibmcloud sl vs options` and review the values in the **nic** field. |100|
|os_reference_code|Enter the reference code of the operating system that you want to install on your virtual server instance. To see available OS reference codes, log in to the [IBM Cloud Infrastructure (Classic Infrastructure) API](https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest_Block_Device_Template_Group/getVhdImportSoftwareDescriptions.json?objectMask=referenceCode).|CENTOS_LATEST_64|
|os_reference_code|Enter the reference code of the operating system that you want to install on your virtual server instance. To see available OS reference codes, log in to the [IBM Cloud Infrastructure (Classic Infrastructure) API](https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest_Block_Device_Template_Group/getVhdImportSoftwareDescriptions.json?objectMask=referenceCode).|CENTOS_7_64|
|private_network_only|Decide if you want to connect your classic infrastructure virtual server instance to a private VLAN only. Enter `true` to connect it to a private VLAN only, and `false` to connect it to a public and a private VLAN. |false|
|ssh_label|Enter a label that you want to assign to your SSH key.|public ssh key - Schematics VM|
|ssh_notes|Enter a short description that you want to add to your SSH key. ||
Expand Down
8 changes: 5 additions & 3 deletions provider.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
variable "iaas_classic_username" {
description = "Enter the user name to access IBM Cloud classic infrastructure. Go to the [IBM Cloud API keys](https://cloud.ibm.com/iam/apikeys) page, and hover on the row of your API key, and select the **Actions** icon. Then, click **Details** and copy your user name. "
}

variable "iaas_classic_api_key" {
description = "Enter your classic infrastructure API key. Go to the [IBM Cloud API keys page](https://cloud.ibm.com/iam/apikeys) to get the details of an existing API key or to create a new one."
}

provider "ibm" {
iaas_classic_username = "${var.iaas_classic_username}"
iaas_classic_api_key = "${var.iaas_classic_api_key}"
iaas_classic_timeout = 300
iaas_classic_username = var.iaas_classic_username
iaas_classic_api_key = var.iaas_classic_api_key
iaas_classic_timeout = 300
}

12 changes: 12 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

terraform {
required_version = ">= 1.0"
required_providers {
ibm = {
source = "IBM-Cloud/ibm"
version = "1.38.0"
}
}
}


78 changes: 49 additions & 29 deletions vm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,85 +13,105 @@
#
################################################################
variable "hostname" {
default = "lamp"
default = "lamp"
description = "Enter a host name for your classic infrastructure virtual server instance. This host name is used with the `domain` to create the full URL for your classic infrastructure virtual server instance."
}

variable "domain" {
default = "domain.dev"
default = "domain.dev"
description = "Enter the domain name that you want to assign to your classic infrastructure virtual server instance. This domain name is used with the `hostname` to create the full URL for your classic infrastructure virtual server instance."
}

variable "datacenter" {
default = "wdc01"
default = "wdc01"
description = "Enter the data center where you want to provision your classic infrastructure virtual server instance. For available data centers, run `ibmcloud sl vs options` and review the values in the 'datacenter' field."
}

variable "os_reference_code" {
default = "CENTOS_LATEST_64"
default = "CENTOS_7_64"
description = "Enter the reference code of the operating system that you want to install on your virtual server instance. To see available OS reference codes, log in to the [IBM Cloud Infrastructure (SoftLayer) API](https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest_Block_Device_Template_Group/getVhdImportSoftwareDescriptions.json?objectMask=referenceCode)."
}

variable "cores" {
default = "1"
default = "1"
description = "Enter the number of CPU cores that you want to allocate to your classic infrastructure virtual server instance. For supported cores, run `ibmcloud sl vs options` and review the values in the 'cpu (standard)' field."
}

variable "memory" {
default = "1024"
default = "1024"
description = "Enter the amount of memory in megabytes that you want to allocate to your classic infrastructure virtual server instance. To find available memory sizes, run `ibmcloud sl vs options` and review the values in the 'memory' field. "
}

variable "disk_size" {
default = "25"
default = "25"
description = "Enter the numeric disk sizes in GB for the instance’s block device and disk image settings. To view available disk sizes, run `ibmcloud sl vs options` and review the values in the 'san disk (0)' field. "
}

variable "private_network_only" {
default = "false"
default = "false"
description = "Decide if you want to connect your classic infrastructure virtual server instance to a private VLAN only. Enter `true` to connect it to a private VLAN only, and `false` to connect it to a public and a private VLAN."
}

variable "network_speed" {
default = "100"
default = "100"
description = "Enter the network speed in Mbps for your classic infrastructure virtual server instance. To find available network speeds, run `ibmcloud sl vs options` and review the values in the 'nic' field."
}

variable "tags" {
default = "lamp"
default = "lamp"
description = "Enter descriptive tags that you want to add to your virtual server instance. Tags can help find your resource more easily after it is created in IBM Cloud."
}

variable "ssh_user" {
default = "root"
default = "root"
description = "Enter the default user name that you want to use to log in to the virtual server instance."
}

variable "ssh_label" {
default = "public ssh key"
default = "public ssh key"
description = "Enter a label that you want to assign to your SSH key."
}

variable "ssh_notes" {
default = ""
default = ""
description = "Enter a short description that you want to add to your SSH key."
}

variable "ssh_key" {
description = "Enter a public SSH key that you use to access your classic infrastructure virtual server instance. For more information about adding an SSH key in IBM Cloud, see [Adding an SSH key](https://cloud.ibm.com/docs/infrastructure/ssh-keys?topic=ssh-keys-adding-an-ssh-key)."
}

# Comment out if not running in schematics
variable TF_VERSION {
default = "1.0"
type = string
description = "The version of the Terraform engine that's used in the Schematics workspace."
}

resource "ibm_compute_ssh_key" "ssh_key" {
label = "${var.ssh_label}"
notes = "${var.ssh_notes}"
public_key = "${var.ssh_key}"
label = var.ssh_label
notes = var.ssh_notes
public_key = var.ssh_key
}

resource "ibm_compute_vm_instance" "vm" {
hostname = "${var.hostname}"
os_reference_code = "${var.os_reference_code}"
domain = "${var.domain}"
datacenter = "${var.datacenter}"
network_speed = "${var.network_speed}"
hostname = var.hostname
os_reference_code = var.os_reference_code
domain = var.domain
datacenter = var.datacenter
network_speed = var.network_speed
hourly_billing = true
private_network_only = "${var.private_network_only}"
cores = "${var.cores}"
memory = "${var.memory}"
disks = ["${var.disk_size}"]
private_network_only = var.private_network_only
cores = var.cores
memory = var.memory
disks = [var.disk_size]
dedicated_acct_host_only = true
local_disk = false
ssh_key_ids = ["${ibm_compute_ssh_key.ssh_key.id}"]
tags = ["${var.tags}"]
user_metadata = "${file("install.yml")}"
ssh_key_ids = [ibm_compute_ssh_key.ssh_key.id]
tags = [var.tags]
user_metadata = file("install.yml")
}

output "public_ip" {
value = "http://${ibm_compute_vm_instance.vm.ipv4_address}"
value = "http://${ibm_compute_vm_instance.vm.ipv4_address}"
}

0 comments on commit 8feca50

Please sign in to comment.