> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ubiquex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrating from Pulumi

> Convert existing Pulumi TypeScript programs to ubx .iac files.

If you have existing Pulumi TypeScript programs, `ubx convert --from pulumi` converts them to ubx `.iac` format.

## Quick Migration

```bash theme={null}
ubx convert --from pulumi index.ts
ubx convert --from pulumi ./pulumi/
ubx convert --from pulumi ./pulumi/ --out ./iac/
```

## TypeScript Conversion (Mechanical)

Pulumi TypeScript is mechanically converted for common patterns:

```typescript theme={null}
// Pulumi TypeScript
const bucket = new aws.s3.BucketV2("assets", {
    bucket: `${env}-assets`,
    forceDestroy: true,
});

export const bucketName = bucket.bucket;
```

Converts to:

```hcl theme={null}
unit "aws_s3_bucket_v2" "assets" {
  bucket        = "${input.env}-assets"
  force_destroy = true
}

output "bucket_name" {
  value = ~unit.aws_s3_bucket_v2.assets.bucket
}
```

## Python and Go (AI-Assisted)

Python and Go conversions require `UBX_AI_API_KEY`:

```bash theme={null}
export UBX_AI_API_KEY=sk-ant-...
ubx convert --from pulumi __main__.py    # Python
ubx convert --from pulumi main.go        # Go
```

## Key Differences

| Pulumi TypeScript                    | ubx                                    |
| ------------------------------------ | -------------------------------------- |
| `new aws.s3.BucketV2("name", {...})` | `unit "aws_s3_bucket_v2" "name" {...}` |
| `bucket.bucket`                      | `~unit.aws_s3_bucket_v2.name.bucket`   |
| `export const x = ...`               | `output "x" { value = ... }`           |
| `pulumi.Config().get("env")`         | `input "env" { type = "string" }`      |
| `pulumi.all([a, b]).apply(...)`      | handled automatically by `~`           |

## After Migration

```bash theme={null}
ubx validate          # check for errors
ubx validate --compile  # also check generated TypeScript
ubx plan              # preview
ubx explain           # understand the converted infrastructure
```
