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

# extend block

> Override specific attributes per environment without duplicating config.

The `extend` block overrides specific attributes of an existing block for a target environment. Non-overridden attributes are inherited from base. No Terraform equivalent.

## Syntax

```hcl theme={null}
# For unit, deploy, sync (three labels):
extend "unit" "resource_type" "name" {
  attribute = override_value
}

# For component (two labels — no type):
extend "component" "name" {
  attribute = override_value
}
```

## Example

```hcl theme={null}
# main.iac — base definitions
unit "aws_rds_instance" "db" {
  engine            = "postgres"
  instance_class    = "db.t3.micro"   # staging default
  allocated_storage = 20
  multi_az          = false
  username          = "admin"
  password          = secret("aws_secrets_manager", "staging/db/password")
  skip_final_snapshot = true
}

# envs/prod/overrides.iac — prod overrides
extend "unit" "aws_rds_instance" "db" {
  instance_class    = "db.r6g.xlarge"
  allocated_storage = 100
  multi_az          = true
  password          = secret("aws_secrets_manager", "prod/db/password")
}
```

```bash theme={null}
ubx apply              # staging — db.t3.micro, single-az
ubx apply --env prod   # prod    — db.r6g.xlarge, multi-az
```

## File Layout

```
project/
  main.iac
  envs/
    prod/
      overrides.iac
    staging/
      overrides.iac
```

## Supported Block Types

| Block       | Syntax                                         |
| ----------- | ---------------------------------------------- |
| `unit`      | `extend "unit" "resource_type" "name" { ... }` |
| `deploy`    | `extend "deploy" "type" "name" { ... }`        |
| `sync`      | `extend "sync" "type" "name" { ... }`          |
| `component` | `extend "component" "name" { ... }`            |

`input`, `output`, `local`, and `extend` blocks cannot be extended.

## Validation

* Target block must exist in the base files
* Unknown attributes pass through without schema check
