CLI Commands Reference
Comet provides a set of commands for managing your infrastructure. This page documents all available commands and their options.
Global Flags
These flags are available for all commands:
--help- Display help information--version- Print version information
comet version
Print the current version of Comet.
comet version
Example Output:
comet version 0.1.0
comet list
List available stacks or components with metadata support.
List All Stacks
# List stacks with basic metadata
comet list
# List stacks with full metadata details
comet list --details
Flags:
--details, -d- Show full metadata including owner
Example Output (default):
+------------+--------------------------------------+--------------------+-------------------------+
| STACK | DESCRIPTION | TAGS | PATH |
+------------+--------------------------------------+--------------------+-------------------------+
| dev | Development environment | dev, testing | stacks/dev.stack.js |
| staging | Staging environment for QA | staging, qa | stacks/staging.stack.js |
| production | Production with HA configuration | prod, critical | stacks/prod.stack.js |
+------------+--------------------------------------+--------------------+-------------------------+
Example Output (--details):
+------------+--------------------------------------+---------------+--------------------+-------------------------+
| STACK | DESCRIPTION | OWNER | TAGS | PATH |
+------------+--------------------------------------+---------------+--------------------+-------------------------+
| dev | Development environment | dev-team | dev, testing | stacks/dev.stack.js |
| staging | Staging environment for QA | qa-team | staging, qa | stacks/staging.stack.js |
| production | Production with HA configuration | platform-team | prod, critical | stacks/prod.stack.js |
+------------+--------------------------------------+---------------+--------------------+-------------------------+
List Components in a Stack
comet list <stack>
Example:
comet list dev
Example Output:
Components in stack 'dev':
- vpc
- gke
- cloudsql
- redis
comet types
Generate TypeScript definitions for IDE support.
comet types
What it does:
- Creates
index.d.tsin your stacks directory - Provides autocomplete and type hints in your IDE
- Enables type checking for your stack files
Usage in stack files:
Add this reference to the top of your .stack.js files:
/// <reference path="./index.d.ts" />
Or enable type checking:
// @ts-check
/// <reference path="./index.d.ts" />
Benefits:
- ✅ Autocomplete for all Comet functions
- ✅ Inline documentation
- ✅ Type checking catches errors before running
- ✅ Better refactoring support
See the TypeScript Support section for more details.
comet plan
Show what changes will be made by the current configuration without actually applying them.
Plan All Components
comet plan <stack>
Example:
comet plan production
Plan a Specific Component
comet plan <stack> <component>
Example:
comet plan production vpc
Output: Shows Terraform plan output with additions, changes, and deletions.
comet init
Initialize backends and providers without running plan or apply operations. This is useful for setting up the environment before querying outputs or troubleshooting initialization issues.
Initialize All Components
comet init <stack>
Example:
comet init dev
Initialize a Specific Component
comet init <stack> <component>
Example:
comet init dev vpc
What it does:
- Generates backend configuration files (
backend.tf.json) - Generates provider configuration files (
providers_gen.tf) - Downloads required provider plugins
- Configures remote state backend
- Does NOT run plan, apply, or make infrastructure changes
Use cases:
- Before running
comet outputon a fresh checkout - Troubleshooting provider/backend initialization issues
- CI/CD validation pipelines that only need to query infrastructure
comet apply
Create or update infrastructure based on your configuration.
Apply All Components
comet apply <stack>
Example:
comet apply dev
This will apply changes to all components in the stack. Make sure to run comet plan first to review changes.
Apply a Specific Component
comet apply <stack> <component>
Example:
comet apply dev vpc
Flags:
--auto-approve- Skip interactive approval (use with caution)
comet output
Display output values from infrastructure components.
Show All Outputs from a Component
comet output <stack> <component>
Example:
comet output production gke
Example Output:
cluster_endpoint = "https://35.123.45.67"
cluster_ca_certificate = "LS0tLS1CRU..."
cluster_name = "prod-gke-cluster"
Show a Specific Output Key
comet output <stack> <component> <key>
Example:
comet output production gke cluster_endpoint
Example Output:
https://35.123.45.67
This is useful for scripting and automation:
ENDPOINT=$(comet output production gke cluster_endpoint)
# ENDPOINT now contains: https://35.123.45.67 (no quotes)
Show All Outputs from All Components
comet output <stack>
Example:
comet output production
JSON Output Format
Use the --json flag to output in JSON format, which can be piped to tools like jq:
comet output <stack> <component> --json
Example:
comet output production gke --json
Example Output:
{
"cluster_endpoint": "https://35.123.45.67",
"cluster_ca_certificate": "LS0tLS1CRU...",
"cluster_name": "prod-gke-cluster"
}
You can also get a specific key in JSON format:
comet output production gke cluster_endpoint --json
Example Output:
"https://35.123.45.67"
Piping to jq:
# Extract a specific field
comet output production gke --json | jq -r '.cluster_endpoint'
# Get all cluster names from all components
comet output production --json | jq -r '.cluster_name'
Note: When using the --json flag, sensitive values are displayed in plain text.
comet destroy
Destroy previously-created infrastructure.
Destroy All Components
comet destroy <stack>
Example:
comet destroy dev
This will destroy ALL infrastructure in the stack. This action cannot be undone. Always review with comet plan first.
Destroy a Specific Component
comet destroy <stack> <component>
Example:
comet destroy dev vpc
Flags:
--auto-approve- Skip interactive approval (use with extreme caution)
comet clean
Delete Terraform-related folders and files (.terraform, state files, etc.) for a stack or component.
Clean All Components
comet clean <stack>
Example:
comet clean dev
Clean a Specific Component
comet clean <stack> <component>
Example:
comet clean dev vpc
Use this command when you want to start fresh with Terraform initialization, or to clean up after destroying infrastructure.
comet export
Export stack configuration to standalone Terraform files for inspection or manual execution.
comet export <stack> [component] -o <output-dir>
Example - Export Entire Stack:
comet export production -o ./exported/production
Example - Export Single Component:
comet export production vpc -o ./exported/production-vpc
Flags:
-o, --output- Output directory for exported files (required)
This generates standard Terraform files that can be used independently of Comet:
backend.tf.json- Backend configurationproviders_gen.tf- Provider configurations*.tfvars.json- Variable values- Module source files (if applicable)
comet kube
Generate kubeconfig for Kubernetes clusters.
comet kube <stack> <component>
Example:
comet kube production gke
This command generates a kubeconfig file that you can use to connect to your Kubernetes cluster:
# Use the generated kubeconfig
export KUBECONFIG=~/.kube/comet-production-gke
kubectl get nodes
Common Workflows
Initial Deployment
# 1. List available stacks
comet list
# 2. Review changes
comet plan dev
# 3. Apply infrastructure
comet apply dev
# 4. Check outputs
comet output dev
Read-Only Query (Fresh Checkout)
# 1. Initialize backends and providers
comet init production
# 2. Query infrastructure outputs
comet output production vpc
comet output production gke
Updating Infrastructure
# 1. Review what will change
comet plan production vpc
# 2. Apply the changes
comet apply production vpc
# 3. Verify outputs
comet output production vpc
Destroying Infrastructure
# 1. Review what will be destroyed
comet plan production # Should show deletions
# 2. Destroy infrastructure
comet destroy production
# 3. Clean up Terraform files
comet clean production
Working with Specific Components
# Plan a single component
comet plan dev gke
# Apply a single component
comet apply dev gke
# Get component outputs
comet output dev gke
# Destroy a single component
comet destroy dev gke
Tips
Use Plan Before Apply
Always run plan before apply to review changes:
comet plan production
# Review the output carefully
comet apply production
Component Dependencies
Comet respects component dependencies within a stack. When you apply a stack, components with dependencies are applied in the correct order.
Parallel Execution
When applying multiple independent components, Comet can execute them in parallel for faster deployments.
State Management
Comet uses the backend configuration defined in your stack files. Make sure your backend is properly configured and accessible before running commands.
Error Recovery
If a command fails partway through:
- Review the error message
- Fix the issue in your configuration
- Run the command again - Terraform's state management will resume from where it left off
This action is dangerous