import block is how you bring them under management: you write a unit block describing the resource’s desired configuration, add a matching import block with the resource’s cloud provider ID, and on the next ubx apply, Pulumi reads the live resource’s state, writes it into Pulumi’s state file, and begins managing it going forward. No recreation. No downtime. No data loss.
What you’ll learn
- How
importbrings an existing cloud resource under ubx management - How the
idvalue maps to the cloud provider’s resource identifier - What happens at validate time vs apply time
Why this matters
ubx validate only checks the import block’s syntax — it does not contact AWS to verify the resource exists. The actual import (writing the resource into Pulumi state) happens on the first ubx apply, which requires AWS credentials and the resource to already exist in your account.The source code
How it works
ubx validate checks syntax only
ubx validate confirms the import block’s type and name match an existing unit block, and that the id field is present. It does not contact AWS or verify the resource exists. Validation passes even if the bucket doesn’t exist yet.ubx apply reads the live resource state
On the first apply after an
import block is added, Pulumi calls the AWS API to read the resource’s current configuration and writes it into the Pulumi state file. The resource is now tracked in state as if it had been created by Pulumi originally.What ubx generates
Common mistakes
Run it
What you learned
import brings an existing cloud resource under ubx management without recreating itubx validate only checks syntax — the actual import requires AWS credentials and the resource to existRemove the
import block after the first successful apply — the resource is now in Pulumi stateNext steps
moved block
Rename a resource in state without destroying it
import block reference
Full import block syntax and provider ID formats
Full runnable example: github.com/ubiquex/ubx-examples/31-import-existing-resource

