provider "azurerm" {
subscription_id = "XXXXXXXXXXXXXXXXXXXXX"
client_id = "XXXXXXXXXXXXXXXXXXXxx"
client_secret = "XXXXXXXXXXXXXX"
tenant_id = "XXXXXXXXXXXXXXXXXXXXX"
}
# create a resource group
resource "azurerm_resource_group" "dhanesh-rs" {
name = "terraformtest"
location = "Southeast Asia"
}
resource "azurerm_virtual_network" "dhanesh-net"{
address_space = ["10.0.0.0/16"]
location = "Southeast Asia"
name = "dhanesh-net"
resource_group_name = "${azurerm_resource_group.dhanesh-rs.name}"
}
resource "azurerm_subnet" "dhanesh-sub" {
address_prefix = "10.0.2.0/24"
name = "dhanesh-sub"
resource_group_name = "${azurerm_resource_group.dhanesh-rs.name}"
virtual_network_name = "${azurerm_virtual_network.dhanesh-net.name}"
}
resource "azurerm_network_interface" "dhanesh-if" {
location = "Southeast Asia"
name = "dhanesh-if"
resource_group_name = "${azurerm_resource_group.dhanesh-rs.name}"
"ip_configuration" {
name = "dhanesh-ifip"
private_ip_address_allocation = "dynamic"
subnet_id = "${azurerm_subnet.dhanesh-sub.id}"
}
}
resource "azurerm_availability_set" "dhanesh-as" {
name = "dhanesh-az"
location = "Southeast Asia"
resource_group_name = "${azurerm_resource_group.dhanesh-rs.name}"
tags{
environment="production"
}
}
resource "azurerm_storage_account" dhanesh-ds {
name = "dhaneshds"
account_type = "Standard_LRS"
location = "Southeast Asia"
resource_group_name = "${azurerm_resource_group.dhanesh-rs.name}"
tags {
environment ="production"
}
}
resource "azurerm_storage_container" "dhansh-sc" {
name = "dhanesh-sc"
resource_group_name = "${azurerm_resource_group.dhanesh-rs.name}"
storage_account_name = "${azurerm_storage_account.dhanesh-ds.name}"
container_access_type = "private"
}
resource "azurerm_virtual_machine" "dhanesh-vm" {
name = "dhaneshvm"
location = "Southeast Asia"
resource_group_name = "${azurerm_resource_group.dhanesh-rs.name}"
network_interface_ids = ["${azurerm_network_interface.dhanesh-if.id}"]
vm_size = "Standard_A0"
storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "14.04.2-LTS"
version = "latest"
}
storage_os_disk {
name ="myosdisk"
vhd_uri = "${azurerm_storage_account.dhanesh-ds.primary_blob_endpoint}${azurerm_storage_container.dhansh-sc.name}/myos.vhd"
caching = "ReadWrite"
create_option = "FromImage"
}
os_profile {
admin_password = "Dhanesh@1234567"
admin_username = "dhanesh"
computer_name = "dhanesh-vm"
}
os_profile_linux_config {
disable_password_authentication = false
}
tags {
environment = "production"
}
}
No comments:
Post a Comment