Skip to content

Commit

Permalink
Terraform: AKS Cluster Test
Browse files Browse the repository at this point in the history
  • Loading branch information
blastomussa committed Sep 10, 2022
1 parent df08d59 commit 447614b
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ tests/*
terraform/variables.tf
*/.terraform*
*/terraform.*
terraform.tfvars

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
46 changes: 46 additions & 0 deletions aks-cluster.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
terraform {
required_version = ">= 1.2"
required_providers {
azurerm = {
version = "~> 3.22.0"
}
}
}

# Azure Resource Manager provider
provider "azurerm" {
features {}
subscription_id = var.subscription_id
skip_provider_registration = true
}

# Create Resource Group
resource "azurerm_resource_group" "rg" {
name = var.resource_group_name
location = var.resource_group_location
}

resource "azurerm_kubernetes_cluster" "k8s" {
name = "${random_pet.prefix.id}-aks"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
dns_prefix = "${random_pet.prefix.id}-k8s"

default_node_pool {
name = "default"
node_count = 2
vm_size = "Standard_D2_v2"
os_disk_size_gb = 30
}

service_principal {
client_id = var.appId
client_secret = var.password
}

role_based_access_control_enabled = true

tags = {
environment = "Demo"
}
}
4 changes: 2 additions & 2 deletions frontend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def button():
'user': user,
'time': time
}
mongo(user_data) ######TESTING THIS
mongo(user_data) ######WORKS BUT NEEDS BETTER DATA
return redirect(url_for('success'))


Expand Down Expand Up @@ -72,7 +72,7 @@ def mongo(data):

db = client[DB_NAME]

collection = db.test_collection ### THIS IS FUCKING UP; how do i use variable
collection = db.test_collection ### how do i use variable after dot(.)
document_id = insert_document(collection, data)

if __name__ == '__main__':
Expand Down
7 changes: 7 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
variable "appId" {
description = "Azure Kubernetes Service Cluster service principal"
}

variable "password" {
description = "Azure Kubernetes Service Cluster password"
}

0 comments on commit 447614b

Please sign in to comment.