Skytap Terraform provider reference

Contents

Configuration and credentials

provider "skytap" {
  username = "${var.skytap_username}"
  api_token = "${var.skytap_api_token}"
}

resource "skytap_environment" "env" {
    # ...
}

Data Sources

skytap_template

Retrieves information about a template. This data source provides the id and name of a template as configured in your Skytap account. This is useful to retrieve a template id via its name.

The name field can accept an exact string or a regular expression.

An error occurs if any of the following conditions is true:

  • No template can be retrieved.
  • The template does not exist.
  • More than one template matches the name and the most_recent flag is not set.

If more than one templates are returned, set most_recent to true to sort the results in descending order by creation date. By default, the newest template is used.

The data source name is skytap_template and the following fields are defined:

Field Name Type Description
name string (required) A regular expression representation of the template name.
most_recent Boolean (optional) Use the most recently created template from the returned list.
Attributes Reference

The following attributes are exported:

Field Name Type Description
id integer The unique ID of the template.
Example Usage

Get the template:

data "skytap_template" "example" {
    name = "18.04"
    most_recent = true
}

skytap_project

Get information on a project. This data source provides the id, name, summary, auto_add_role_name and show_project_members properties of a project as configured in your Skytap account. Use to obtain the project’s id via its name.

An error occurs if any of the following conditions is true:

  • No projects can be retrieved.
  • The project does not exist.
  • More than one project matches the name.
Example Usage

Get the project:

data "skytap_project" "example" {
  name = "example"
}
Argument Reference

The following arguments are supported:

Field Name Type Description
name string (required) The name of project.
Attributes Reference

The following attributes are exported:

Field Name Type Description
id integer The ID of the project.
summary string The summary description of the project.
auto_add_role_name string The role automatically assigned to every new user added to the project.
show_project_members Boolean Whether project members can view a list of the other project members.

Resources

skytap_environment

Provides a Skytap environment resource. An environment consists of one or more virtual machines, networks, and associated settings and metadata. Unlike a template, an environment can be run and have most of its settings modified. When an environment is created, all of its VMs are run.

Example Usage
# Create a new environment
resource "skytap_environment" "environment" {
  template_id = "123456"
  name = "Terraform Example"
  description = "Skytap terraform provider example environment."
}
Argument Reference

The following arguments are supported:

Field Name Type Description
template_id integer (required, force new) ID of the template you want to create an environment from. If updating with a new one then the environment is recreated.
name string (required) User-defined name of the environment. Limited to 255 UTF-8 characters. Defaults to the name of the source template name if null is provided.
description string User-defined description of the environment. Limited to 1000 characters. Null allowed. UTF-8 character type.
outbound_traffic Boolean (optional) Indicates whether networks in the environment can send outbound traffic.
routable Boolean (optional) Indicates whether networks within the environment can route traffic to one another.
shutdown_on_idle integer (optional) The number of seconds an environment can be idle before it is automatically shut down. Valid range: 300 to 86400 seconds (5 minutes to 1 day).
shutdown_at_time datetime (optional) The date and time that the environment is automatically shut down. Format: yyyy/mm/dd hh:mm:ss. By default, the suspend time uses the UTC offset for the time zone defined in your user account settings.

Optionally, a different UTC offset can be supplied (for example: 2018/07/20 14:20:00 -0000). The value in the API response is converted to your time zone.

suspend_on_idle integer (optional) The number of seconds an environment can be idle before it is automatically suspended. Valid range: 300 to 86400 seconds (5 minutes to 1 day).
suspend_at_time datetime (optional) The date and time that the environment is automatically suspended. Format: yyyy/mm/dd hh:mm:ss. By default, the suspend time uses the UTC offset for the time zone defined in your user account settings. Optionally, a different UTC offset can be supplied (for example: 2018/07/20 14:20:00 -0000). The value in the API response is converted to your time zone.

Notes

  • If suspend_on_idle and suspend_at_time are both null, automatic suspend is disabled.
  • If shutdown_on_idle and shutdown_at_time are both null, automatic shut down is disabled.
  • An environment can’t be configured to use both automatic suspend and automatic shut down. Only one of the following settings can take effect: suspend_on_idle, suspend_at_time, shutdown_on_idle, or shutdown_at_time.
  • When you send a request that updates one of the four suspend or shutdown options, the other three options are automatically set to null by the REST API.
  • If multiple suspend or shut down options are sent in the same request, the suspend_type field determines which setting Skytap Cloud will honor.
Attributes Reference

The following attributes are exported:

Field Name Type Description
id integer The ID of the environment.

skytap_vm

Provides a Skytap Virtual Machine (VM) resource. The environment VM resource represents an image of a single virtual machine.

Notes

  • VMs exist only inside environments and templates.
  • An environment or template can have multiple VMs.
  • Each VM is a unique resource. A VM in a template will have a different ID than a VM in an environment created from that template.
  • The VM is run immediately after creation.
Example Usage
# Create a new vm
resource "skytap_vm" "vm" {
  template_id = 123
  vm_id = 456
  environment_id = 789
  name = "my vm"
}
Argument Reference

The following arguments are supported:

