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

feat: moves to using Alias A records for Azure App #134

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 0 additions & 9 deletions azurerm/modules/azurerm-cosmosdb/constraints.tf

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
data "azurerm_client_config" "current" {}

module "default_label" {
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=0.16.0"
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=0.25.0"
namespace = "${var.name_company}-${var.name_project}"
stage = var.stage
name = "${lookup(var.location_name_map, var.resource_group_location, "uksouth")}-${var.name_component}"
name = "${lookup(var.location_name_map, var.resource_group_location, "westeurope")}-${var.name_component}"
attributes = var.attributes
delimiter = "-"
tags = var.tags
Expand All @@ -24,10 +24,6 @@ module "cosmosdb" {
source = "../../"
create_cosmosdb = true
resource_namer = module.default_label.id
name_environment = "dev-feature"
name_project = var.name_project
name_company = var.name_company
name_component = var.name_component
resource_group_name = azurerm_resource_group.default.name
cosmosdb_sql_container = "Menu"
cosmosdb_sql_container_partition_key = "/id"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
terraform {
backend "azurerm" {
}
# Uncomment if you want a non-local backend
# backend "azurerm" {
# }
}

provider "azurerm" {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
############################################
# NAMING
############################################

variable "name_company" {
type = string

default = "example"
}

variable "name_project" {
type = string

default = "stacks"
}

variable "name_component" {
type = string

default = "cosmos"
}

variable "name_environment" {
type = string

default = "nonprod"
}

variable "stage" {
type = string

default = "dev"
}

variable "attributes" {
default = []
}

variable "tags" {
type = map(string)

default = {}
}

############################################
# RESOURCE INFORMATION
############################################
variable "resource_group_location" {
type = string
default = "westeurope"
}

# Each region must have corresponding a shortend name for resource naming purposes
variable "location_name_map" {
type = map(string)

default = {
northeurope = "eun"
westeurope = "euw"
uksouth = "uks"
ukwest = "ukw"
eastus = "use"
eastus2 = "use2"
westus = "usw"
eastasia = "ase"
southeastasia = "asse"
}
}
109 changes: 0 additions & 109 deletions azurerm/modules/azurerm-cosmosdb/examples/existing-rg-cosmosdb/vars.tf

This file was deleted.

This file was deleted.

15 changes: 9 additions & 6 deletions azurerm/modules/azurerm-cosmosdb/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
##################################################

resource "azurerm_cosmosdb_account" "default" {
count = var.create_cosmosdb ? 1 : 0
count = var.create_cosmosdb ? 1 : 0

name = var.resource_namer
resource_group_name = var.resource_group_name
location = var.resource_group_location
offer_type = var.cosmosdb_offer_type
kind = var.cosmosdb_kind

enable_automatic_failover = true
automatic_failover_enabled = true

consistency_policy {
consistency_level = "BoundedStaleness"
Expand All @@ -22,6 +23,7 @@ resource "azurerm_cosmosdb_account" "default" {
location = var.resource_group_location
failover_priority = 0
}

tags = var.resource_tags
lifecycle {
ignore_changes = [
Expand All @@ -31,18 +33,19 @@ resource "azurerm_cosmosdb_account" "default" {
}

resource "azurerm_cosmosdb_sql_database" "default" {
count = var.create_cosmosdb ? 1 : 0
count = var.create_cosmosdb ? 1 : 0

name = var.resource_namer
resource_group_name = azurerm_cosmosdb_account.default.0.resource_group_name
account_name = azurerm_cosmosdb_account.default.0.name
}

# TODO: make this an array of maps
resource "azurerm_cosmosdb_sql_container" "default" {
count = var.create_cosmosdb ? 1 : 0
count = var.create_cosmosdb ? 1 : 0

name = var.cosmosdb_sql_container
resource_group_name = azurerm_cosmosdb_account.default.0.resource_group_name
account_name = azurerm_cosmosdb_account.default.0.name
database_name = azurerm_cosmosdb_sql_database.default.0.name
partition_key_path = var.cosmosdb_sql_container_partition_key
partition_key_paths = [var.cosmosdb_sql_container_partition_key]
}
2 changes: 1 addition & 1 deletion azurerm/modules/azurerm-cosmosdb/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ output "cosmosdb_endpoint" {
output "cosmosdb_primary_master_key" {
description = "Primary Key for accessing the DB CRUD, should only be used in applications running outside of AzureCloud"
sensitive = true
value = var.create_cosmosdb ? azurerm_cosmosdb_account.default.0.primary_master_key : ""
value = var.create_cosmosdb ? azurerm_cosmosdb_account.default.0.primary_key : ""
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
############################################
# AUTHENTICATION
############################################
############################################
# NAMING
############################################

Expand All @@ -11,45 +8,50 @@ variable "resource_namer" {
}

variable "resource_tags" {
description = "Map of tags to be applied to all resources created as part of this module"
type = map(string)
default = {}
description = "Map of tags to be applied to all resources created as part of this module"

default = {}
}

############################################
# COSMOSDB INFORMATION
############################################

variable "cosmosdb_sql_container" {
type = string

description = "Sql container name"
type = string
}

variable "cosmosdb_sql_container_partition_key" {
description = "Partition key path, if multiple partition"
type = string
description = "Partition key path, if multiple partition"
}


variable "cosmosdb_offer_type" {
description = ""
type = string
default = "Standard"
description = ""

default = "Standard"
}

variable "cosmosdb_kind" {
description = ""
type = string
default = "GlobalDocumentDB"
description = ""

default = "GlobalDocumentDB"
}

############################################
# RESOURCE INFORMATION
############################################

variable "resource_group_location" {
type = string
default = "uksouth"
type = string

default = "westeurope"
}

variable "resource_group_name" {
Expand All @@ -61,7 +63,7 @@ variable "resource_group_name" {
##########################

variable "create_cosmosdb" {
type = bool
type = bool

default = false
}

Loading