An open API service indexing awesome lists of open source software.

https://github.com/sparkfabrik/terraform-typesense-keys

Terraform module to manage Typesense keys
https://github.com/sparkfabrik/terraform-typesense-keys

iac infrastructure-as-code terraform typesense

Last synced: 5 months ago
JSON representation

Terraform module to manage Typesense keys

Awesome Lists containing this project

README

          

# Typesense Keys Module

This module creates Typesense API keys and optionally a Kubernetes secret.

## What it creates

- **Read-only API key**: For document search operations.
- **Full access API key**: For all Typesense operations.
- **Kubernetes secret**: Contains host URL, API keys, and collection prefix (optional).

## Diagram
```mermaid
flowchart LR
typesense_module["Typesense Keys Module"] -- "generates" --> api_keys["API Keys (RO + Full Access)"]
api_keys -- "stored in" --> k8s_secret["Kubernetes Secret"]
terraform_config["Terraform Config"] -- "configures" --> typesense_provider["Typesense Provider"]
typesense_provider -- "manages" --> typesense_module
projects["Projects"] -- "consumes" --> k8s_secret
```
## Usage

### Basic usage with collection prefix

```terraform
module "typesense_keys" {
source = "github.com/sparkfabrik/terraform-typesense-keys?ref=X.Y.Z"

collection_prefix = "myproject"
secret_namespace = "myproject-stage"
secret_name = "myproject-typesense"
typesense_external_host = "typesense.example.com"
typesense_external_port = 443
typesense_external_proto = "https"
typesense_internal_host = "typesense.default.svc.cluster.local"
typesense_internal_port = 8108
typesense_internal_proto = "http"
}
```

### Without collection prefix (all collections)

If you omit the `collection_prefix`, the API keys will have access to all collections (`*`):

```terraform
module "typesense_keys" {
source = "github.com/sparkfabrik/terraform-typesense-keys?ref=X.Y.Z"

secret_namespace = "myproject-stage"
secret_name = "myproject-typesense"
typesense_external_host = "typesense.example.com"
typesense_internal_host = "typesense.default.svc.cluster.local"
}
```

### Without Kubernetes secret

If you only need the API keys without creating a Kubernetes secret, omit the `secret_name`:

```terraform
module "typesense_keys" {
source = "github.com/sparkfabrik/terraform-typesense-keys?ref=X.Y.Z"

collection_prefix = "myproject"
typesense_external_host = "typesense.example.com"
typesense_internal_host = "typesense.default.svc.cluster.local"
}
```

## Providers

| Name | Version |
|------|---------|
| [kubernetes](#provider\_kubernetes) | >= 2.21 |
| [random](#provider\_random) | >= 3.4.3 |
| [typesense](#provider\_typesense) | 0.0.5 |

## Requirements

| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.2 |
| [kubernetes](#requirement\_kubernetes) | >= 2.21 |
| [random](#requirement\_random) | >= 3.4.3 |
| [typesense](#requirement\_typesense) | 0.0.5 |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [collection\_prefix](#input\_collection\_prefix) | The collection prefix for Typesense keys | `string` | `""` | no |
| [secret\_name](#input\_secret\_name) | The name of the Kubernetes secret | `string` | `""` | no |
| [secret\_namespace](#input\_secret\_namespace) | The Kubernetes namespace where the secret will be created | `string` | `""` | no |
| [typesense\_external\_host](#input\_typesense\_external\_host) | The Typesense host URL | `string` | n/a | yes |
| [typesense\_external\_port](#input\_typesense\_external\_port) | The Typesense port | `number` | `443` | no |
| [typesense\_external\_proto](#input\_typesense\_external\_proto) | The Typesense protocol | `string` | `"https"` | no |
| [typesense\_internal\_host](#input\_typesense\_internal\_host) | The Typesense host URL | `string` | n/a | yes |
| [typesense\_internal\_port](#input\_typesense\_internal\_port) | The Typesense port | `number` | `8108` | no |
| [typesense\_internal\_proto](#input\_typesense\_internal\_proto) | The Typesense protocol | `string` | `"http"` | no |

## Outputs

| Name | Description |
|------|-------------|
| [secret\_name](#output\_secret\_name) | The name of the created Kubernetes secret |
| [secret\_namespace](#output\_secret\_namespace) | The namespace of the created Kubernetes secret |

## Resources

| Name | Type |
|------|------|
| [kubernetes_secret_v1.typesense_credentials](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/secret_v1) | resource |
| [random_password.full_access_key](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
| [random_password.readonly_key](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
| [typesense_key.full_access](https://registry.terraform.io/providers/cysp/typesense/0.0.5/docs/resources/key) | resource |
| [typesense_key.readonly](https://registry.terraform.io/providers/cysp/typesense/0.0.5/docs/resources/key) | resource |

## Modules

No modules.