Skip to content

Commit

Permalink
Added support for custom user data script
Browse files Browse the repository at this point in the history
  • Loading branch information
mihailradkov committed Nov 9, 2023
1 parent ecb739f commit 4c3c6dd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
9 changes: 8 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ resource "azurerm_subnet" "graphdb-vmss" {
address_prefixes = var.graphdb_subnet_address_prefix
}


# ------------------------------------------------------------

# Creates a user assigned identity which will be provided to GraphDB VMs.
module "identity" {
source = "./modules/identity"

Expand All @@ -67,6 +67,7 @@ module "identity" {
depends_on = [azurerm_resource_group.graphdb]
}

# Creates Key Vault for secure storage of GraphDB configurations and secrets
module "vault" {
source = "./modules/vault"

Expand All @@ -78,6 +79,7 @@ module "vault" {
depends_on = [azurerm_resource_group.graphdb]
}

# Managed GraphDB configurations in the Key Vault
module "configuration" {
source = "./modules/configuration"

Expand All @@ -96,6 +98,7 @@ module "configuration" {
]
}

# Creates a public load balancer for forwarding internet traffic to the GraphDB proxies
module "load_balancer" {
source = "./modules/load_balancer"

Expand All @@ -107,13 +110,15 @@ module "load_balancer" {
depends_on = [azurerm_resource_group.graphdb, azurerm_virtual_network.graphdb]
}

# Module for resolving the GraphDB shared image ID
module "graphdb_image" {
source = "./modules/image"

graphdb_version = var.graphdb_version
graphdb_image_id = var.graphdb_image_id
}

# Creates a VM scale set for GraphDB and GraphDB cluster proxies
module "vm" {
source = "./modules/vm"

Expand All @@ -133,6 +138,8 @@ module "vm" {
ssh_key = var.ssh_key
source_ssh_blocks = var.source_ssh_blocks

custom_user_data = var.custom_graphdb_vm_user_data

tags = local.tags

depends_on = [
Expand Down
3 changes: 1 addition & 2 deletions modules/vm/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ resource "azurerm_network_security_rule" "graphdb-proxies-inbound" {
}

locals {
# TODO: Add support for user provided one?
user_data_script = templatefile("${path.module}/templates/entrypoint.sh.tpl", {
user_data_script = var.custom_user_data != null ? var.custom_user_data : templatefile("${path.module}/templates/entrypoint.sh.tpl", {
load_balancer_fqdn : var.load_balancer_fqdn
key_vault_name : var.key_vault_name
})
Expand Down
6 changes: 6 additions & 0 deletions modules/vm/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,9 @@ variable "key_vault_name" {
description = "Name of a Key Vault containing GraphDB configurations"
type = string
}

variable "custom_user_data" {
description = "Custom user data script used during the cloud init phase in the GraphDB VMs. Should be in base64 encoding."
type = string
default = null
}
15 changes: 11 additions & 4 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ variable "graphdb_image_id" {
default = null
}

#
# GraphDB configurations

variable "graphdb_license_path" {
description = "Local path to a file, containing a GraphDB Enterprise license."
type = string
}

# GraphDB VM

variable "node_count" {
description = "Number of GraphDB nodes to deploy in ASG"
Expand All @@ -75,8 +82,8 @@ variable "source_ssh_blocks" {
default = null
}


variable "graphdb_license_path" {
description = "Local path to a file, containing a GraphDB Enterprise license."
variable "custom_graphdb_vm_user_data" {
description = "Custom user data script used during the cloud init phase in the GraphDB VMs. Should be in base64 encoding."
type = string
default = null
}

0 comments on commit 4c3c6dd

Please sign in to comment.