Skip to content
Merged
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
3 changes: 3 additions & 0 deletions modules/azure/cosmosdb/azure.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "azurerm" {
version = "=1.38.0"
}
8 changes: 8 additions & 0 deletions modules/azure/cosmosdb/backend.tf.azurerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
backend "azurerm" {
resource_group_name = "example-tfstate"
storage_account_name = "exampletfstate"
container_name = "tfstate"
key = "cosmosdb/terraform.tfstate"
}
}
10 changes: 10 additions & 0 deletions modules/azure/cosmosdb/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
locals {
network = {
name = data.terraform_remote_state.network.outputs.network_name
region = data.terraform_remote_state.network.outputs.region
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following may not be necessary.

  • cidr
  • dns
  • id
  • bastion_ip
  • bastion_provision_id
  • internal_domain

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Thanks 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

kubernetes = {
node_pool_subnet_id = data.terraform_remote_state.kubernetes.outputs.node_pool_subnet_id
}
}
7 changes: 7 additions & 0 deletions modules/azure/cosmosdb/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module "cosmosdb" {
source = "git::https://github.com/scalar-labs/scalar-terraform.git//modules/azure/cosmosdb?ref=master"

# Required Variables
network = local.network
kubernetes = local.kubernetes
}
11 changes: 11 additions & 0 deletions modules/azure/cosmosdb/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
output "cosmosdb_account_endpoint" {
value = module.cosmosdb.cosmosdb_account_endpoint
}

output "cosmosdb_account_primary_master_key" {
value = module.cosmosdb.cosmosdb_account_primary_master_key
}

output "cosmosdb_account_secondary_master_key" {
value = module.cosmosdb.cosmosdb_account_secondary_master_key
}
15 changes: 15 additions & 0 deletions modules/azure/cosmosdb/remote.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
data "terraform_remote_state" "network" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need remote.tf.azurerm for a case where blob storage is used for the backend?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In scalar-k8s, cassandra and monitor modules have remote.tf.azurerm (and remote.tf.s3 also), but kuberrnetes doesn't.
I wonder if these example files should be provided because they are all very similar and I think it's getting harder to keep them all correct and up-to-date. It might be better to document how to use the remote backend rather than providing example files.

Copy link
Collaborator

@feeblefakie feeblefakie Sep 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but then backend.tf.azurerm is pretty similar to other backend files.
So that's probably another issue to fix; removing redundant files.
As for this, I think it should be consistent with the others.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this PR, I have added remote.tf.azurerm for the cosmosdb module.

But to be fully consistent, remote.tf.azurerm (and remote.tf.s3 also?) need to be added to kubernetes module as well. That's the same for backend.tf. And monitor/remote.tf.azurerm and monitor/remote.tf.s3 already look wrong when compared to module/remote.tf. I'll fix these issues later.

BTW, basically, should we have s3 backend files in azure modules? When taking a look at scalar-terraform, it looks like modules in examples/aws have only s3 versions, but in example/azure, some modules have only azurerm versions, some have both versions, and some don't have either. I think s3 files can be removed from azure examples.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
I think we should remove s3 files from Azure.
So to sum up, the following needs to be fixed?

  • add remote.tf.azurerm for kubenetes module
  • fix monitor.tf.s3 and azurerm
  • remove s3 files from azure

I think it can be done in one PR or separate PRs.
Could you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the summary! Sure!

backend = "local"

config = {
path = "../network/terraform.tfstate"
}
}

data "terraform_remote_state" "kubernetes" {
backend = "local"

config = {
path = "../kubernetes/terraform.tfstate"
}
}
19 changes: 19 additions & 0 deletions modules/azure/cosmosdb/remote.tf.azurerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
data "terraform_remote_state" "network" {
backend = "azurerm"

config = {
storage_account_name = "exampletfstate"
container_name = "tfstate"
key = "network/terraform.tfstate"
}
}

data "terraform_remote_state" "kubernetes" {
backend = "azurerm"

config = {
storage_account_name = "exampletfstate"
container_name = "tfstate"
key = "kubernetes/terraform.tfstate"
}
}
2 changes: 2 additions & 0 deletions modules/azure/kubernetes/example.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ kubernetes_scalar_apps_pool = {
# cluster_auto_scaling_max_count = "6"
}

# use_cosmosdb = false

custom_tags = {
# "environment" = "example"
}
1 change: 1 addition & 0 deletions modules/azure/kubernetes/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ module "kubernetes" {
kubernetes_cluster = var.kubernetes_cluster
kubernetes_default_node_pool = var.kubernetes_default_node_pool
kubernetes_scalar_apps_pool = var.kubernetes_scalar_apps_pool
use_cosmosdb = var.use_cosmosdb
custom_tags = var.custom_tags
}
4 changes: 4 additions & 0 deletions modules/azure/kubernetes/output.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
output "node_pool_subnet_id" {
value = module.kubernetes.node_pool_subnet_id
}

output "kube_config" {
value = module.kubernetes.kube_config
description = "kubectl configuration e.g: ~/.kube/config"
Expand Down
6 changes: 6 additions & 0 deletions modules/azure/kubernetes/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ variable "kubernetes_scalar_apps_pool" {
description = "Custom definition kubernetes scalar apps node pools, same as default_node_pool"
}

variable "use_cosmosdb" {
type = bool
default = false
description = "Whether to use Cosmos DB. If true, a service endpoint for Cosmos DB is enabled."
}

variable "custom_tags" {
type = map
default = {}
Expand Down