Skip to main content

CLI Commands Reference

Complete reference for all Terraback commands.

Command Structure

terraback [OPTIONS] COMMAND [ARGS]

Global Options

OptionDescription
--verbose, -vEnable verbose output
--debugEnable debug logging
--helpShow help message

Top-Level Commands

CommandDescription
awsAmazon Web Services resources
azureMicrosoft Azure resources
gcpGoogle Cloud Platform resources
scanResource scanning commands
terraformTerraform operations
cleanClean generated files
listList scanned resources
analyseAnalyse Terraform state
licenseLicense management
cacheCache management

Scan Commands

scan all

Scan all resources in a cloud provider.

terraback scan all PROVIDER [OPTIONS]

Arguments:

  • PROVIDER: Cloud provider (aws, azure, or gcp)

Options:

OptionDescription
-o, --output-dir PATHDirectory to save Terraform files (default: generated)
-p, --profile TEXTAWS profile name
-r, --region TEXTAWS region, Azure location, or GCP region
-s, --subscription-id TEXTAzure subscription ID
--project-id TEXTGCP project ID
-g, --resource-group TEXTAzure resource group
-z, --zone TEXTGCP zone
--with-depsRecursively scan dependencies (Professional)
--parallel INTEGERNumber of parallel workers (1-32)
--enterprise-modulesGenerate enterprise module structure (Professional)
--cache / --no-cacheCache API responses for faster re-scans. Opt-in: caching is OFF by default (--no-cache)
--cache-encryptEncrypt cache files at rest with Fernet (requires --cache)
--all-regionsScan all enabled regions/locations in parallel instead of a single region (Professional)
--resumeResume an interrupted scan, skipping scanners that already completed
--previewRun a terraform plan preview after the scan completes

Examples:

# Scan all AWS resources in us-east-1
terraback scan all aws -r us-east-1 -o ./output

# Scan with dependencies and enterprise modules
terraback scan all aws -r us-east-1 --with-deps --enterprise-modules -o ./enterprise

# Scan Azure resource group
terraback scan all azure -g my-resource-group -o ./azure-output

# Scan GCP project
terraback scan all gcp --project-id my-project -r us-central1 -o ./gcp-output

# Scan all enabled AWS regions in parallel, caching API responses
terraback scan all aws --all-regions --parallel 8 --cache -o ./output

# Resume an interrupted scan
terraback scan all aws -r us-east-1 --resume -o ./output

scan auth-check

Check authentication status for all cloud providers.

terraback scan auth-check

AWS Commands

aws scan-all

Scan all available AWS resources based on your license tier.

terraback aws scan-all [OPTIONS]

Service-Specific Commands

Each AWS service has resource-specific commands for scanning, listing, and importing. For example, the EC2 service has scan-instances, list-instances, import-instance, scan-volumes, etc.

Available Services:

ServiceDescription
ec2EC2 instances, volumes, snapshots, AMIs, key pairs
vpcVPCs, subnets, security groups, route tables, gateways
s3S3 buckets, versioning, public access blocks
iamIAM roles, policies
rdsRDS instances, subnet groups, parameter groups
lambdaLambda functions, layers
elbv2Application/Network Load Balancers, target groups, listeners
elbClassic Load Balancers
route53Hosted zones, DNS records
snsSNS topics, subscriptions
sqsSQS queues
acmACM certificates
apigatewayAPI Gateway REST APIs
autoscalingAuto Scaling groups, policies, launch configurations
cloudfrontCloudFront distributions, origin access controls
cloudwatchLog groups, alarms, dashboards
ecrECR repositories
ecsECS clusters, services, task definitions
efsEFS file systems, mount targets, access points
eipsElastic IPs
elasticacheElastiCache clusters, replication groups
secretsmanagerSecrets Manager secrets
ssmSSM parameters, documents
dynamodbDynamoDB tables
kmsKMS keys, aliases
eventbridgeEventBridge rules, targets
stepfunctionsStep Functions state machines
kinesisKinesis streams, Firehose delivery streams
opensearchOpenSearch domains
mskMSK clusters
cloudtrailCloudTrail trails
guarddutyGuardDuty detectors
backupAWS Backup vaults

Example Usage:

# Scan EC2 instances
terraback aws ec2 scan-instances --region us-east-1 --output-dir ./output

# Scan EC2 instances with dependencies
terraback aws ec2 scan-instances --region us-east-1 --with-deps --output-dir ./output

# List previously scanned EC2 instances
terraback aws ec2 list-instances --output-dir ./output

# Import a specific EC2 instance
terraback aws ec2 import-instance i-1234567890abcdef0 --output-dir ./output

Azure Commands

azure scan-all

Scan all available Azure resources.

terraback azure scan-all [OPTIONS]

Service-Specific Commands

Azure services are organized by category. Use terraback azure CATEGORY to access service-specific commands.

ServiceCLI CommandDescription
ComputecomputeVirtual machines, managed disks, VM scale sets, SSH keys, function apps, App Service plans, web apps
NetworknetworkVirtual networks, subnets, network interfaces, NSGs, public IPs, NAT gateways, route tables
StoragestorageStorage accounts, file shares
DatabasedatabaseSQL servers, SQL databases, SQL elastic pools
ContainercontainerKubernetes clusters, container registries
SecuritysecurityKey vaults, role assignments, role definitions, user-assigned identities
Load BalancerlbLoad balancers, application gateways
CachingcachingRedis Cache instances
CDNcdnCDN profiles, CDN endpoints
DNSdnsDNS zones, DNS records
MessagingmessagingService Bus namespaces, queues, topics, subscriptions, Event Hub namespaces
MonitoringmonitorLog Analytics workspaces, action groups, metric alerts, portal dashboards
IntegrationintegrationAPI Management instances, APIs
ResourcesresourcesResource groups

