opentofu/website/source/docs/providers/softlayer/r/virtual_guest.html.markdown
danielcbright 8921e10d71 Added softlayer virtual guest and ssh keys functionality:
Here is an example that will setup the following:
+ An SSH key resource.
+ A virtual server resource that uses an existing SSH key.
+ A virtual server resource using an existing SSH key and a Terraform managed SSH key (created as "test_key_1" in the example below).

(create this as sl.tf and run terraform commands from this directory):
```hcl
provider "softlayer" {
    username = ""
    api_key = ""
}

resource "softlayer_ssh_key" "test_key_1" {
    name = "test_key_1"
    public_key = "${file(\"~/.ssh/id_rsa_test_key_1.pub\")}"
    # Windows Example:
    # public_key = "${file(\"C:\ssh\keys\path\id_rsa_test_key_1.pub\")}"
}

resource "softlayer_virtual_guest" "my_server_1" {
    name = "my_server_1"
    domain = "example.com"
    ssh_keys = ["123456"]
    image = "DEBIAN_7_64"
    region = "ams01"
    public_network_speed = 10
    cpu = 1
    ram = 1024
}

resource "softlayer_virtual_guest" "my_server_2" {
    name = "my_server_2"
    domain = "example.com"
    ssh_keys = ["123456", "${softlayer_ssh_key.test_key_1.id}"]
    image = "CENTOS_6_64"
    region = "ams01"
    public_network_speed = 10
    cpu = 1
    ram = 1024
}
```

You'll need to provide your SoftLayer username and API key,
so that Terraform can connect. If you don't want to put
credentials in your configuration file, you can leave them
out:

```
provider "softlayer" {}
```

...and instead set these environment variables:

- **SOFTLAYER_USERNAME**: Your SoftLayer username
- **SOFTLAYER_API_KEY**: Your API key
2016-05-03 15:58:58 -05:00

4.9 KiB

layout page_title sidebar_current description
softlayer SoftLayer: virtual_guest docs-softlayer-resource-virtual-guest Manages SoftLayer Virtual Guests.

softlayer\virtual_guest

Provides virtual guest resource. This allows virtual guests to be created, updated and deleted. For additional details please refer to API documentation.

Example Usage

# Create a new virtual guest using image "Debian"
resource "softlayer_virtual_guest" "twc_terraform_sample" {
    name = "twc-terraform-sample-name"
    domain = "bar.example.com"
    image = "DEBIAN_7_64"
    region = "ams01"
    public_network_speed = 10
    hourly_billing = true
    private_network_only = false
    cpu = 1
    ram = 1024
    disks = [25, 10, 20]
    user_data = "{\"value\":\"newvalue\"}"
    dedicated_acct_host_only = true
    local_disk = false
    frontend_vlan_id = 1085155
    backend_vlan_id = 1085157
}
# Create a new virtual guest using block device template
resource "softlayer_virtual_guest" "terraform-sample-BDTGroup" {
   name = "terraform-sample-blockDeviceTemplateGroup"
   domain = "bar.example.com"
   region = "ams01"
   public_network_speed = 10
   hourly_billing = false
   cpu = 1
   ram = 1024
   local_disk = false
   block_device_template_group_gid = "****-****-****-****-****"
}

Argument Reference

The following arguments are supported:

  • name | string
    • Hostname for the computing instance.
    • Required
  • domain | string
    • Domain for the computing instance.
    • Required
  • cpu | int
    • The number of CPU cores to allocate.
    • Required
  • ram | int
    • The amount of memory to allocate in megabytes.
    • Required
  • region | string
    • Specifies which datacenter the instance is to be provisioned in.
    • Required
  • hourly_billing | boolean
    • Specifies the billing type for the instance. When true the computing instance will be billed on hourly usage, otherwise it will be billed on a monthly basis.
    • Required
  • local_disk | boolean
    • Specifies the disk type for the instance. When true the disks for the computing instance will be provisioned on the host which it runs, otherwise SAN disks will be provisioned.
    • Required
  • dedicated_acct_host_only | boolean
    • Specifies whether or not the instance must only run on hosts with instances from the same account
    • Default: nil
    • Optional
  • image | string
    • An identifier for the operating system to provision the computing instance with.
    • Conditionally required - Disallowed when blockDeviceTemplateGroup.globalIdentifier is provided, as the template will specify the operating system.
  • block_device_template_group_gid | string
    • A global identifier for the template to be used to provision the computing instance.
    • Conditionally required - Disallowed when operatingSystemReferenceCode is provided, as the template will specify the operating system.
  • public_network_speed | int
    • Specifies the connection speed for the instance's network components.
    • Default: 10
    • Optional
  • private_network_only | boolean
    • Specifies whether or not the instance only has access to the private network. When true this flag specifies that a compute instance is to only have access to the private network.
    • Default: False
    • Optional
  • frontend_vlan_id | int
    • Specifies the network vlan which is to be used for the frontend interface of the computing instance.
    • Default: nil
    • Optional
  • backend_vlan_id | int
    • Specifies the network vlan which is to be used for the backend interface of the computing instance.
    • Default: nil
    • Optional
  • disks | array
    • Block device and disk image settings for the computing instance
    • Optional
    • Default: The smallest available capacity for the primary disk will be used. If an image template is specified the disk capacity will be be provided by the template.
  • user_data | string
    • Arbitrary data to be made available to the computing instance.
    • Default: nil
    • Optional
  • ssh_keys | array
    • SSH keys to install on the computing instance upon provisioning.
    • Default: nil
    • Optional
  • ipv4_address | string
    • Uses editObject call, template data defined here.
    • Default: nil
    • Optional
  • ipv4_address_private | string
    • Uses editObject call, template data defined here.
    • Default: nil
    • Optional
  • post_install_script_uri | string

Attributes Reference

The following attributes are exported:

  • id - id of the virtual guest.