ops0ops0

Importing Resources

After scanning, generate Terraform code for discovered resources and import them into IaC management. ops0 supports AI-assisted and direct code generation with multiple output formats.

Import Workflow

Select Resources

Choose resources to import from the discovery session.

Organize into Projects

Group selected resources into discovery projects by environment, application, or team.

Choose Generation Mode

Select AI-assisted or direct Terraform generation.

Configure State Backend

Set up the Terraform state backend (S3, Azure Blob, GCS, or local).

Review Code

Review the generated Terraform code before finalizing.

Import

Create an IaC project, download as ZIP, or push directly to GitHub.


Generation Modes

ops0 IaC code generation from discovered resources

AI-Assisted Generation

AI-powered code generation that produces optimized, production-ready Terraform:

  • Real-time security scanning during generation
  • Event streaming shows generation progress
  • Intelligent module grouping by resource type
  • Automatic variable extraction for configurable values
  • Best-practice patterns applied (naming, tagging, dependencies)

The AI generation uses streaming output so you can watch the code being generated in real time. If issues are detected during security scanning, they appear inline with suggestions.

Direct Generation

Generate Terraform code without AI, with progress tracking from 10 to 100 percent:

Output ModeFiles ProducedUse Case
Single filemain.tfQuick imports, small resource sets
Modular projectOrganized into modules by resource typeLarge environments, team collaboration
Flat importmain.tf + variables.tf + outputs.tfStandard Terraform import workflow

Resource Status

StatusMeaning
UnmanagedNot in any Terraform state; available for import
ManagedAlready managed by Terraform; skip or re-import

Filtering Resources

FilterDescription
TypeFilter by resource type (EC2, VPC, RDS, etc.)
RegionFilter by cloud region/location
TagsFilter by resource tags (Environment, Owner, etc.)
SearchFilter by name or resource ID

State Backend Configuration

Configure Terraform state backend for imported resources

Configure where Terraform stores state for the imported resources:

BackendConfiguration
S3Bucket, key, region, optional DynamoDB table for locking
Azure BlobStorage account, container, key
GCSBucket, prefix
LocalLocal filesystem path (single user only)
Recommended

Use S3, Azure Blob, or GCS for team environments. Local backends are suitable for individual testing only.


Generated Code

ops0 produces Terraform files with proper resource references and dependency ordering:

FileContents
main.tfResource definitions with actual cloud configuration
variables.tfVariable declarations for configurable values
outputs.tfOutput values for important resource attributes
imports.tfImport blocks for Terraform 1.5+

Example: Generated Import Block

import {
  to = aws_vpc.main
  id = "vpc-0abc123def456"
}

resource "aws_vpc" "main" {
  cidr_block           = "10.0.0.0/16"
  enable_dns_hostnames = true
  enable_dns_support   = true

  tags = {
    Name        = "production-vpc"
    Environment = "production"
  }
}

Modular Output Structure

When using modular generation, code is organized by resource type:

project-name/
├── main.tf
├── variables.tf
├── outputs.tf
├── imports.tf
└── modules/
    ├── networking/
    │   ├── vpc.tf
    │   ├── subnets.tf
    │   └── security_groups.tf
    ├── compute/
    │   └── instances.tf
    └── database/
        └── rds.tf

Import Destinations

After code generation, choose where to send the produced Terraform:

Link discovered resources to an IaC project in ops0

Create IaC Project

Create a new project in ops0 with the generated code already in place.

Download ZIP

Download all generated files as a ZIP archive for local review or handoff.

Push to GitHub

Sync the generated code directly to a connected GitHub repository.


GitHub Sync

Push generated Terraform code directly to a connected GitHub repository:

Select Repository

Choose a connected GitHub repository from the GitHub sync modal.

Choose Branch

Select an existing branch or create a new one.

Set Path

Configure the directory path within the repository.

Push

ops0 commits and pushes the generated code to the repository.


Regeneration

Discovery import complete — IaC project created from discovered resources

If the initial generation doesn't meet your needs, regenerate the code:

  • Adjust generation settings (output mode, module structure)
  • Re-run AI generation with different parameters
  • Regenerate for specific resources while keeping others

Troubleshooting

Import Failed

The resource may have been deleted or permissions may have changed. Re-run discovery to refresh the inventory.

Already Managed

The resource already exists in another Terraform state. Skip it here or remove it from the other state first.

Generation Timeout

Large batches can time out during AI generation. Split the import by resource type or environment.

State Lock

Another process is holding the Terraform state lock. Wait for it to clear or force unlock if the lock is stale.

Importing Best Practices
  • Import incrementally instead of bringing everything in at once.
  • Group related resources by environment or application.
  • Review generated Terraform before deploying.
  • Run terraform plan after import to verify the result.
  • Push to GitHub immediately so the imported state is versioned.