> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ctrlplane.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Resource Providers Overview

> Sync infrastructure resources into Ctrlplane's inventory

Resource providers automatically discover and sync your infrastructure into
Ctrlplane's resource inventory. This enables dynamic environment targeting based
on resource metadata.

## Quick Start

All providers use the same pattern:

```bash theme={null}
# Set up authentication
export CTRLPLANE_API_KEY="your-api-key"

# Sync resources (one-time)
ctrlc sync <provider> [options]

# Sync on interval (continuous)
ctrlc sync <provider> --interval 5m [options]
```

## Common Patterns

### Continuous Sync

Run sync on an interval to keep resources up-to-date:

```bash theme={null}
# Sync every 5 minutes
ctrlc sync kubernetes --interval 5m --cluster-name prod-cluster

# Sync every hour
ctrlc sync aws eks --region us-east-1 --interval 1h
```

### Running in Kubernetes

Deploy a sync job as a Kubernetes CronJob or Deployment:

```yaml theme={null}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ctrlplane-sync
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ctrlplane-sync
  template:
    metadata:
      labels:
        app: ctrlplane-sync
    spec:
      containers:
        - name: sync
          image: ctrlplane/cli:latest
          command:
            - ctrlc
            - sync
            - kubernetes
            - --interval
            - "5m"
            - --cluster-name
            - "$(CLUSTER_NAME)"
          env:
            - name: CTRLPLANE_API_KEY
              valueFrom:
                secretKeyRef:
                  name: ctrlplane-credentials
                  key: api-key
            - name: CLUSTER_NAME
              value: "my-cluster"
```

## Resource Schema

All resources follow the same schema:

| Field        | Required | Description                                     |
| ------------ | -------- | ----------------------------------------------- |
| `identifier` | Yes      | Unique identifier (auto-generated by providers) |
| `name`       | Yes      | Human-readable name                             |
| `kind`       | Yes      | Resource type (e.g., `Kubernetes/Namespace`)    |
| `version`    | Yes      | Resource version                                |
| `metadata`   | No       | Key-value pairs for filtering and selectors     |
| `config`     | No       | Configuration passed to job agents              |

### Metadata vs Config

* **Metadata** — Used for environment selectors and filtering
* **Config** — Passed to job agents for deployment execution

```yaml theme={null}
# Metadata: used for targeting
metadata:
  environment: production
  region: us-east-1
  team: platform

# Config: used by job agents
config:
  namespace: my-app
  cluster_url: https://k8s.example.com
```

## Environment Selectors

Resources are matched to environments using selectors:

```yaml theme={null}
type: Environment
name: Production US
resourceSelector: |
  resource.metadata["environment"] == "production" &&
  resource.metadata["region"].startsWith("us-")
```

When resources are synced, environments automatically re-evaluate selectors.

## Next Steps

<CardGroup cols={2}>
  <Card title="Kubernetes" icon="dharmachakra" href="./kubernetes">
    Sync Kubernetes resources
  </Card>

  <Card title="AWS" icon="aws" href="./aws">
    Sync AWS resources
  </Card>

  <Card title="Google Cloud" icon="google" href="./google-cloud">
    Sync GCP resources
  </Card>

  <Card title="Custom Provider" icon="code" href="./custom">
    Build your own
  </Card>
</CardGroup>
