ChainLaunch

Terraform Resource Reference

Complete reference for all ChainLaunch Terraform provider resources.

Complete reference for all ChainLaunch Terraform provider resources.

Provider Configuration

terraform {
  required_providers {
    chainlaunch = {
      source = "registry.terraform.io/kfsoftware/chainlaunch"
    }
  }
}
 
provider "chainlaunch" {
  url      = "http://localhost:8100"
  username = "admin"
  password = var.chainlaunch_password
}
Attribute Required Description
url Yes ChainLaunch API URL
username Yes Authentication username
password Yes Authentication password

Organizations

chainlaunch_fabric_organization

Creates a Hyperledger Fabric organization with MSP, CA, and crypto material.

resource "chainlaunch_fabric_organization" "org1" {
  msp_id      = "Org1MSP"
  description = "Manufacturing organization"
  provider_id = 1  # Key provider ID (database, Vault, or KMS)
}
Attribute Required Type Description
msp_id Yes string Organization MSP ID
description No string Organization description
provider_id No number Key provider ID (defaults to database provider)

Computed: id

chainlaunch_fabric_organization_import

Imports an existing Fabric organization from external crypto material.

resource "chainlaunch_fabric_organization_import" "external_org" {
  msp_id       = "ExternalOrgMSP"
  description  = "Imported from existing network"
  sign_ca_cert = file("crypto/ca-cert.pem")
  sign_ca_key  = file("crypto/ca-key.pem")
  tls_ca_cert  = file("crypto/tls-ca-cert.pem")
  tls_ca_key   = file("crypto/tls-ca-key.pem")
  provider_id  = tonumber(chainlaunch_key_provider.vault.id)
}

Nodes

chainlaunch_node

Creates a blockchain node (Fabric peer, orderer, CA, or Besu node).

resource "chainlaunch_node" "peer0" {
  name            = "peer0-org1"
  platform        = "FABRIC"
  node_type       = "FABRIC_PEER"
  organization_id = tonumber(chainlaunch_fabric_organization.org1.id)
}
Attribute Required Type Description
name Yes string Node name
platform Yes string FABRIC or BESU
node_type Yes string See node types below
organization_id No number Organization (Fabric only)

Node types: FABRIC_PEER, FABRIC_ORDERER, FABRIC_CA, BESU_FULLNODE

chainlaunch_besu_node

Creates a Besu node with full configuration.

resource "chainlaunch_besu_node" "validator0" {
  name       = "validator-0"
  network_id = tonumber(chainlaunch_network.besu.id)
  node_type  = "validator"
  p2p_port   = 30303
  rpc_port   = 8545
  ws_port    = 8546
}

chainlaunch_fabric_orderer

Creates a Fabric orderer node for a specific network.

resource "chainlaunch_fabric_orderer" "orderer0" {
  name            = "orderer0-org1"
  organization_id = tonumber(chainlaunch_fabric_organization.org1.id)
  network_id      = tonumber(chainlaunch_fabric_network.main.id)
}

chainlaunch_fabric_add_node

Adds an existing node to a Fabric network/channel.

resource "chainlaunch_fabric_add_node" "add_peer" {
  network_id = tonumber(chainlaunch_fabric_network.main.id)
  node_id    = tonumber(chainlaunch_node.peer0.id)
}

Networks

chainlaunch_network

Generic network resource (Fabric or Besu).

resource "chainlaunch_network" "besu" {
  name     = "production-besu"
  platform = "BESU"
}

chainlaunch_fabric_network

Creates a complete Fabric network with channels, orgs, and policies.

resource "chainlaunch_fabric_network" "main" {
  name = "supply-chain"
 
  peer_organizations = [
    {
      msp_id = chainlaunch_fabric_organization.org1.msp_id
      peers  = [tonumber(chainlaunch_node.peer0.id)]
    },
    {
      msp_id = chainlaunch_fabric_organization.org2.msp_id
      peers  = [tonumber(chainlaunch_node.peer1.id)]
    }
  ]
 
  orderer_organizations = [
    {
      msp_id   = chainlaunch_fabric_organization.org1.msp_id
      orderers = [tonumber(chainlaunch_fabric_orderer.orderer0.id)]
    }
  ]
 
  channels = ["mychannel"]
}

chainlaunch_fabric_anchor_peers

Sets anchor peers for an organization in a channel.

resource "chainlaunch_fabric_anchor_peers" "org1" {
  network_id      = tonumber(chainlaunch_fabric_network.main.id)
  organization_id = tonumber(chainlaunch_fabric_organization.org1.id)
  peer_ids        = [tonumber(chainlaunch_node.peer0.id)]
}

Keys & Key Providers

chainlaunch_key

Creates a cryptographic key.

resource "chainlaunch_key" "signing_key" {
  name        = "signing-key"
  algorithm   = "EC"
  curve       = "P-256"
  provider_id = 1
}

chainlaunch_key_provider

