Skip to content

MaterializeInc/terraform-azurerm-materialize

Repository files navigation

Materialize on Azure

Terraform module for deploying Materialize on Azure with all required infrastructure components.

This module sets up:

  • AKS cluster for Materialize workloads
  • Azure Database for PostgreSQL Flexible Server for metadata storage
  • Azure Blob Storage for persistence
  • Required networking and security configurations
  • Managed identities with proper RBAC permissions

Warning This is provided on a best-effort basis and Materialize cannot offer support for this module.

The module has been tested with:

  • AKS version 1.28
  • PostgreSQL 15
  • Materialize Operator v0.1.0

Setup Notes:

This module requires active Azure credentials in your environment, either set up through environment variables containing the required keys or by logging in with the Azure CLI using:

az login

You also need to set an Azure subscription ID in the subscription_id variable or set the ARM_SUBSCRIPTION_ID environment variable, eg:

export ARM_SUBSCRIPTION_ID="your-subscription-id"

Additionally, this module runs a Python script to generate Azure SAS tokens for the storage account. This requires Python 3.12 or greater.

Installing Dependencies

Before running the module, ensure you have the necessary Python dependencies installed:

  1. Install Python 3.12+ if you haven't already.

  2. Install the required dependencies using pip:

    pip install -r requirements.txt

    Or alternatively, you can install the dependencies manually:

    pip install azure-identity azure-storage-blob azure-keyvault-secrets azure-mgmt-storage

If you are using a virtual environment, you can set it up as follows:

python -m venv venv
source venv/bin/activate  # On macOS/Linux
venv\Scripts\activate  # On Windows
pip install -r requirements.txt

This will install the required Python packages in a virtual environment.

Requirements

Name Version
terraform >= 1.0
azuread >= 2.45.0
azurerm >= 3.75.0
helm ~> 2.0
kubernetes ~> 2.0

Providers

No providers.

Modules

Name Source Version
aks ./modules/aks n/a
database ./modules/database n/a
operator github.com/MaterializeInc/terraform-helm-materialize v0.1.7
storage ./modules/storage n/a

Resources

No resources.

Inputs

Name Description Type Default Required
aks_config AKS cluster configuration
object({
vm_size = string
disk_size_gb = number
min_nodes = number
max_nodes = number
})
{
"disk_size_gb": 100,
"max_nodes": 5,
"min_nodes": 1,
"vm_size": "Standard_E8ps_v6"
}
no
database_config Azure Database for PostgreSQL configuration
object({
sku_name = optional(string, "GP_Standard_D2s_v3")
postgres_version = optional(string, "15")
password = string
username = optional(string, "materialize")
db_name = optional(string, "materialize")
})
n/a yes
helm_chart Chart name from repository or local path to chart. For local charts, set the path to the chart directory. string "materialize-operator" no
helm_values Additional Helm values to merge with defaults any {} no
install_materialize_operator Whether to install the Materialize operator bool true no
location The location where resources will be created string "eastus2" no
materialize_instances Configuration for Materialize instances
list(object({
name = string
namespace = optional(string)
database_name = string
environmentd_version = optional(string, "v0.130.4")
cpu_request = optional(string, "1")
memory_request = optional(string, "1Gi")
memory_limit = optional(string, "1Gi")
create_database = optional(bool, true)
in_place_rollout = optional(bool, false)
request_rollout = optional(string)
force_rollout = optional(string)
}))
[] no
namespace Namespace for all resources, usually the organization or project name string "materialize" no
network_config Network configuration for the AKS cluster
object({
vnet_address_space = string
subnet_cidr = string
service_cidr = string
})
{
"docker_bridge_cidr": "172.17.0.1/16",
"service_cidr": "10.1.0.0/16",
"subnet_cidr": "10.0.0.0/20",
"vnet_address_space": "10.0.0.0/16"
}
no
operator_namespace Namespace for the Materialize operator string "materialize" no
operator_version Version of the Materialize operator to install string null no
orchestratord_version Version of the Materialize orchestrator to install string "v0.130.4" no
prefix Prefix to be used for resource names string "materialize" no
resource_group_name The name of the resource group string n/a yes
tags Tags to apply to all resources map(string) {} no
use_local_chart Whether to use a local chart instead of one from a repository bool false no

Outputs

Name Description
aks_cluster AKS cluster details
connection_strings Formatted connection strings for Materialize
database Azure Database for PostgreSQL details
identities Managed Identity details
kube_config The kube_config for the AKS cluster
resource_group_name n/a
storage Azure Storage Account details

Accessing the AKS cluster

The AKS cluster can be accessed using the kubectl command-line tool. To authenticate with the cluster, run the following command:

az aks get-credentials --resource-group $(terraform output -raw resource_group_name) --name $(terraform output -json aks_cluster | jq -r '.name')

This command retrieves the AKS cluster credentials and merges them into the ~/.kube/config file. You can now interact with the AKS cluster using kubectl.

About

Terraform module for deploying the required Azure infrastructure components for Materialize

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •