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

> Query existing cloud resources with the data block.

The `data` block is a read-only lookup of existing cloud resources. Data block outputs are always `Pending&lt;T&gt;`. Equivalent to Terraform's `data` source.

## Syntax

```hcl theme={null}
data "resource_type" "name" {
  attribute = value
}
```

## Examples

```hcl theme={null}
data "aws_vpc" "main" {
  filters = { "tag:Name" = "prod-vpc" }
}

data "aws_ami" "ubuntu" {
  most_recent = true
  filters     = { "name" = "ubuntu/images/*" }
  owners      = ["099720109477"]
}

data "aws_caller_identity" "current" {}
```

## Referencing Data Sources

Always `Pending&lt;T&gt;` — always require `~`:

```hcl theme={null}
unit "aws_instance" "app" {
  ami    = ~data.aws_ami.ubuntu.id
  vpc_id = ~data.aws_vpc.main.id
}
```

## Generated TypeScript

```typescript theme={null}
const main = pulumi.output(aws.ec2.getVpc({
    filters: [{ name: "tag:Name", values: ["prod-vpc"] }],
}));

const ubuntu = pulumi.output(aws.ec2.getAmi({
    mostRecent: true,
}));

const current = pulumi.output(aws.getCallerIdentity({}));
```

## Function Name Mapping

| ubx type              | TypeScript function       |
| --------------------- | ------------------------- |
| `aws_vpc`             | `aws.ec2.getVpc()`        |
| `aws_ami`             | `aws.ec2.getAmi()`        |
| `aws_subnet`          | `aws.ec2.getSubnet()`     |
| `aws_caller_identity` | `aws.getCallerIdentity()` |
| `aws_s3_bucket`       | `aws.s3.getBucket()`      |

## `filters` Attribute

```hcl theme={null}
data "aws_vpc" "main" {
  filters = { "tag:Name" = "prod-vpc" }
}
```

Compiled to Pulumi's filter array format:

```typescript theme={null}
filters: [{ name: "tag:Name", values: ["prod-vpc"] }]
```

## Error Cases

```hcl theme={null}
# Undefined reference — compile error
unit "aws_s3_bucket_v2" "b" {
  bucket = ~data.aws_vpc.missing.id
}
# ✗  ~data.aws_vpc.missing references an undeclared data block;
#    add: data "aws_vpc" "missing" { ... }
```
