Deploy JSON Configs with Terraform

A JSON config stores a validated JSON configuration file in the Bahriya platform. JSON configs are scoped to your organisation, versioned with rotation history, and can be attached to projects and containers (mounted as files via a ConfigMap volume).

Updated 23 Jun 20262 min read

A JSON config stores a validated JSON configuration file in the Bahriya platform. JSON configs are scoped to your organisation, versioned with rotation history, and can be attached to projects and containers (mounted as files via a ConfigMap volume).

Required fields

FieldTypeDescription
handlestringA unique identifier (DNS-1123 compliant: lowercase, alphanumeric, hyphens).
namestringA display name.
contentstringValid JSON content.

Read-only fields

FieldTypeDescription
currentversionintegerThe currently active version number.
maxversionsintegerHow many historic versions are retained (default 5).

Example

resource "bahriya_json_config" "app_settings" {
  handle  = "app-settings"
  name    = "App Settings"
  content = file("${path.module}/configs/app-settings.json")
}

You can also build the content inline with jsonencode():

resource "bahriya_json_config" "app_settings" {
  handle  = "app-settings"
  name    = "App Settings"
  content = jsonencode({
    service = "api"
    features = {
      alpha = true
      beta  = false
    }
  })
}

Attach it to a project so it deploys to the project's regions:

resource "bahriya_project" "production" {
  handle  = "production"
  name    = "Production"
  regions = ["helsinki-1", "falkenstein-1"]
}
 
resource "bahriya_project_json_config_attachment" "app_settings" {
  project_id = bahriya_project.production.id
  handle     = bahriya_json_config.app_settings.handle
}

Then mount it on a container as a file via a ConfigMap volume:

resource "bahriya_container" "api" {
  # ... other fields ...
 
  json_configs = [
    {
      handle    = bahriya_json_config.app_settings.handle
      mountpath = "/etc/bahriya/cfg/app-settings.json"
    },
  ]
}

Rotation

To rotate configuration content, update the content field in your Terraform config and run terraform apply. The Bahriya API creates a new version and marks it current. Previous versions are retained for rollback (default: last 5). Content is re-validated as syntactically correct JSON on every update.

After rotation, file-mounted containers pick up the new config automatically within about 60 seconds. No manual redeploy is needed.

Importing an existing config

terraform import bahriya_json_config.app_settings <uuid>

Pricing

JSON configs are billed at $0.02 per month while they exist in your organisation, plus $0.02 per region per month when attached to a project.