terraform/website/source/docs/providers/azure/r/instance.html.markdown

4.4 KiB

layout page_title sidebar_current description
azure Azure: azure_instance docs-azure-resource-instance Creates a hosted service, role and deployment and then creates a virtual machine in the deployment based on the specified configuration.

azure_instance

Creates a hosted service, role and deployment and then creates a virtual machine in the deployment based on the specified configuration.

Example Usage

resource "azure_instance" "web" {
    name = "terraform-test"
    image = "Ubuntu Server 14.04 LTS"
    size = "Basic_A1"
    storage_service_name = "yourstorage"
    location = "West US"
    username = "terraform"
    password = "Pass!admin123"

    endpoint {
        name = "SSH"
        protocol = "tcp"
        public_port = 22
        private_port = 22
    }
}

Argument Reference

The following arguments are supported:

  • name - (Required) The name of the instance. Changing this forces a new resource to be created.

  • description - (Optional) The description for the associated hosted service. Changing this forces a new resource to be created (defaults to the instance name).

  • image - (Required) The name of an existing VM or OS image to use for this instance. Changing this forces a new resource to be created.

  • size - (Required) The size of the instance.

  • subnet - (Optional) The name of the subnet to connect this instance to. If a value is supplied virtual_network is required. Changing this forces a new resource to be created.

  • virtual_network - (Optional) The name of the virtual network the subnet belongs to. If a value is supplied subnet is required. Changing this forces a new resource to be created.

  • storage_service_name - (Optional) The name of an existing storage account within the subscription which will be used to store the VHDs of this instance. Changing this forces a new resource to be created.

  • reverse_dns - (Optional) The DNS address to which the IP address of the hosted service resolves when queried using a reverse DNS query. Changing this forces a new resource to be created.

  • location - (Required) The location/region where the cloud service is created. Changing this forces a new resource to be created.

  • automatic_updates - (Optional) If true this will enable automatic updates. This attribute is only used when creating a Windows instance. Changing this forces a new resource to be created (defaults false)

  • time_zone - (Optional) The appropriate time zone for this instance in the format 'America/Los_Angeles'. This attribute is only used when creating a Windows instance. Changing this forces a new resource to be created (defaults false)

  • username - (Required) The username of a new user that will be created while creating the instance. Changing this forces a new resource to be created.

  • password - (Optional) The password of the new user that will be created while creating the instance. Required when creating a Windows instance or when not supplying an ssh_key_thumbprint while creating a Linux instance. Changing this forces a new resource to be created.

  • ssh_key_thumbprint - (Optional) The SSH thumbprint of an existing SSH key within the subscription. This attribute is only used when creating a Linux instance. Changing this forces a new resource to be created.

  • security_group - (Optional) The Network Security Group to associate with this instance.

  • endpoint - (Optional) Can be specified multiple times to define multiple endpoints. Each endpoint block supports fields documented below.

The endpoint block supports:

  • name - (Required) The name of the external endpoint.

  • protocol - (Optional) The transport protocol for the endpoint. Valid options are: tcp and udp (defaults tcp)

  • public_port - (Required) The external port to use for the endpoint.

  • private_port - (Required) The private port on which the instance is listening.

Attributes Reference

The following attributes are exported:

  • id - The instance ID.
  • description - The description for the associated hosted service.
  • subnet - The subnet the instance is connected to.
  • endpoint - The complete set of configured endpoints.
  • security_group - The associated Network Security Group.
  • ip_address - The private IP address assigned to the instance.
  • vip_address - The public IP address assigned to the instance.