first commit

This commit is contained in:
Neil Borromeo 2022-05-30 17:37:50 +08:00
commit 2660f55733
3 changed files with 248 additions and 0 deletions

View file

@ -0,0 +1 @@
# Place for terraform code for Azure

84
terraform/azure/main.tf Normal file
View file

@ -0,0 +1,84 @@
terraform {
required_version = ">=0.12"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>2.0"
}
}
}
resource "azurerm_resource_group" "resource_gp" {
name = "terraRG"
location = "southeastasia"
tags = {
Owner = "Elvi"
}
}
variable "prefix" {
default = "lv"
}
resource "azurerm_virtual_network" "main" {
name = "${var.prefix}-network"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.resource_gp.location
resource_group_name = azurerm_resource_group.resource_gp.name
}
resource "azurerm_subnet" "internal" {
name = "internal"
resource_group_name = azurerm_resource_group.resource_gp.name
virtual_network_name = azurerm_virtual_network.main.name
address_prefixes = ["10.0.2.0/24"]
}
resource "azurerm_network_interface" "main" {
name = "${var.prefix}-nic"
location = azurerm_resource_group.resource_gp.location
resource_group_name = azurerm_resource_group.resource_gp.name
ip_configuration {
name = "testconfiguration1"
subnet_id = azurerm_subnet.internal.id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_virtual_machine" "main" {
name = "${var.prefix}-vm"
location = azurerm_resource_group.resource_gp.location
resource_group_name = azurerm_resource_group.resource_gp.name
network_interface_ids = [azurerm_network_interface.main.id]
vm_size = "Standard_DS1_v2"
storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
version = "latest"
}
storage_os_disk {
name = "testdisk01"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
os_profile {
computer_name = "test-pc"
admin_username = "testadmin"
admin_password = "Password1234!"
}
os_profile_linux_config {
disable_password_authentication = false
}
tags = {
Owner = "Elvi"
}
}

View file

@ -0,0 +1,24 @@
provider "azurerm"{
subscription_id = var.subscription_id
client_id = var.client_id
client_secret = var.client_secret
tenant_id = var.tenant_id
features {}
}
variable "subscription_id"{
description = "Enter Subscription ID "
}
variable "client_id"{
description = "Enter Client ID "
}
variable "client_secret"{
description = "Enter Client Secret "
}
variable "tenant_id"{
description = "Enter Tenant ID"
}