Introduction
The IACM (Infrastructure as Code Management) commands enable you to execute Terraform operations remotely using Harness servers. These commands upload your local Terraform code, execute it remotely, and stream logs back to your terminal in real-time.Key Features
- Remote Execution: Execute Terraform commands on Harness infrastructure without requiring local Terraform installation
- Real-time Log Streaming: Stream execution logs directly to your CLI as the pipeline runs
- Workspace Integration: Automatically sync with your Harness IACM workspace configuration
- Pipeline Orchestration: Leverage default pipelines configured at workspace or project level
- Custom Arguments: Pass Terraform-specific arguments like targets and replacements
Available Commands
plan
Execute a Terraform plan remotely and stream the results to your terminal
How It Works
Execution Flow
- Workspace Retrieval: Fetches workspace configuration including repository path and default pipelines
- Source Code Packaging: Zips your local Terraform code based on workspace folder path configuration
- Remote Execution Creation: Creates a remote execution request on Harness servers
- Upload: Uploads the packaged source code with SHA-256 checksum verification
- Pipeline Trigger: Triggers the configured default pipeline for the operation
- Log Streaming: Streams execution logs in real-time, including both completed and running steps
Authentication
IACM commands require authentication with Harness. See Global Flags for authentication options.Make sure you’re authenticated before running IACM commands:
Workspace Configuration
Repository Path
Therepository_path configured in your workspace determines what code gets uploaded:
- If your workspace has a folder path configured (e.g.,
terraform/prod), the CLI will find the repository root and upload the entire repository - If no folder path is configured, the CLI uploads the current directory and its contents
Default Pipelines
Each IACM command (plan, apply, etc.) can have a default pipeline configured at:- Workspace level: Takes precedence over project-level configuration
- Project level: Used if no workspace-level pipeline is configured
Log Streaming
Logs are streamed from the Harness pipeline execution:- Active Steps: For running steps, logs are streamed in real-time using SSE (Server-Sent Events)
- Completed Steps: For already completed steps, logs are fetched as a blob
- Format: Logs include timestamp, level, and message content
Error Handling
Common Errors
Workspace not found
Workspace not found
Ensure the workspace ID, organization, and project are correct. The workspace must exist in the specified project.
No default pipeline configured
No default pipeline configured
Configure a default pipeline for the operation at either workspace or project level in the Harness UI.
Folder path not found
Folder path not found
The
repository_path configured in your workspace doesn’t exist in your current directory. Either:- Navigate to the correct directory
- Update the workspace repository path configuration
Authentication failed
Authentication failed
Your authentication token may have expired. Run
hc auth login to re-authenticate.Examples
Basic Usage
With Organization and Project
With Terraform Arguments
See Also
- iacm plan - Detailed plan command documentation
- Global Flags - Authentication and configuration flags
- Authentication - Setting up authentication with Harness