Skip to main content
The input block declares typed fields that parameterize a stack. At deploy time, values are provided via Pulumi config (pulumi config set key value). In the generated Python program, inputs become pulumi.Config() calls.

Syntax

input "name" {
    field_name: Type
    field_with_default: Type = default_value
}

Example

input "networking" {
    vpc_cidr:     string       = "10.0.0.0/16"
    azs:          list(string)
    deploy_nat:   bool         = false
}
Generated Python:
config = pulumi.Config()

vpc_cidr    = config.get("vpc_cidr") or "10.0.0.0/16"
azs         = config.require_object("azs")
deploy_nat  = config.get_bool("deploy_nat") or False

Referencing inputs

Input fields are accessed via the input.fieldName qualified form — bare field names are not in scope:
stack "networking" {
    vpc = aws.ec2.Vpc {
        cidr_block = input.vpc_cidr   // correct
        // cidr_block = vpc_cidr     // error: undefined reference "vpc_cidr"
    }
}
When you have multiple input blocks (e.g., one per file), you can disambiguate with input.blockName.fieldName:
// networking-inputs.xcl
input "base" {
    region: string = "us-east-1"
}

// advanced-inputs.xcl
input "advanced" {
    region: string = "eu-west-1"  // would conflict with base.region
}

// In expressions:
provider "aws" {
    region = input.base.region
}

Optional fields (with default)

A field with a default value is optional at deploy time. The default is used when the config key is not set:
input "s" {
    instance_type: string = "t3.micro"
    count:         int    = 1          // ERROR: "count" is a reserved name
}

Required fields (no default)

A field without a default must be provided via pulumi config set before deploying:
input "s" {
    db_password: string   // required — no default
    db_name:     string
}

Supported types

All XCL types are valid for input fields. See Types for the full list. Primitive types map to typed Pulumi config accessors:
  • stringconfig.get() / config.require()
  • boolconfig.get_bool() / config.require_bool()
  • numberconfig.get_float() / config.require_float()
  • intconfig.get_int() / config.require_int()
  • any, list(T), map(T), object(...), tuple(...)config.require_object()

Default value type checking

The typechecker verifies that default values are compatible with the declared type:
input "s" {
    timeout: number = "30s"  // error: default value is a string literal but field type is number
    enabled: bool   = 1      // error: default value is a number literal but field type is bool
}

Reserved field names

The following names cannot be used as input field names (they are reserved reference namespaces): stack, input, output, locals, module, provider, import, space, root, for, when, match, default, count, each Error: "count" is a reserved reference namespace - choose a different name

Multiple input blocks

A stack may have multiple input blocks (typically one per .xcl file). All fields across all input blocks share a flat namespace — duplicate field names across blocks are an error:
// Error:
// file-a.xcl
input "a" { region: string }
// file-b.xcl
input "b" { region: string }  // "region" is already defined in file-a.xcl:2 - remove one, or rename