Skip to content
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Terraform Variables
*.tfvars

*.terraform.*
55 changes: 55 additions & 0 deletions Rigs/basic-tf/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
provider "azurerm" {
subscription_id = var.subscription_id
features {}
}

resource "azurerm_resource_group" "basic_rig_rg" {
name = format("Grover-%s",var.deployment_name)
location = var.location
}

module "network" {
source = "../modules/network"

address_space = var.address_space
default_subnet_cidr = var.default_subnet_cidr
location = var.location
deployment_name = var.deployment_name
}

module "loadbalancer" {
source ="../modules/loadbalancer"

location = var.location
resource_group_name = azurerm_resource_group.basic_rig_rg.name
deployment_name = var.deployment_name
}

module "vm" {
source ="../modules/virtualmachine"

location = var.location
resource_group_name = azurerm_resource_group.basic_rig_rg.name
vmcount = var.vmcount
Fault_Domain_Count = var.Fault_Domain_Count
Update_Domain_Count = var.Update_Domain_Count
adminuser = var.adminuser
adminpassword = var.adminpassword

image_publisher = var.image_publisher
image_offer = var.image_offer
image_sku = var.image_sku
image_version = var.image_version

vm_name_prefix = var.vm_name_prefix
vm_size = var.vm_size

vm_os_disk_name = var.vm_os_disk_name
vm_os_disk_caching = var.vm_os_disk_caching
vm_os_disk_create_option = var.vm_os_disk_create_option
vm_os_disk_managed_type = var.vm_os_disk_managed_type

network_subnet_id = module.network.subnet_instance_id
loadbalancer_beap_id = module.loadbalancer.lb_beap_id
deployment_name = var.deployment_name
}
79 changes: 79 additions & 0 deletions Rigs/basic-tf/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
variable "subscription_id" {
description = "the guid of the subscription"
}

variable "deployment_name" {
description = "The name to prefix the deployment"
}

variable "location" {
description = "The region location of the deployment."
}

variable "vmcount" {
description = "The number of vms to create"
}

variable "adminuser" {
description = "The admin username for the vm"
}

variable "adminpassword" {
description = "The password for the admin user"
}

variable "Fault_Domain_Count" {
description = "The number of fault domains"
}

variable "Update_Domain_Count" {
description = "The number of update domains"
}

variable "image_publisher" {
type = string
}

variable "image_offer" {
type = string
}

variable "image_sku" {
type = string
}

variable "image_version" {
type = string
}

variable "vm_name_prefix" {
type = string
}

variable "vm_size" {
type = string
}

variable "vm_os_disk_name" {
type = string
}

variable "vm_os_disk_caching" {
type = string
}

variable "vm_os_disk_create_option" {
type = string
}

variable "vm_os_disk_managed_type" {
type = string
}

variable "address_space" {
type = string
}

variable "default_subnet_cidr" {
type = string
}
28 changes: 28 additions & 0 deletions Rigs/modules/AzureSQL/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
resource "random_password" "DatabasePassword" {
length = 16
special = true
override_special = "_%@"
}

resource "azurerm_sql_server" "sqlserver" {
name = format("%ssqlserver",var.deployment_name)
resource_group_name = var.resource_group_name
location = var.location
version = "12.0"
administrator_login = var.serverLoginName
administrator_login_password = random_password.DatabasePassword.result
}

resource "azurerm_sql_database" "devsqldatabase" {
name = format("%sdatabase-dev",var.deployment_name)
resource_group_name = var.resource_group_name
location = var.location
server_name = azurerm_sql_server.sqlserver.name
}

resource "azurerm_sql_database" "prodsqldatabase" {
name = format("%sdatabase-prod",var.deployment_name)
resource_group_name = var.resource_group_name
location = var.location
server_name = azurerm_sql_server.sqlserver.name
}
15 changes: 15 additions & 0 deletions Rigs/modules/AzureSQL/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
output "DatabasePassword" {
value = random_password.DatabasePassword.result
}

output "DatabaseServerName" {
value = azurerm_sql_server.sqlserver.name
}

output "DatabaseName" {
value = azurerm_sql_database.devsqldatabase.name
}

output "DatabaseUserName" {
value = azurerm_sql_server.sqlserver.administrator_login
}
15 changes: 15 additions & 0 deletions Rigs/modules/AzureSQL/variable.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
variable "resource_group_name" {
type = string
}

variable "location" {
type = string
}

variable "serverLoginName" {
type = string
}

