Prerequisites
- A PlanetScale service token with these permissions on the database:
connect_branchanddelete_branch_passwordfor a development branchconnect_production_branchanddelete_production_branch_passwordfor a production branch
- A role in the Infisical project that lets you create dynamic secrets
Step 1: Create the dynamic secret
1
In your project, go to the environment and folder where you want the dynamic secret, then select Add New > Add Dynamic Secret.
2
Select PlanetScale Vitess.
3
Fill in the form:
How long a lease lasts if the person creating it doesn’t choose a TTL (for example,
1h).The value of your PlanetScale service token. When you edit the dynamic secret, leave this blank to keep the current token.
The role that each password gets: Read-only, Write-only, Read/write, or Admin.
The name each password gets in PlanetScale, under Advanced. The default gives each password a random name. PlanetScale names must be unique on the branch and can only contain up to 63 lowercase letters, numbers, and dashes. Infisical lowercases the name, turns other characters into dashes, shortens it if needed, and adds a random suffix. You can use
{{dynamicSecret.name}}, {{identity.name}}, {{unixTimestamp}}, and {{randomUsername}} to make the passwords easier to find in PlanetScale.You can’t change the organization, database, or branch while the dynamic secret has active leases. Revoke the leases first.
4
Select Submit.Before Infisical saves the dynamic secret, it checks that the service token can access the branch. If PlanetScale rejects the token, PlanetScale can’t find the branch, or the database doesn’t run Vitess, Infisical shows the error and doesn’t save the dynamic secret.
Step 2: Create a lease
1
In the row for the dynamic secret, select Generate Lease.
2
Enter a Default TTL for the lease, then select Provision Lease.
3
Copy the values Infisical shows:
DB_HOST: the PlanetScale host to connect toDB_USERNAME: the MySQL usernameDB_PASSWORD: the MySQL password
Revoke a lease
Select the dynamic secret to see its leases, then select Revoke lease next to a lease to delete its password in PlanetScale before the lease expires. When a lease expires, Infisical deletes its password. PlanetScale also stops accepting the password when the lease expires, even if Infisical can’t delete it. You can’t renew a PlanetScale lease. To keep access, create a new lease before the current one expires.If the service token can’t delete passwords on the branch, revoking a lease fails and the password keeps working until the lease expires. Grant the token
delete_branch_password (delete_production_branch_password for a production branch), then revoke the lease again.