Skip to main content
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

module "name" {
    source = "..."
    // additional properties passed to the module
}

Source types

Local path

module "vpc" {
    source = "./modules/vpc"
    cidr   = input.vpc_cidr
    azs    = input.azs
}

Strata registry

module "vpc" {
    source  = "registry.ubiquex.io/vpc"
    version = "1.2.0"
    cidr    = input.vpc_cidr
}

npm package

module "vpc" {
    source = "@myorg/vpc-component"
    cidr   = input.vpc_cidr
}

Git

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):
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