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

# module

> The module block instantiates a reusable infrastructure module from a local path or registry.

The `module` block instantiates a reusable infrastructure module. Modules are composable units of infrastructure — a VPC module, an EKS cluster module, etc. — that can be sourced locally, from a registry, or from a Git repository.

## Syntax

```xcl theme={"theme":"css-variables"}
module "name" {
    source = "..."
    // additional properties passed to the module
}
```

## Source types

### Local path

```xcl theme={"theme":"css-variables"}
module "vpc" {
    source = "./modules/vpc"
    cidr   = input.vpc_cidr
    azs    = input.azs
}
```

### Strata registry

```xcl theme={"theme":"css-variables"}
module "vpc" {
    source  = "registry.ubiquex.io/vpc"
    version = "1.2.0"
    cidr    = input.vpc_cidr
}
```

### npm package

```xcl theme={"theme":"css-variables"}
module "vpc" {
    source = "@myorg/vpc-component"
    cidr   = input.vpc_cidr
}
```

### Git

```xcl theme={"theme":"css-variables"}
module "vpc" {
    source = "git::https://github.com/myorg/xcl-modules//vpc"
    cidr   = input.vpc_cidr
}
```

## Referencing module outputs

After declaring a module, its outputs are accessible as `moduleName.outputName`. Module outputs are **Pending** (resolved after deploy, not at compile time):

```xcl theme={"theme":"css-variables"}
module "vpc" {
    source = "./modules/vpc"
    cidr   = input.vpc_cidr
}

stack "s" {
    cluster = aws.eks.Cluster {
        vpc_id = vpc.outputs.vpc_id   // Pending<T>
    }
}
```

## Compile-time behavior

The typechecker registers the module name in scope and validates that properties reference valid names. It does **not** recursively typecheck the module's source files. Full module resolution happens at deploy time via Pulumi.

## Duplicate module names

A module name must be unique across all `.xcl` files in the stack:

```
"vpc" is already defined in modules.xcl:3 - remove one, or rename
```
