# Terraform to Provisioning Migration

Migrate existing Terraform configurations to Provisioning.

## Migration Strategy

### 1. Analyze Existing Terraform

```bash
# Count resources
terraform state list | wc -l

# Get resource details
terraform state show aws_instance.web
```

### 2. Create Nickel Equivalents

Terraform:
```hcl
resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t3.large"
  count         = 3

  tags = {
    Name = "web-server"
  }
}
```

Provisioning (Nickel):
```nickel
{
  servers = [
    {
      name = "web-01",
      instance_type = "t3.large",
      image = "ami-0c55b159cbfafe1f0",
      tags = { Name = "web-server" }
    },
    {
      name = "web-02",
      instance_type = "t3.large",
      image = "ami-0c55b159cbfafe1f0",
      tags = { Name = "web-server" }
    },
    {
      name = "web-03",
      instance_type = "t3.large",
      image = "ami-0c55b159cbfafe1f0",
      tags = { Name = "web-server" }
    }
  ]
}
```

### 3. Import Existing Resources

```bash
# Create state in Provisioning
provisioning resource import --resource-type server --id i-12345 --name web-01
```

### 4. Validate Configuration

```bash
provisioning infra validate --config migrated-config.ncl
```

### 5. Plan and Apply

```bash
# Plan migration
provisioning infra plan --config migrated-config.ncl --output plan.json

# Apply
provisioning infra apply --config migrated-config.ncl
```

## Key Differences

| Terraform | Provisioning |
| ----------| - -------------- |
| HCL syntax | Nickel (type-safe) |
| State file | Workspace state |
| Modules | Extensions |
| Variables | Nickel functions |
| Workspaces | First-class workspaces |

## Related Documentation

- [Nickel Guide](../infrastructure/nickel-guide.md)
- [Workspace Management](../features/workspace-management.md)
- [Configuration System](../infrastructure/configuration-system.md)