Example Usage:

# Scan VMs in a resource group
terraback azure compute vm scan -g my-resource-group --output-dir ./output

# Scan all Azure resources
terraback azure scan-all -g my-resource-group --output-dir ./output

GCP Commands

gcp scan-all

Scan all available GCP resources.

terraback gcp scan-all [OPTIONS]

Service-Specific Commands

ServiceCLI CommandDescription
Compute EnginecomputeInstances, disks, instance templates
NetworknetworkVPC networks, subnets, firewall rules, routers, NAT gateways
StoragestorageCloud Storage buckets, Filestore instances
GKEgkeKubernetes clusters, node pools
Cloud SQLsqlSQL instances, SQL databases
Cloud FunctionsfunctionsCloud Functions
Pub/SubpubsubTopics, subscriptions
Cloud RuncloudrunCloud Run services
Load BalancerloadbalancerBackend services, URL maps, target proxies, forwarding rules
SecretssecretsSecrets
CachingcachingMemorystore Redis and Memcached instances
SecuritysecurityKMS key rings, crypto keys, Certificate Authority, Binary Authorization
Container RegistrycontainerregistryContainer registries
Certificate ManagercertificatemanagerCertificates, certificate maps
MessagingmessagingCloud Tasks queues
IntegrationintegrationAPI gateways, Workflows, Eventarc triggers
DatabasedatabaseFirestore, Bigtable, Spanner

Example Usage:

# Scan compute instances
terraback gcp compute scan-all --project-id my-project --region us-central1 --output-dir ./output

# Scan all GCP resources
terraback gcp scan-all --project-id my-project --region us-central1 --output-dir ./output

Import Commands

After a scan, bring the discovered resources under Terraform management with the provider-level import command. This is the fast path: with Terraform 1.5+ it uses import blocks to import every resource in a single operation instead of one terraform import call per resource.

terraback <aws|azure|gcp> import [OPTIONS]

Options:

OptionDescription
-o, --output-dir PATHDirectory containing the generated import files (default: generated)
-t, --terraform-dir PATHTerraform working directory (defaults to --output-dir)
-m, --method TEXTImport method: auto (detect best), bulk (fastest, Terraform 1.5+), or sequential (one-by-one, most reliable). Default: auto
--plan-checkRun a full terraform plan validation before importing; aborts on drift
--allow-driftAllow import to proceed even when --plan-check detects drift
-y, --yesSkip the confirmation prompt

Examples:

# Auto-detect the best method and import everything (with confirmation)
terraback aws import -o ./output

# Force bulk import (Terraform 1.5+ import blocks), no prompt
terraback aws import -o ./output --method bulk --yes

# Validate with a plan first, abort if drift is detected
terraback azure import -o ./output --plan-check

See the Import Guide for the full workflow and method comparison.

Analyse Commands

analyse state

Display the resources, modules, dependencies, and outputs in a Terraform state file, along with suggested module paths for each resource.

terraback analyse state [OPTIONS]

Options:

OptionDescription
--tfstate-file PATHPath to the .tfstate file (default: terraform.tfstate)

analyse summary

Show a summary of the resources in a Terraform state file.

terraback analyse summary [OPTIONS]

Options:

OptionDescription
--tfstate-file PATHPath to the .tfstate file (default: terraform.tfstate)

License Commands

license activate

Activate a license key.

terraback license activate LICENSE_KEY

license status

Show current license status.

terraback license status

license doctor

Diagnose and troubleshoot license issues.

terraback license doctor

license refresh

Force online license validation.

terraback license refresh

Cache Commands

cache stats

Show cache statistics.

terraback cache stats

cache clear

Clear all cached data.

terraback cache clear

cache invalidate

Invalidate specific cache entries.

terraback cache invalidate [OPTIONS]

Options:

OptionDescription
--service TEXTService name to invalidate cache for
--operation TEXTSpecific operation to invalidate

Examples:

# Clear all EC2 cache
terraback cache invalidate --service ec2

# Clear S3 cache
terraback cache invalidate --service s3

Clean Commands

clean

Clean generated files from a directory.

terraback clean [OPTIONS]

clean all

Clean all generated files including import files.

terraback clean all [OPTIONS]

Output Files

When scanning, Terraback generates:

File/DirectoryDescription
*.tfTerraform resource definitions
provider.tfProvider configuration
import/Import command JSON files
variables.tfVariable definitions (enterprise modules)
outputs.tfOutput definitions (enterprise modules)
modules/Module directory (enterprise modules)
config/Environment configurations (enterprise modules)

Common Options

These options are available on terraback scan all. Service-specific commands use --region, --output-dir, --profile (without short forms).

OptionDescriptionAvailable on
-o, --output-dirDirectory for generated files (default: ./generated)scan all
-r, --regionAWS region or GCP regionscan all
-p, --profileAWS profile namescan all
-g, --resource-groupAzure resource groupscan all, Azure commands
--project-idGCP project IDscan all, GCP commands
--with-depsScan dependencies automaticallyscan all, service commands
--enterprise-modulesGenerate organized module structurescan all
--parallel NNumber of parallel workers (1-32)scan all
--cache / --no-cacheCache API responses (OFF by default)scan all
--cache-encryptEncrypt cache files at rest (requires --cache)scan all
--all-regionsScan all enabled regions/locations in parallelscan all
--resumeResume an interrupted scanscan all
--previewRun terraform plan preview after scanscan all

Note: The table above describes scan all, where -r/--region accepts an AWS region, Azure location, or GCP region. When using Azure commands directly (terraback azure ..., outside of scan all), there is no --region flag — use --location (or -l) instead.

Exit Codes

CodeMeaning
0Success
1Error (authentication, permission, license, or general failure)