The Formance Cloud Terraform provider allows you to manage your Formance Cloud resources via Infrastructure as Code (IaC). This provider supports managing stacks and stack modules.
- Installation
- Configuration
- Quick Start Guide
- Authentication
- Available Resources
- Data Sources
- Examples
- Full Documentation
- Support
terraform {
required_providers {
cloud = {
source = "formancehq/cloud"
}
}
}
provider "cloud" {
# Configuration...
}
The provider can be configured in two ways:
provider "cloud" {
client_id = "your-client-id"
client_secret = "your-client-secret"
}
export FORMANCE_CLOUD_CLIENT_ID="your-client-id"
export FORMANCE_CLOUD_CLIENT_SECRET="your-client-secret"
Here's a minimal example to get started with the Formance Cloud provider:
# Provider configuration
provider "cloud" {
# Credentials can be set via environment variables
}
# Get current organization
data "cloud_current_organization" "current" {}
# Get available regions
data "cloud_regions" "default" {
organization_id = data.cloud_current_organization.current.id
}
# Create a stack
resource "cloud_stack" "production" {
name = "production"
region_id = data.cloud_regions.default.regions[0].id
}
# Enable the ledger module
resource "cloud_stack_module" "ledger" {
name = "ledger"
stack_id = cloud_stack.production.id
}
The provider uses OAuth2 authentication with client credentials. To obtain your credentials:
- Log in to your Formance Cloud account
- Navigate to your organization settings
- Create a new OAuth2 application
- Note the
client_id
andclient_secret
- Never commit your credentials in your code
- Use environment variables or a secrets manager
- Limit your credentials' permissions to the minimum required
- Rotate your secrets regularly
cloud_stack
- Manages an isolated environment for your Formance services
cloud_stack_module
- Enables/disables modules on a stack
cloud_organizations
- Retrieves organization informationcloud_stacks
- Retrieves stack informationcloud_regions
- Retrieves region informationcloud_region_versions
- Lists available versions in a region
# Get current organization
data "cloud_current_organization" "current" {}
# Get available regions
data "cloud_regions" "default" {}
# Variables for environments
variable "environments" {
default = ["development", "staging", "production"]
}
# Create a stack for each environment
resource "cloud_stack" "env" {
for_each = toset(var.environments)
name = each.value
region_id = data.cloud_regions.default.regions[0].id
}
# Enable necessary modules for each stack
resource "cloud_stack_module" "ledger" {
for_each = cloud_stack.env
name = "ledger"
stack_id = each.value.id
}
For more detailed information about each resource and data source:
The following modules can be enabled on your stacks:
- ledger - Core accounting engine
- payments - Payment management and orchestration
- webhooks - Webhook management and distribution
- wallets - Digital wallet functionality
- search - Full-text search capabilities
- reconciliation - Transaction reconciliation
- orchestration - Workflow orchestration
- auth - Authentication and authorization
- stargate - API Gateway
Error: Failed to authenticate with Formance Cloud API
Solution: Check your client_id
and client_secret
. Ensure they are correctly configured.
Error: Insufficient permissions to perform this action
Solution: Verify that your credentials have the necessary permissions for the requested action.
Error: Stack cannot be deleted as it contains data
Solution: Use force_destroy = true
with caution to force deletion.
- Issues GitHub: github.com/formancehq/terraform-provider-cloud/issues
- API Documentation: docs.formance.com
- Contact: [email protected]
Contributions are welcome! See our contribution guide for more information.
This provider is distributed under the Apache 2.0 License. See LICENSE for more details.