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

# data

> The data binding looks up existing cloud resources without managing them.

A `data` binding reads information about an existing cloud resource without bringing it under ubx management. It's the equivalent of Terraform's `data` sources. Data bindings live inside a `stack` body, next to regular resource declarations.

## Syntax

```xcl theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
binding_name = data provider.namespace.Type {
  // filter/lookup properties
}
```

Data sources use the same dotted type paths as resources, with the `data` keyword in front.

## Example

Look up the latest Amazon Linux 2 AMI, then use it:

```xcl theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
stack compute {
  ami = data aws.ec2.Ami {
    owners      = ["amazon"]
    most_recent = true
    filters = [
      { name = "name",                values = ["amzn2-ami-hvm-*-x86_64-gp2"] },
      { name = "virtualization-type", values = ["hvm"] }
    ]
  }

  instance = aws.ec2.Instance {
    ami           = ami.id        // resolved at apply time
    instance_type = input.instance_type
  }
}
```

## Look up an existing VPC

```xcl theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
stack application {
  existing_vpc = data aws.ec2.Vpc {
    filters = [{ name = "tag:Name", values = ["prod-vpc"] }]
  }

  subnet = aws.ec2.Subnet {
    vpc_id     = existing_vpc.id
    cidr_block = "10.0.99.0/24"
  }
}
```

## Data source outputs

Attributes read from a data source are **pending values** — they are fetched at apply time from the cloud provider, and the typechecker tracks them the same way it tracks resource outputs:

```xcl theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
ami.id
ami.architecture
existing_vpc.id
```

## In generated code

For the Pulumi Python engine, a data binding compiles to the provider's `get_*` lookup function; for the Terraform and OpenTofu engines it becomes a `data` block in `main.tf`.
