Deploy YAML Configs with Terraform

A YAML config stores a validated YAML configuration file in the Bahriya platform. YAML configs are scoped to your organisation, versioned with rotation history, and can be attached to projects and containers.

Updated 23 Jun 20261 min read

A YAML config stores a validated YAML configuration file in the Bahriya platform. YAML configs are scoped to your organisation, versioned with rotation history, and can be attached to projects and containers.

Required fields

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

Example

resource "bahriya_yaml_config" "app_config" {
  handle  = "app-config"
  name    = "App Config"
  content = file("${path.module}/configs/app.yaml")
}

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_yaml_config_attachment" "app_config" {
  project_id = bahriya_project.production.id
  handle     = bahriya_yaml_config.app_config.handle
}

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

resource "bahriya_container" "api" {
  # ... other fields ...
 
  yaml_configs = [
    {
      handle    = bahriya_yaml_config.app_config.handle
      mountpath = "/etc/bahriya/cfg/app.yaml"
    },
  ]
}

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).

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

Importing an existing config

terraform import bahriya_yaml_config.app_config <uuid>

Pricing

YAML 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.