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_fabric_peer
Creates a Hyperledger Fabric peer node.
resource "chainlaunch_fabric_peer" "peer0" {
name = "peer0-org1"
msp_id = chainlaunch_fabric_organization.org1.msp_id
organization_id = tonumber(chainlaunch_fabric_organization.org1.id)
version = "2.5.9"
mode = "docker"
listen_address = "0.0.0.0:7051"
chaincode_address = "0.0.0.0:7052"
events_address = "0.0.0.0:7053"
operations_listen_address = "0.0.0.0:9443"
external_endpoint = "peer0.org1.example.com:7051"
}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)
}chainlaunch_fabric_join_node
Joins an existing peer node to a Fabric channel.
resource "chainlaunch_fabric_join_node" "join_peer" {
network_id = tonumber(chainlaunch_fabric_network.main.id)
node_id = tonumber(chainlaunch_node.peer0.id)
}chainlaunch_fabric_identity
Creates a Fabric admin or client identity for an organization.
resource "chainlaunch_fabric_identity" "admin" {
name = "org1-admin"
organization_id = tonumber(chainlaunch_fabric_organization.org1.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
Creates a chaincode record (smart contract) associated with a network/channel. The chaincode name is referenced by the install, approve, and commit steps.
resource "chainlaunch_fabric_chaincode" "mycc" {
name = "asset-tracker"
network_id = tonumber(chainlaunch_fabric_network.main.id)
}| Attribute | Required | Type | Description |
|---|---|---|---|
name |
Yes | string | Chaincode name |
network_id |
Yes | number | Fabric network/channel ID |
Computed: id, network_name, network_platform, created_at
chainlaunch_fabric_chaincode_definition
Creates a chaincode definition: the versioned, sequenced unit (docker image + endorsement policy) approved and committed to a channel.
resource "chainlaunch_fabric_chaincode_definition" "mycc_v1" {
chaincode_id = tonumber(chainlaunch_fabric_chaincode.mycc.id)
version = "1.0"
sequence = 1
docker_image = "chaincode/asset-tracker:1.0"
endorsement_policy = "OR('Org1MSP.member','Org2MSP.member')"
}| Attribute | Required | Type | Description |
|---|---|---|---|
chaincode_id |
Yes | number | Parent chaincode ID |
version |
Yes | string | Chaincode version |
sequence |
Yes | number | Definition sequence |
docker_image |
No | string | Chaincode docker image |
endorsement_policy |
No | string | Endorsement policy |
chaincode_address |
No | string | Chaincode address |
Computed: id, created_at
chainlaunch_fabric_chaincode_install
Installs a chaincode definition's package on one or more peers.
resource "chainlaunch_fabric_chaincode_install" "mycc" {
definition_id = tonumber(chainlaunch_fabric_chaincode_definition.mycc_v1.id)
peer_ids = [tonumber(chainlaunch_node.peer0.id)]
}| Attribute | Required | Type | Description |
|---|---|---|---|
definition_id |
Yes | number | Chaincode definition ID |
peer_ids |
Yes | list(number) | Peers to install on |
Computed: id, status, message
chainlaunch_fabric_chaincode_approve
Approves a chaincode definition for an organization on a peer.
resource "chainlaunch_fabric_chaincode_approve" "org1" {
definition_id = tonumber(chainlaunch_fabric_chaincode_definition.mycc_v1.id)
peer_id = tonumber(chainlaunch_node.peer0.id)
depends_on = [chainlaunch_fabric_chaincode_install.mycc]
}| Attribute | Required | Type | Description |
|---|---|---|---|
definition_id |
Yes | number | Chaincode definition ID |
peer_id |
Yes | number | Peer to approve from |
Computed: id, status, message
chainlaunch_fabric_chaincode_commit
Commits a chaincode definition to a channel (after majority approval).
resource "chainlaunch_fabric_chaincode_commit" "mycc" {
definition_id = tonumber(chainlaunch_fabric_chaincode_definition.mycc_v1.id)
peer_id = tonumber(chainlaunch_node.peer0.id)
depends_on = [
chainlaunch_fabric_chaincode_approve.org1,
chainlaunch_fabric_chaincode_approve.org2,
]
}| Attribute | Required | Type | Description |
|---|---|---|---|
definition_id |
Yes | number | Chaincode definition ID |
peer_id |
Yes | number | Peer to commit from |
Computed: id, status, message
chainlaunch_fabric_chaincode_deploy
Starts the chaincode docker containers for a committed definition.
resource "chainlaunch_fabric_chaincode_deploy" "mycc" {
definition_id = tonumber(chainlaunch_fabric_chaincode_definition.mycc_v1.id)
environment_variables = {
CORE_CHAINCODE_LOGGING_LEVEL = "info"
}
}| Attribute | Required | Type | Description |
|---|---|---|---|
definition_id |
Yes | number | Chaincode definition ID |
environment_variables |
No | map(string) | Container environment variables |
Computed: id, status, message
Backups
chainlaunch_backup_target
Creates an S3-compatible backup target.
resource "chainlaunch_backup_target" "s3" {
name = "primary-s3"
bucket_name = "chainlaunch-backups"
region = "us-east-1"
endpoint = "https://s3.amazonaws.com"
access_key_id = var.s3_access_key
secret_access_key = var.s3_secret_key
}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_prometheus
Configures the managed Prometheus instance.
resource "chainlaunch_metrics_prometheus" "main" {
scrape_interval = "15s"
}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_invitation
Creates a node sharing invitation for another instance.
resource "chainlaunch_node_invitation" "peer" {
node_id = tonumber(chainlaunch_node.peer0.id)
}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_sync_all_external_nodes
Syncs external nodes from all connected peers.
chainlaunch_network_share
Shares a network with a connected peer.
chainlaunch_shared_network_accept
Accepts a shared network from a connected peer.
chainlaunch_chaincode_definition_share
Shares a chaincode definition with a connected peer.
Remote Management
chainlaunch_install_ssh
Installs ChainLaunch on a remote server via SSH.
resource "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
- Terraform Overview for setup and best practices
- Vault Integration for Vault key provider config
- AWS KMS Integration for AWS KMS key provider config