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

# PlanetScale MySQL

> Managed PlanetScale MySQL with application credentials, safe migrations, and in-place cluster resizing.

**Type:** `rvn-planetscale-vitess` · **Latest version:** `0.1.0`

## Readme

Managed PlanetScale MySQL with application credentials, safe migrations, and in-place cluster resizing.

### Overview

Creates one Vitess database with a main branch, manages its default keyspace,
and generates a read/write application credential. Each module instance owns
its database. The initial size is PS-10; safe migrations and deletion protection
are enabled. PlanetScale's built-in backups remain in effect.

### Use cases

| Scenario | Benefit |
| - | - |
| MySQL application | Provision the database and consume its connection outputs. |
| Growing workload | Resize the default keyspace without replacing the branch. |
| Separate Ravion environments | Give each environment its own database and lifecycle. |

### Provisioning

Uses the standard Ravion Terraform change and destroy pipelines. No separate
PlanetScale pipeline or pipeline ID is required.

The first deployment creates the branch at the selected size, its default
keyspace, and application credentials. From the second deployment, the module
automatically imports that existing keyspace into Terraform state and manages
its size and extra replicas. An import can resize it in the same apply; it
does not copy data or create another keyspace. Extra replicas are first applied
on the second deployment, even if configured initially.

### Configuration

| Setting | Behavior |
| - | - |
| PlanetScale integration | Required active connection from Settings → Integrations. Supplies the organization and short-lived credentials. |
| Database name | Generated from project, environment and module names. |
| Database region | Required PlanetScale region slug, such as us-east; choose a Vitess-supported region near the application. |
| Cluster size | PS-10 by default. Region availability and pricing vary. |
| Extra replicas | Zero by default; reconciled from the second deployment. Additional replicas increase cost. |
| Application credential CIDRs | Empty by default (no source-IP restriction). Enter CIDR ranges to restrict access. |
| Deletion protection | Enabled. Disable and apply before destroying; Terraform deletes the default keyspace before the branch. |
| Safe migrations | Enabled. Main-branch schema changes require PlanetScale deploy requests. |
| Terraform execution environment | Runner location; independent of database placement. Each Terraform step has a 45-minute timeout. |

### Metrics

Declares 63 native branch/tablet chart candidates using the saved integration.
Metrics work from the first successful deployment; no keyspace adoption,
CloudWatch account, exporter, or separate metrics database setting is required.
Shard, tablet, and availability-zone series remain separate. Missing or
engine-specific metrics are shown as unavailable rather than zero.

Metrics currently preserve raw native values. Unit/rate semantics and live
availability are not fully verified; metric support depends on the engine,
topology, and activity of the branch.

### Application connections

Connect with the host, port, database\_name, username and sensitive password
outputs. A sensitive connection\_string is also available. Configure TLS
certificate and hostname verification in your MySQL driver; clients use
different TLS options. Passwords are stored in Terraform state.

The application credential has read/write data access. Schema migration
credentials and PlanetScale deploy-request workflows are separate concerns.

### Advanced configuration

Uses the same Terraform settings as other Ravion modules: OpenTofu version
override, Ravion Terraform workspace name, and Advanced Terraform variables.
Change and destroy pipelines inherit the environment's normal pipeline defaults;
configure those defaults at organization, project, or environment scope, not as
PlanetScale-specific module inputs. Advanced Terraform variables override the
generated variables.

Advanced Terraform variables can configure additional keyspaces and passwords,
VTGate sizing/autoscaling, and custom backup policies. These options can add
charges. Custom backups are optional; built-in backups remain available
without them. Cluster sizes are listed for the selected organization and
region, including Metal SKUs with their NVMe disk capacity. Additional branches,
VSchema and deploy requests are outside this release's scope.

### Design decisions

Database identity and region are fixed after creation. Compute sizing remains
editable. The first deployment uses PlanetScale's automatically-created default
keyspace. Later deployments adopt it automatically, using the previous
deployment's branch ID; they never create a second default keyspace. On
destroy, Terraform deletes an already-imported default keyspace before
deleting the branch. Disable branch deletion protection and apply first.
This deletion order needs verification with a disposable PlanetScale database
before production use. No AWS resources are needed for the PlanetScale
database itself; AWS is used by the Terraform runner and short-lived secret
delivery. Plan, apply, and destroy each use their own temporary token from
the selected integration; no bootstrap credential reaches the runner.

### Learn more