Creates a key management provider (Database, Vault, or AWS KMS).

# Vault
resource "chainlaunch_key_provider" "vault" {
  name       = "vault-production"
  type       = "VAULT"
  is_default = true
 
  vault_config = {
    operation = "IMPORT"
    address   = "https://vault.company.com:8200"
    token     = var.vault_token
    mount     = "secret"
  }
}
 
# AWS KMS
resource "chainlaunch_key_provider" "kms" {
  name       = "aws-kms"
  type       = "AWS_KMS"
  is_default = false
 
  aws_kms_config = {
    operation            = "IMPORT"
    aws_region           = "us-east-1"
    kms_key_alias_prefix = "chainlaunch/"
  }
}

See Vault Integration and AWS KMS Integration for details.


Chaincode Lifecycle

chainlaunch_fabric_chaincode

Installs chaincode on a peer.

resource "chainlaunch_fabric_chaincode" "mycc" {
  name       = "asset-tracker"
  peer_id    = tonumber(chainlaunch_node.peer0.id)
  network_id = tonumber(chainlaunch_fabric_network.main.id)
  version    = "1.0"
  language   = "golang"
  address    = "chaincode/asset-tracker:1.0"
}

chainlaunch_fabric_chaincode_approve

Approves chaincode for an organization.

resource "chainlaunch_fabric_chaincode_approve" "org1" {
  name       = "asset-tracker"
  version    = "1.0"
  sequence   = 1
  network_id = tonumber(chainlaunch_fabric_network.main.id)
  peer_id    = tonumber(chainlaunch_node.peer0.id)
}

chainlaunch_fabric_chaincode_commit

Commits chaincode to a channel (after majority approval).

resource "chainlaunch_fabric_chaincode_commit" "mycc" {
  name       = "asset-tracker"
  version    = "1.0"
  sequence   = 1
  network_id = tonumber(chainlaunch_fabric_network.main.id)
 
  depends_on = [
    chainlaunch_fabric_chaincode_approve.org1,
    chainlaunch_fabric_chaincode_approve.org2,
  ]
}

chainlaunch_fabric_chaincode_definition

Creates a chaincode definition (higher-level than individual lifecycle steps).

chainlaunch_fabric_chaincode_deploy

One-shot chaincode deployment (install + approve + commit).


Backups

chainlaunch_backup_schedule

Creates a backup schedule.

resource "chainlaunch_backup_schedule" "daily" {
  name            = "daily-backup"
  target_id       = tonumber(chainlaunch_backup_target.s3.id)
  cron_expression = "0 2 * * *"  # 2 AM daily
  retention_days  = 30
  enabled         = true
}

Monitoring

chainlaunch_metrics_job

Creates a Prometheus metrics scrape job.

resource "chainlaunch_metrics_job" "nodes" {
  name          = "node-metrics"
  scrape_target = "localhost:9091"
  interval      = "15s"
}

Notifications

chainlaunch_notification_provider

Creates an SMTP notification provider.

resource "chainlaunch_notification_provider" "email" {
  type       = "SMTP"
  name       = "Ops Email"
  is_default = true
 
  smtp_config = {
    host       = "smtp.gmail.com"
    port       = 587
    username   = var.smtp_user
    password   = var.smtp_password
    from       = "alerts@company.com"
    tls        = true
    recipients = ["ops@company.com"]
  }
 
  notify_node_downtime      = true
  notify_backup_failure     = true
  notify_disk_space_warning = true
}

Plugins

chainlaunch_plugin

Registers a plugin.

resource "chainlaunch_plugin" "hlf_api" {
  name        = "hlf-api"
  description = "Hyperledger Fabric REST API gateway"
  image       = "chainlaunch/hlf-api:latest"
}

chainlaunch_plugin_deployment

Deploys a plugin instance.

resource "chainlaunch_plugin_deployment" "hlf_api" {
  plugin_id  = tonumber(chainlaunch_plugin.hlf_api.id)
  network_id = tonumber(chainlaunch_fabric_network.main.id)
  config     = jsonencode({ port = 3000 })
}

Node Sharing (Pro)

chainlaunch_node_accept_invitation

Accepts a node sharing invitation.

resource "chainlaunch_node_accept_invitation" "peer" {
  invitation_jwt = var.invitation_token
}

chainlaunch_external_nodes_sync

Syncs external nodes from a connected peer.

chainlaunch_network_share

Shares a network with a connected peer.

chainlaunch_chaincode_definition_share

Shares a chaincode definition with a connected peer.


Remote Management

chainlaunch_chainlaunch_install_ssh

Installs ChainLaunch on a remote server via SSH.

resource "chainlaunch_chainlaunch_install_ssh" "remote" {
  host        = "10.0.1.50"
  user        = "root"
  private_key = file("~/.ssh/id_rsa")
  version     = "latest"
}

Full Example

See the complete example for a full Fabric network with orgs, nodes, channels, chaincode, backups, and monitoring.

Next Steps