terraform/examples/azure-vm-simple-linux-manag.../main.tf

108 lines
3.4 KiB
Terraform
Raw Normal View History

# provider "azurerm" {
# subscription_id = "REPLACE-WITH-YOUR-SUBSCRIPTION-ID"
# client_id = "REPLACE-WITH-YOUR-CLIENT-ID"
# client_secret = "REPLACE-WITH-YOUR-CLIENT-SECRET"
# tenant_id = "REPLACE-WITH-YOUR-TENANT-ID"
# }
2017-04-17 22:46:01 +02:00
resource "azurerm_resource_group" "rg" {
name = "${var.resource_group}"
location = "${var.location}"
}
resource "azurerm_virtual_network" "vnet" {
name = "${var.virtual_network_name}"
location = "${var.location}"
address_space = ["${var.address_space}"]
resource_group_name = "${azurerm_resource_group.rg.name}"
}
resource "azurerm_subnet" "subnet" {
name = "${var.rg_prefix}subnet"
virtual_network_name = "${azurerm_virtual_network.vnet.name}"
resource_group_name = "${azurerm_resource_group.rg.name}"
address_prefix = "${var.subnet_prefix}"
}
resource "azurerm_network_interface" "nic" {
2017-04-24 18:45:24 +02:00
name = "${var.rg_prefix}nic"
location = "${var.location}"
resource_group_name = "${azurerm_resource_group.rg.name}"
2017-04-17 22:46:01 +02:00
ip_configuration {
name = "${var.rg_prefix}ipconfig"
subnet_id = "${azurerm_subnet.subnet.id}"
private_ip_address_allocation = "Dynamic"
public_ip_address_id = "${azurerm_public_ip.pip.id}"
}
}
resource "azurerm_public_ip" "pip" {
name = "${var.rg_prefix}-ip"
location = "${var.location}"
resource_group_name = "${azurerm_resource_group.rg.name}"
public_ip_address_allocation = "Dynamic"
2017-04-17 22:46:01 +02:00
domain_name_label = "${var.dns_name}"
}
resource "azurerm_storage_account" "stor" {
name = "${var.dns_name}stor"
2017-04-17 22:46:01 +02:00
location = "${var.location}"
resource_group_name = "${azurerm_resource_group.rg.name}"
account_type = "${var.storage_account_type}"
}
resource "azurerm_managed_disk" "datadisk" {
name = "${var.hostname}-datadisk"
2017-04-17 22:46:01 +02:00
location = "${var.location}"
resource_group_name = "${azurerm_resource_group.rg.name}"
storage_account_type = "Standard_LRS"
create_option = "Empty"
disk_size_gb = "1023"
}
resource "azurerm_virtual_machine" "vm" {
name = "${var.rg_prefix}vm"
location = "${var.location}"
resource_group_name = "${azurerm_resource_group.rg.name}"
vm_size = "${var.vm_size}"
network_interface_ids = ["${azurerm_network_interface.nic.id}"]
storage_image_reference {
publisher = "${var.image_publisher}"
offer = "${var.image_offer}"
sku = "${var.image_sku}"
version = "${var.image_version}"
}
storage_os_disk {
name = "${var.hostname}-osdisk"
managed_disk_type = "Standard_LRS"
caching = "ReadWrite"
create_option = "FromImage"
2017-04-17 22:46:01 +02:00
}
storage_data_disk {
name = "${var.hostname}-datadisk"
managed_disk_id = "${azurerm_managed_disk.datadisk.id}"
managed_disk_type = "Standard_LRS"
disk_size_gb = "1023"
create_option = "Attach"
lun = 0
2017-04-17 22:46:01 +02:00
}
os_profile {
computer_name = "${var.hostname}"
admin_username = "${var.admin_username}"
admin_password = "${var.admin_password}"
}
os_profile_linux_config {
disable_password_authentication = false
}
2017-04-17 22:46:01 +02:00
boot_diagnostics {
enabled = true
2017-04-17 22:46:01 +02:00
storage_uri = "${azurerm_storage_account.stor.primary_blob_endpoint}"
}
provider/azurerm: Add example of CDN with Storage Account (#14193) * initial commit - 101-vm-from-user-image * changed branch name * not deploying - storage problems * provisions vm but image not properly prepared * storage not correct * provisions properly * changed main.tf to azuredeploy.tf * added tfvars and info for README * tfvars ignored and corrected file ext * added CI config; added sane defaults for variables; updated deployment script, added mac specific deployment for local testing * deploy.sh to be executable * executable deploy files * added CI files; changed vars * prep for PR * removal of old folder * prep for PR * wrong args for travis * more PR prep * updated README * commented out variables in terraform.tfvars * Topic 101 vm from user image (#2) * initial commit - 101-vm-from-user-image * added tfvars and info for README * added CI config; added sane defaults for variables; updated deployment script, added mac specific deployment for local testing * prep for PR * added new template * oops, left off master * prep for PR * correct repository for destination * renamed scripts to be more intuitive; added check for docker * merge vm simple; vm from image * initial commit * deploys locally * updated deploy * changed to allow http & https (like ARM tmplt) * changed host_name & host_name variable desc * prep for PR * took out armviz button and minor README changes * changed host_name * fixed merge conflicts * changed host_name variable * updating Hashicorp's changes to merged simple linux branch * updating files to merge w/master and prep for Hashicorp pr * reverted to Hashicorp's .travis.yml * terraform graph * removing pending example * cleaned up deploy.ci.sh
2017-05-04 15:28:04 +02:00
}