* [PlanetScale Terraform provider](https://planetscale.com/docs/terraform)
* [Vitess cluster configuration](https://planetscale.com/docs/vitess/cluster-configuration)
* [PlanetScale pricing](https://planetscale.com/pricing)

## Inputs reference

All inputs for `rvn-planetscale-vitess` version `0.1.0`. Use the `name` shown for each field as the input key in module config.

### PlanetScale integration

<ResponseField name="planetscale" type="string" required>
  **PlanetScale integration.** Select an active integration from Settings → Integrations. The organization and short-lived credentials come from this connection.

  * Immutable after creation
</ResponseField>

### Database

<ResponseField name="name" type="string" required>
  **Database name.**

  * Default: `<< project.given_id >>-<< environment.given_id >>-<< module.given_id >>`
  * Immutable after creation
  * Pattern: `^[a-z0-9]([a-z0-9-]{0,62}[a-z0-9])?$` — 1-64 lowercase letters, numbers, and hyphens. Start and end with a letter or number.
</ResponseField>

<ResponseField name="region" type="string" required>
  **Database region.** Choose a MySQL region available to the selected PlanetScale organization near your application.

  * Immutable after creation
</ResponseField>

<ResponseField name="cluster_size" type="string" required>
  **Cluster size.** Choose a regional MySQL size. Metal options include local NVMe disk capacity in the SKU. Compute is per instance; the cluster includes a primary and two replicas. Changes resize in place.

  * Default: `PS_10`
</ResponseField>

<ResponseField name="extra_replicas" type="number">
  **Extra replicas.** Additional replicas beyond PlanetScale's included replicas; increases cost. Applied from the second deployment, after automatic default-keyspace adoption.

  * Default: `0`
  * Min: `0`
</ResponseField>

<ResponseField name="application_password_cidrs" type="string_array">
  **Application credential CIDRs.** Restrict application connections to these IPv4 or IPv6 CIDR ranges. Empty permits connections from any source IP.

  * Default: `[]`
</ResponseField>

<ResponseField name="deletion_protection_enabled" type="boolean">
  **Deletion protection.** Disable and apply before destroying the database. The default keyspace is deleted before the branch.

  * Default: `true`
</ResponseField>

<ResponseField name="safe_migrations_enabled" type="boolean">
  **Safe migrations.** Require PlanetScale deploy requests for schema changes. Disable only when direct DDL on main is intended.

  * Default: `true`
</ResponseField>

### Terraform settings

<ResponseField name="opentofu_version" type="string">
  **OpenTofu version override.** Override the environment's default version for this module
</ResponseField>

<ResponseField name="ravion_state_backend_workspace" type="string">
  **Ravion Terraform workspace name.** Override Terraform state backend workspace name. Defaults to project + environment + module given ids.

  * Immutable after creation
</ResponseField>

<ResponseField name="terraform_plan_default_policies_enabled" type="boolean">
  **Include default plan policies.** Turn off to plan with only the policies below instead of the default read-only policies. Requires at least one policy below.

  * Default: `true`
</ResponseField>

<ResponseField name="terraform_plan_iam_policy_arns" type="string_array">
  **Terraform plan IAM policies.** IAM managed policy ARNs for the Terraform plan runner role. Without default policies, allow s3:CreateBucket, s3:PutObject, s3:GetObject, and s3:ListBucket on the ravion-terraform-plans-\<AWS account number> bucket in this account.

  * Default: `[]`
</ResponseField>

<ResponseField name="terraform_apply_default_policies_enabled" type="boolean">
  **Include default apply policies.** Turn off to apply and destroy with only the policies below instead of AdministratorAccess. Requires at least one policy below.

  * Default: `true`
</ResponseField>

<ResponseField name="terraform_apply_iam_policy_arns" type="string_array">
  **Terraform apply IAM policies.** IAM managed policy ARNs for the Terraform apply runner role. Without default policies, allow s3:CreateBucket, s3:PutObject, s3:GetObject, and s3:ListBucket on the ravion-terraform-plans-\<AWS account number> bucket in this account.

  * Default: `[]`
</ResponseField>

<ResponseField name="advanced_terraform_variables" type="object">
  **Advanced Terraform variables.** Optional raw Terraform variable overrides for advanced module inputs or one-off overrides. Values here override the generated variables above.

  * Default: `{}`
</ResponseField>

<ResponseField name="execution_environment_id" type="string" required>
  **Terraform execution environment.** Runs OpenTofu with short-lived credentials from the selected integration. This does not select the database's cloud account or region.

  * Default: `<< defaults.execution_environment_id >>`
</ResponseField>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.