Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Damilola #12

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions NEWAZA/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
provider "azurerm" {
version = "2.0.0"
subscription_id = var.subscriptionID

features {}
}

resource "azurerm_resource_group" "main" {
name = var.rgName
location = var.location
}

resource "azurerm_virtual_network" "main" {
name = "guanaVnet"
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
address_space = ["10.0.0.0/16"]
}

resource "azurerm_subnet" "main" {
name = "guanaSubnet"
resource_group_name = azurerm_resource_group.main.name
virtual_network_name = azurerm_virtual_network.main.name
address_prefix = "10.0.1.0/24"
}

resource "azurerm_public_ip" "mypublicIP" {
name = var.publicIP
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
allocation_method = "Static"
ip_version = "IPv4"
}

resource "azurerm_network_security_group" "main" {
name = "mysecureNSG"
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name

security_rule {
name = "RDP"
priority = 100
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "3389"
source_address_prefix = "*"
destination_address_prefix = "*"
}

resource "azurerm_virtual_machine" "main" {
name = "DEVOPS"
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
network_interface_ids = ["${var.network_interface_id}"]
vm_size = "Standard_DS1_v2"

# Uncomment this line to delete the OS disk automatically when deleting the VM
delete_os_disk_on_termination = true

storage_image_reference {
publisher = "MicrosoftWindowsServer"
offer = "WindowsServer"
sku = "2016-Datacenter "
version = "latest"
}

storage_os_disk {
name = "disk1"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}

os_profile {
computer_name = "DEVOPS"
admin_username = "azureuser"
admin_password = "W3lcomeWorld12!!"
}

tags = {
environment = "staging"
}
}
5 changes: 5 additions & 0 deletions NEWAZA/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
subscriptionID = "bce7717f-edf5-4ca0-8940-a972b94e586a"
rgName = "DEVOPS2"
location = "eastus"
publicIP = "Guana"
network_interface_id = "/subscriptions/bce7717f-edf5-4ca0-8940-a972b94e586a/resourceGroups/DEVOPS2/providers/Microsoft.Network/networkInterfaces/GuanaNIC"
23 changes: 23 additions & 0 deletions NEWAZA/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
variable "subscriptionID" {
type = string
description = "Variable for our resource group"
}

variable "rgName" {
type = string
description = "name of resource group"
}

variable "location" {
type = string
description = "location of your resource group"
}

variable "network_interface_id" {
type = string
}

variable "publicIP" {
type = string
description = "name of Pubic IP"
}