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

# Adding Resource Types

> How to add new provider resource types to ubx.

ubx validates resource attributes against a schema registry. To add support for new resource types, you update the schema registry.

## Schema Registry Location

```
internal/compiler/schema/
  aws.go        # AWS resource schemas
  gcp.go        # GCP resource schemas
  azure.go      # Azure resource schemas
  kubernetes.go # Kubernetes resource schemas
```

## Schema Format

Each resource type is a `ResourceSchema` struct:

```go theme={null}
// internal/compiler/schema/aws.go

var awsSchemas = map[string]ResourceSchema{
    "aws_s3_bucket_v2": {
        Required: []string{},
        Optional: []string{
            "bucket", "force_destroy", "tags", "acl",
            "object_lock_enabled", "policy",
        },
        Tags: true,  // supports default_tags injection
    },
    "aws_rds_instance": {
        Required: []string{"engine", "instance_class"},
        Optional: []string{
            "allocated_storage", "username", "password",
            "skip_final_snapshot", "multi_az", "storage_encrypted",
        },
        Tags: true,
    },
}
```

## Adding a New Resource

1. Find the resource in the [Pulumi AWS Registry](https://www.pulumi.com/registry/packages/aws/)
2. Add a new entry to the appropriate schema file:

```go theme={null}
"aws_cloudfront_distribution": {
    Required: []string{"origin", "default_cache_behavior", "restrictions", "viewer_certificate"},
    Optional: []string{
        "aliases", "comment", "enabled", "price_class", "tags",
    },
    Tags: true,
},
```

3. Add the resource type to the codegen registry:

```go theme={null}
// internal/compiler/codegen/registry.go
"aws_cloudfront_distribution": {
    Import:    "aws",
    Module:    "cloudfront",
    ClassName: "Distribution",
},
```

4. Write a test in `internal/compiler/schema/aws_test.go`

5. Run `go test ./...`

## Updating via Schema Sync

For bulk updates, the `ubx schema sync` command fetches schemas directly from Pulumi's JSON schema endpoint and updates the registry automatically:

```bash theme={null}
ubx schema sync aws
```

## Opening an Issue

If a resource type you need is missing, [open a GitHub issue](https://github.com/ubiquex/ubx/issues) with the resource type name and a link to the Pulumi registry page.