Field Name Type Description
environment_id integer (required, force new) ID of the environment you want to add the VM to. If updating with a new one then the VM is recreated.
template_id integer (required, force new) ID of the template you want to create the VM from. If updating with a new one then the VM is recreated.
vm_id integer (required, force new) ID of the VM you want to create the VM from. If updating with a new one then the VM is recreated.
name string (optional, computed) User-defined name. Limited to 100 characters.

The name is truncated to 33 UTF-8 characters after saving. If a name is not provided then the name of the source VM is used.

cpus integer (optional, computed) The number of CPUs allocated to this virtual machine. Valid range is 1 to 12. Maximum limit depends on the max_cpus setting.
ram integer (optional, computed) The amount of RAM (in MB) allocated to this virtual machine. Valid range is 256 to 131,072. Maximum limit depends on the max_ram setting.
os_disk_size integer (optional, computed) The size of the disk (in MiB—converted to GiB in the Skytap UI) that hosts the OS for this virtual machine. Maximum size is 2,096,128 MiB (1.999 TiB).
disk array (optional) Array of virtual disks (in MiB—converted to GiB in the Skytap UI) within the VM. Maximum combined size is 2,096,128 MiB (1.999 TiB).
Field NameTypeDescription
namestring(required) A unique name for the disk.

Disk names are truncated to 33 UTF-8 characters after saving. If a name is not provided then the name of the source VM is used.

sizeintegerThe size of the disk (in MiB—converted to GiB in the Skytap UI). Maximum size is 2,096,128 MiB (1.999 TiB).
network_interface array (optional, computed, force new) A Skytap network adapter is a virtualized network interface card (network adapter). It is logically contained in a VM and attached to a network.
Field NameTypeDescription
interface_typestring(required, force new) Type of network to which this network adapter is attached.
network_idinteger(required, force new) ID of the network to which this network adapter is attached.
ipIP v4 address(required, force new) The IP address (for example, 10.1.0.37). Skytap will not assign the same IP address to multiple interfaces on the same network.
hostnamestring(required, force new) Limited to 32 characters. Valid characters are lowercase letters, numbers, and hyphens. Can't begin or end with hyphens. Can't be gw.
published_service array (optional, force new) Generally, a published service represents a binding of a port on a network interface to an IP and port that is routable and accessible from the public Internet. This mechanism is used to selectively expose ports on the guest to the public Internet.

Published services exist and are managed as aspects of network interfaces—that is, as part of the overall environment element.

Field NameTypeDescription
internal_portstring(required, force new) The port that is exposed on the interface. Typically this is dictated by standard usage (e.g., port 80 for http traffic, port 22 for SSH).
Attributes Reference

The following attributes are exported:

Field Name Type Description
id integer The ID of the VM.
published_service array The published services.
Field NameTypeDescription
idintegerThe ID of the published service.
external_idintegerThe external ID of the published service.
external_portintegerThe external port of the published service.

skytap_network

Provides a Skytap network resource. Networks are not top-level elements of the Skytap API. They are elements properly contained within an environment. Operations on them are implicitly on the containing environment.

Example Usage
# Create a new network
resource "skytap_network" "network" {
  environment_id = "123456"
  name = "my network"
  domain = "domain.com"
  subnet = "1.2.3.4/16"
  gateway = "1.2.3.254"
  tunnelable = true
}
Argument Reference

The following arguments are supported:

Field Name Type Description
environment_id integer (required, force new) ID of the environment you want to attach the network to. If updating with a new one then the network is recreated.
name string (required) User-defined name of the network. Limited to 255 characters. UTF-8 character type.
domain string (required) Domain name for the Skytap network. Limited to 64 characters.

Valid characters are lowercase letters, numbers, and hyphens. Can't be blank, must not begin or end with a period, and must start and end with a letter or number. This field can be changed only when all virtual machines in the environment are stopped (not suspended or running).

subnet string (required) Defines the subnet address and subnet mask size in CIDR format (for example, 10.0.0.0/24). IP addresses for the VMs are assigned from this subnet and standard network services (DNS resolution, CIFS share, routes to Internet) are defined appropriately for it.

The subnet mask size must be between 16 and 30. Valid characters are lowercase letters, numbers, and hyphens. Can't be blank, must not begin or end with a period, and must start and end with a letter or number.

gateway string (optional, computed) Gateway IP address.
tunnelable Boolean (optional) If true, this network can be connected to other networks.
Attributes Reference

The following attributes are exported:

Field Name Type Description
id integer The ID of the network.

skytap_project

Provides a Skytap project resource. Projects are an access permissions model used to share environments, templates, and assets with other users.

Example Usage
# Create a new project
resource "skytap_project" "project" {
  name = "Terraform Example"
  summary = "Skytap terraform provider example project."
  show_project_members = false
  auto_add_role_name = "participant"
}
Argument Reference

The following arguments are supported:

Field Name Type Description
name string (required) User-defined project name.
summary string (optional) User-defined description of project.
auto_add_role_name string

(optional)

  • If this field is set to viewer, participant, editor, or manager, new users added to your Skytap account are automatically added to this project with the specified project role. Existing users aren’t affected by this setting.
  • If the field is set to null, new users aren’t automatically added to the project.

For additional details, see Automatically adding new users to a project.

show_project_members Boolean (optional) Determines whether projects members can view a list of other project members. The default value is false.
Attributes Reference

The following attributes are exported:

Field Name Type Description
id integer The ID of the project.