2015-05-18 15:40:45 +02:00
|
|
|
---
|
|
|
|
layout: "azure"
|
|
|
|
page_title: "Azure: azure_instance"
|
|
|
|
sidebar_current: "docs-azure-resource-instance"
|
|
|
|
description: |-
|
2015-05-29 00:10:21 +02:00
|
|
|
Creates a hosted service, role and deployment and then creates a virtual machine in the deployment based on the specified configuration.
|
2015-05-18 15:40:45 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
# azure\_instance
|
|
|
|
|
2015-06-26 14:48:55 +02:00
|
|
|
Creates a hosted service, role and deployment and then creates a virtual
|
2015-05-29 00:10:21 +02:00
|
|
|
machine in the deployment based on the specified configuration.
|
2015-05-18 15:40:45 +02:00
|
|
|
|
|
|
|
## Example Usage
|
|
|
|
|
2017-04-17 12:17:54 +02:00
|
|
|
```hcl
|
2015-06-26 14:48:55 +02:00
|
|
|
resource "azure_hosted_service" "terraform-service" {
|
2017-02-18 23:48:50 +01:00
|
|
|
name = "terraform-service"
|
|
|
|
location = "North Europe"
|
|
|
|
ephemeral_contents = false
|
|
|
|
description = "Hosted service created by Terraform."
|
|
|
|
label = "tf-hs-01"
|
2015-06-26 14:48:55 +02:00
|
|
|
}
|
|
|
|
|
2015-05-18 15:40:45 +02:00
|
|
|
resource "azure_instance" "web" {
|
2017-02-18 23:48:50 +01:00
|
|
|
name = "terraform-test"
|
|
|
|
hosted_service_name = "${azure_hosted_service.terraform-service.name}"
|
|
|
|
image = "Ubuntu Server 14.04 LTS"
|
|
|
|
size = "Basic_A1"
|
|
|
|
storage_service_name = "yourstorage"
|
|
|
|
location = "West US"
|
|
|
|
username = "terraform"
|
|
|
|
password = "Pass!admin123"
|
|
|
|
domain_name = "contoso.com"
|
|
|
|
domain_ou = "OU=Servers,DC=contoso.com,DC=Contoso,DC=com"
|
|
|
|
domain_username = "Administrator"
|
|
|
|
domain_password = "Pa$$word123"
|
|
|
|
|
|
|
|
endpoint {
|
|
|
|
name = "SSH"
|
|
|
|
protocol = "tcp"
|
|
|
|
public_port = 22
|
|
|
|
private_port = 22
|
|
|
|
}
|
2015-05-18 15:40:45 +02:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
The following arguments are supported:
|
|
|
|
|
|
|
|
* `name` - (Required) The name of the instance. Changing this forces a new
|
|
|
|
resource to be created.
|
|
|
|
|
2015-06-26 14:48:55 +02:00
|
|
|
* `hosted_service_name` - (Optional) The name of the hosted service the
|
|
|
|
instance should be deployed under. If not provided; it will default to the
|
|
|
|
value of `name`. Changes to this parameter forces the creation of a new
|
|
|
|
resource.
|
|
|
|
|
2015-05-29 00:10:21 +02:00
|
|
|
* `description` - (Optional) The description for the associated hosted service.
|
|
|
|
Changing this forces a new resource to be created (defaults to the instance
|
|
|
|
name).
|
2015-05-18 15:40:45 +02:00
|
|
|
|
2015-05-29 00:10:21 +02:00
|
|
|
* `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.
|
2015-05-18 15:40:45 +02:00
|
|
|
|
2015-05-29 00:10:21 +02:00
|
|
|
* `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.
|
|
|
|
|
2015-06-11 20:27:26 +02:00
|
|
|
* `storage_service_name` - (Optional) The name of an existing storage account
|
|
|
|
within the subscription which will be used to store the VHDs of this
|
2015-07-27 17:22:35 +02:00
|
|
|
instance. Changing this forces a new resource to be created. **A Storage
|
|
|
|
Service is required if you are using a Platform Image**
|
2015-05-18 15:40:45 +02:00
|
|
|
|
2015-05-29 00:10:21 +02:00
|
|
|
* `reverse_dns` - (Optional) The DNS address to which the IP address of the
|
|
|
|
hosted service resolves when queried using a reverse DNS query. Changing
|
2015-05-18 15:40:45 +02:00
|
|
|
this forces a new resource to be created.
|
|
|
|
|
2015-05-29 00:10:21 +02:00
|
|
|
* `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.
|
2015-05-18 15:40:45 +02:00
|
|
|
|
2015-05-29 00:10:21 +02:00
|
|
|
* `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.
|
2015-05-18 15:40:45 +02:00
|
|
|
Changing this forces a new resource to be created.
|
|
|
|
|
2015-05-29 00:10:21 +02:00
|
|
|
* `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.
|
|
|
|
|
2015-09-08 16:53:52 +02:00
|
|
|
* `domain_name` - (Optional) The name of an Active Directory domain to join.
|
|
|
|
|
2017-02-18 23:48:50 +01:00
|
|
|
* `domain_ou` - (Optional) Specifies the LDAP Organizational Unit to place the
|
2015-09-08 16:53:52 +02:00
|
|
|
instance in.
|
|
|
|
|
|
|
|
* `domain_username` - (Optional) The username of an account with permission to
|
|
|
|
join the instance to the domain. Required if a domain_name is specified.
|
|
|
|
|
|
|
|
* `domain_password` - (Optional) The password for the domain_username account
|
|
|
|
specified above.
|
|
|
|
|
2016-08-14 12:02:49 +02:00
|
|
|
* `custom_data` - (Optional) The custom data to provide when launching the
|
|
|
|
instance.
|
2015-09-08 16:53:52 +02:00
|
|
|
|
2015-05-29 00:10:21 +02:00
|
|
|
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.
|
2015-05-18 15:40:45 +02:00
|
|
|
|
2015-05-29 00:10:21 +02:00
|
|
|
* `private_port` - (Required) The private port on which the instance is
|
|
|
|
listening.
|
2015-05-18 15:40:45 +02:00
|
|
|
|
|
|
|
## Attributes Reference
|
|
|
|
|
|
|
|
The following attributes are exported:
|
|
|
|
|
|
|
|
* `id` - The instance ID.
|
2015-05-29 00:10:21 +02:00
|
|
|
* `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.
|