> ## 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.

# ubx upgrade

> Detect and apply deprecated resource type upgrades.

`ubx upgrade` scans `.iac` files for deprecated resource types and proposes replacements. Two phases: fast mechanical phase (no AI), then optional AI phase.

## Usage

```bash theme={null}
ubx upgrade [path] [flags]
```

## Examples

```bash theme={null}
ubx upgrade                  # check and upgrade all .iac files
ubx upgrade main.iac         # specific file
ubx upgrade --dry-run        # show diff without applying
ubx upgrade --yes            # apply without confirmation
ubx upgrade --check          # exit 1 if any upgrades needed (CI mode)
```

## Flags

| Flag        | Description                                              |
| ----------- | -------------------------------------------------------- |
| `--dry-run` | Show proposed diff without writing any files             |
| `--yes`     | Apply all upgrades without confirmation prompt           |
| `--check`   | Exit 1 if any upgrades are found; never writes (CI mode) |

## Output

```
--- main.iac ---
  aws_s3_bucket → aws_s3_bucket_v2: Renamed in AWS provider v4+

--- a/main.iac
+++ b/main.iac
@@ -3,3 +3,3 @@
-unit "aws_s3_bucket" "assets" {
+unit "aws_s3_bucket_v2" "assets" {
   bucket = "my-assets"
 }

Apply upgrade(s) to 1 file(s)? [y/N]
```

## Mechanical Upgrade Mappings

Applied instantly without an AI call:

| Deprecated                 | Current                             | Reason                      |
| -------------------------- | ----------------------------------- | --------------------------- |
| `aws_s3_bucket`            | `aws_s3_bucket_v2`                  | Renamed in AWS provider v4+ |
| `aws_rds_cluster_instance` | `aws_rds_cluster`                   | Consolidated in v5+         |
| `aws_elasticache_cluster`  | `aws_elasticache_replication_group` | Preferred for HA            |
| `kubernetes_deployment`    | `kubernetes_deployment_v1`          | API version update          |

## AI Phase

When `UBX_AI_API_KEY` is set, Claude is also consulted for additional upgrade suggestions against the full schema registry. Silently skipped if no key configured.

## CI Usage

```bash theme={null}
# Block CI if any resource types are outdated
ubx upgrade --check || exit 1
```
