Skip to main content

Prerequisites

  • ubx installed (run ubx version to verify)
  • AWS credentials in your environment (for the example below)
  • Python 3.9+ and pip on your PATH (for ubx ship)

1. Create a stack directory

mkdir networking
cd networking

2. Declare your inputs

Create input.xcl:
input "networking" {
    vpc_cidr: string       = "10.0.0.0/16"
    azs:      list(string)
    deploy_nat: bool       = false
}
Fields without a default are required at deploy time via pulumi config set.

3. Declare your resources

Create stack.xcl:
stack "networking" {
    vpc = aws.ec2.Vpc {
        cidr_block = input.vpc_cidr
    }

    subnets = aws.ec2.Subnet * 3 {
        for idx in input.azs

        vpc_id     = vpc.id
        cidr_block = "10.0.0.0/16"
    }

    nat = aws.ec2.NatGateway when input.deploy_nat {
        subnet_id = subnets.id
    }
}

4. Declare your outputs

Create output.xcl:
output "networking" {
    vpc_id     = vpc.id
    subnet_ids = subnets.id
}

5. Compile

ubx compile .
Expected output:
● Compile    . → .ubx/__main__.py
● Typecheck  3 file(s)
● IR         building…
● Output     .ubx/__main__.py

✓  compiled 3 file(s) → .ubx/__main__.py
The generated program is at .ubx/__main__.py. Inspect it before deploying.

6. Deploy

ubx ship .
ubx ship re-runs the full compile pipeline, then calls pulumi up via the Pulumi Automation API. State is stored in .ubx/state/.

7. Tear down

ubx terminate .
You will be prompted to confirm. Pass --force to skip the prompt.

What was created

networking/
  input.xcl
  stack.xcl
  output.xcl
  .ubx/
    __main__.py       ← generated Pulumi Python program
    requirements.txt  ← pulumi + provider packages
    Pulumi.yaml       ← project metadata (stack name = directory name)
    state/            ← local Pulumi state (created by ubx ship)

Next steps