variable "deployment_name" {
type = string
}
61 changes: 61 additions & 0 deletions Rigs/modules/appservice/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
resource "azurerm_app_service_plan" "asp" {
name = format("Grover-%s-asp",var.deployment_name)
location = var.location
resource_group_name = var.resource_group_name

sku {
tier = "Standard"
size = "S1"
}

}

resource "azurerm_app_service" "as" {
name = format("Grover-%s-as",var.deployment_name)
location = var.location
resource_group_name = var.resource_group_name
app_service_plan_id = azurerm_app_service_plan.asp.id

site_config {
dotnet_framework_version = "v4.0"
scm_type = "LocalGit"
}

connection_string {
name = "Database"
type = "SQLServer"
value = var.connection_string
}
}

resource "random_id" "server" {
keepers = {
azi_id = 1
}

byte_length = 8
}

resource "azurerm_app_service_slot" "prod" {
name = format("Grover-%s-%s-prod",var.deployment_name,random_id.server.hex)
app_service_name = azurerm_app_service.as.name
location = var.location
resource_group_name = var.resource_group_name
app_service_plan_id = azurerm_app_service_plan.asp.id

site_config {
dotnet_framework_version = "v4.0"
}

connection_string {
name = "Database"
type = "SQLServer"
value = var.connection_string
}
}

resource "azurerm_app_service_active_slot" "activeslot" {
resource_group_name = var.resource_group_name
app_service_name = azurerm_app_service.as.name
app_service_slot_name = azurerm_app_service_slot.prod.name
}
15 changes: 15 additions & 0 deletions Rigs/modules/appservice/variable.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
variable "resource_group_name" {
type = string
}

variable "location" {
type = string
}

variable "connection_string" {
type = string
}

variable "deployment_name" {
type = string
}
24 changes: 24 additions & 0 deletions Rigs/modules/loadbalancer/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
resource "azurerm_public_ip" "basic_rig_pip" {
name = format("Grover-%s-lb-pip",var.deployment_name)
location = var.location
resource_group_name = var.resource_group_name
allocation_method = "Static"
}

resource "azurerm_lb" "basic_rig_lb" {
name = format("Grover-%s-loadBalancer",var.deployment_name)
location = var.location
resource_group_name = var.resource_group_name

frontend_ip_configuration {
name = "lbpip"
public_ip_address_id = azurerm_public_ip.basic_rig_pip.id
}
}

resource "azurerm_lb_backend_address_pool" "basic_rig_lb_beap" {
resource_group_name = var.resource_group_name
loadbalancer_id = azurerm_lb.basic_rig_lb.id
name = "beap"
}

3 changes: 3 additions & 0 deletions Rigs/modules/loadbalancer/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "lb_beap_id" {
value = azurerm_lb_backend_address_pool.basic_rig_lb_beap.id
}
11 changes: 11 additions & 0 deletions Rigs/modules/loadbalancer/variable.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
variable "location" {
type = string
}

variable "resource_group_name" {
type = string
}

variable "deployment_name" {
type = string
}
19 changes: 19 additions & 0 deletions Rigs/modules/network/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resource "azurerm_resource_group" "basic_rig_network_rg" {
name = format("Grover-%s-Network",var.deployment_name)
location = var.location
}

resource "azurerm_virtual_network" "basic_rig_vnet" {
name = format("Grover-%s-vnet",var.deployment_name)
address_space = [var.address_space]
location = azurerm_resource_group.basic_rig_network_rg.location
resource_group_name = azurerm_resource_group.basic_rig_network_rg.name
}

resource "azurerm_subnet" "basic_rig_subnet" {
name = format("Grover-%s-subnet",var.deployment_name)
resource_group_name = azurerm_resource_group.basic_rig_network_rg.name
virtual_network_name = azurerm_virtual_network.basic_rig_vnet.name
address_prefix = var.default_subnet_cidr
}

11 changes: 11 additions & 0 deletions Rigs/modules/network/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
output "name" {
value = "BackendNetwork"
}

output "subnet_instance_id" {
value = azurerm_subnet.basic_rig_subnet.id
}

output "networkrg_name" {
value = azurerm_resource_group.basic_rig_network_rg.name
}
17 changes: 17 additions & 0 deletions Rigs/modules/network/variable.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
variable "address_space" {
type = string
default = "10.0.0.0/16"
}

variable "default_subnet_cidr" {
type = string
default = "10.0.2.0/24"
}

variable "location" {
type = string
}

variable "deployment_name" {
type = string
}
Loading