Skip to content

Commit

Permalink
Added terraform definitions for known resources.
Browse files Browse the repository at this point in the history
- Apparently Azure stuff is all-too-fragile and I had to create both
Cosmos DB and PostgreSQL twice.
- See: hashicorp/terraform-provider-azurerm#3813
  • Loading branch information
lemvik committed Aug 24, 2019
1 parent 3dffa4a commit 752c97e
Show file tree
Hide file tree
Showing 12 changed files with 2,437 additions and 2,315 deletions.
7 changes: 7 additions & 0 deletions infra/bus-topic.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "azurerm_servicebus_topic" "chat-app" {
name = "chat-app-coordination-topic"
resource_group_name = "${azurerm_resource_group.chat-app.name}"
namespace_name = "${azurerm_servicebus_namespace.chat-app.name}"

enable_partitioning = true
}
21 changes: 21 additions & 0 deletions infra/cosmos-db.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
resource "azurerm_cosmosdb_account" "messages-db" {
name = "chat-app-account"
location = "${azurerm_resource_group.chat-app.location}"
resource_group_name = "${azurerm_resource_group.chat-app.name}"
offer_type = "Standard"
kind = "GlobalDocumentDB"

enable_automatic_failover = false

consistency_policy {
consistency_level = "BoundedStaleness"
max_interval_in_seconds = 10
max_staleness_prefix = 200
}

geo_location {
prefix = "chat-app-account"
location = "${azurerm_resource_group.chat-app.location}"
failover_priority = 0
}
}
10 changes: 10 additions & 0 deletions infra/namespace.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "azurerm_servicebus_namespace" "chat-app" {
name = "chat-app-namespace"
location = "${azurerm_resource_group.chat-app.location}"
resource_group_name = "${azurerm_resource_group.chat-app.name}"
sku = "Standard"

tags = {
source = "terraform"
}
}
6 changes: 6 additions & 0 deletions infra/network.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "azurerm_virtual_network" "chat-app" {
name = "chat-app-network"
resource_group_name = "${azurerm_resource_group.chat-app.name}"
location = "${azurerm_resource_group.chat-app.location}"
address_space = ["10.0.0.0/16"]
}
3 changes: 3 additions & 0 deletions infra/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "azurerm" {
version = "1.33.0"
}
4 changes: 4 additions & 0 deletions infra/resources.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "azurerm_resource_group" "chat-app" {
name = "chat-app"
location = "North Europe"
}
17 changes: 17 additions & 0 deletions infra/service-fabric.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resource "azurerm_service_fabric_cluster" "chat-app" {
name = "chat-app-cluster"
resource_group_name = "${azurerm_resource_group.chat-app.name}"
location = "${azurerm_resource_group.chat-app.location}"
reliability_level = "Bronze"
upgrade_mode = "Automatic"
vm_image = "Linux"
management_endpoint = "https://chat-app.cloudapp.net:19080"

node_type {
name = "chats"
instance_count = 3
is_primary = true
client_endpoint_port = 2020
http_endpoint_port = 80
}
}
23 changes: 23 additions & 0 deletions infra/sql-storage.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
resource "azurerm_postgresql_server" "chat-app" {
name = "postgresql-server-1"
location = "${azurerm_resource_group.chat-app.location}"
resource_group_name = "${azurerm_resource_group.chat-app.name}"

sku {
name = "B_Gen5_2"
capacity = 2
tier = "Basic"
family = "Gen5"
}

storage_profile {
storage_mb = 5120
backup_retention_days = 7
geo_redundant_backup = "Disabled"
}

administrator_login = "psqladmin"
administrator_login_password = "T0o$ecret7oo$ecure7oo4urious"
version = "10"
ssl_enforcement = "Enabled"
}
Loading

0 comments on commit 752c97e

Please sign in to comment.