How Terraform Services Work
Terraform services in Ryvn allow you to define and manage infrastructure resources across multiple cloud providers (AWS, Google Cloud, Azure) using HashiCorp Terraform. When you create a Terraform service, Ryvn handles:- Terraform state management
- Secure storage of provider credentials
- Execution of Terraform plans and applies
- Version control and rollback capabilities
Terraform services are supported out of the box for Ryvn-provisioned clusters only. For existing clusters, contact the Ryvn team via support@ryvn.ai or your shared Slack channel—this requires setting up cloud roles for the Terraform executor.
Prerequisites
Before deploying a Terraform module, ensure you have:- A GitHub repository containing your Terraform configuration
- Appropriate cloud provider permissions configured in your environment
Backend Configuration
Do not specify a Terraform backend in your configuration. Ryvn manages state storage automatically based on your environment.AWS Terraform Executor Policies
In Ryvn’s architecture, the Ryvn Agent is the component responsible for executing Terraform operations and managing Terraform state in your AWS environment. This agent runs with specific IAM permissions that determine which AWS resources your Terraform services can create and manage. By default, the Ryvn Agent runs with restricted IAM permissions that limit the types of resources Terraform can create or manage. To enable broader permissions for your Terraform services, you need to configure the Ryvn Agent’s IAM policy through theterraform_executor_policies configuration.
To grant full access for Terraform services in your AWS environment, add the following to your AWS provisioning
configuration:
Security Best Practice: While the example above shows full wildcard permissions for simplicity, you should scope
these permissions down to only what your Terraform services actually need when deploying to customer environments.
Follow the principle of least privilege by limiting actions to specific services and resources required by your
infrastructure.
terraform_executor_policies configuration must be added during environment provisioning. For existing
environments, you’ll need to update the provisioning configuration to modify the Ryvn Agent’s permissions. See the
AWS provisioning documentation for more details.
Quick Start
Configure GitHub Source
- Select your GitHub repository
- (Optional) Specify the Terraform path if in a subdirectory
Creating a Terraform Service
To create a Terraform service:- Navigate to the Services tab in the Ryvn dashboard
- Click Create Service
- Select Terraform as the service type
- Configure your Terraform source (see below)
- Click Create
Configuring Terraform Source
Terraform services in Ryvn use GitHub repositories as their source. You can configure:- GitHub Repository: Select the repository containing your Terraform code
- Terraform Path (Optional): Specify a subdirectory within the repository where your Terraform configuration is located
terraform/production), specify that path.
Source Credentials
Ryvn automatically manages the credentials needed to access your GitHub repository. When you deploy a Terraform service to an environment, Ryvn:- Generates temporary access tokens for your GitHub repository
- Securely passes these credentials to the Terraform execution environment
- Ensures the credentials have the minimum necessary permissions
Example Terraform Module
Here’s a minimal example that works with Ryvn:Plan Approval Configuration
By default, Terraform plans require manual approval before applying. You can enable automatic approval by settingautoApprove: true on the service:
requireApproval: true, plans will always require approval—regardless of the service’s autoApprove setting. Environment-level approval requirements take precedence, ensuring customers or operators can review changes before they’re applied.
See Deployment Approvals for the complete workflow.
Managing Variables
Accessing the Variables Editor
Navigate to Installation
Go to Environments → Select your environment → Click on your Terraform installation
Basic Variable Configuration
Variables are defined in YAML format and can include static values or dynamic template expressions:Template System
Ryvn provides access to environment state data through template variables. All template expressions use the{{ }} syntax.
Environment State Variables
Access infrastructure information provisioned by Ryvn:Cluster Information
Cluster Information
VPC and Networking
VPC and Networking
DNS Configuration
DNS Configuration
IAM and Security
IAM and Security
Cross-Installation References
Reference outputs from other Terraform installations in the same environment using theinstallation function:
Secret References
Access Kubernetes secrets created in your environment:Template Functions
Ryvn provides helper functions to format and manipulate template values:Configuration Examples
Database Module
Deploying Services
After creating a Terraform service, you can deploy it to an environment:- Navigate to the Environments tab
- Select the target environment
- Click Add Installation
- Select your Terraform service
- Configure any Terraform variables needed for your deployment
- Click Deploy
- Clone your GitHub repository
- Navigate to the specified Terraform path (if provided)
- Initialize Terraform
- Create an execution plan
- Apply the changes if the plan is successful
Monitoring Deployments
After a Terraform operation completes, Ryvn updates the installation status to reflect the current state:| Operation | Success | Status |
|---|---|---|
| Terraform Apply | Yes | Up to date |
| Terraform Apply | No | Failed |
| Terraform Plan | Yes | Pending |
Up to date. This indicates that your infrastructure is provisioned according to your Terraform configuration.
If a Terraform operation fails, the installation status will be marked as Failed. You can view detailed error on the installation’s Activity page or in the logs.
Release Management
Managing infrastructure changes requires coordination to avoid disrupting applications. Ryvn provides controls for Terraform deployments: Release Channels: Control how infrastructure changes flow through environments. Deploy to development first, then promote through staging to production with approval gates. Maintenance Windows: Schedule infrastructure changes during acceptable downtime periods (database migrations, network updates, security changes).Troubleshooting
Permission Denied
Permission Denied
Check that your environment has the necessary cloud provider permissions configured. For AWS, ensure
terraform_executor_policies are properly configured in your environment provisioning.Variable Not Set
Variable Not Set
All required variables must be set in the Terraform Variables section before deployment. Navigate to Installation → Settings → Terraform Variables to configure them.
Template Rendering Failed
Template Rendering Failed
Template expressions are processed when the Terraform task is created. If a referenced installation or secret doesn’t exist, the task will fail with a template error. Ensure dependencies exist before referencing them.