-
Notifications
You must be signed in to change notification settings - Fork 10.4k
thomasgauvin: add credential rotation methods to hyperdrive #17464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Oxyjun
merged 10 commits into
production
from
thomasgauvin/update-hyperdrive-to-add-connection-string-rotating
Oct 11, 2024
+51
−0
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9979064
thomasgauvin: add credential rotation methods to hyperdrive
thomasgauvin 94d16db
thomasgauvin:rename file and add note to update in situ
thomasgauvin b1a1bce
Apply suggestions from code review
Oxyjun e698d2f
Update src/content/docs/hyperdrive/configuration/rotate-credentials.mdx
thomasgauvin c707605
Update src/content/docs/hyperdrive/configuration/rotate-credentials.mdx
thomasgauvin 14eef0a
Update src/content/docs/hyperdrive/configuration/rotate-credentials.mdx
thomasgauvin dd9b0be
Update src/content/docs/hyperdrive/configuration/rotate-credentials.mdx
thomasgauvin 9d357c9
Apply suggestions from code review
thomasgauvin f16d572
Update src/content/docs/hyperdrive/configuration/rotate-credentials.mdx
thomasgauvin b8489fd
Update src/content/docs/hyperdrive/configuration/rotate-credentials.mdx
thomasgauvin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/content/docs/hyperdrive/configuration/rotate-credentials.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| --- | ||
| pcx_content_type: concept | ||
| title: Rotating database credentials | ||
| sidebar: | ||
| order: 8 | ||
| --- | ||
|
|
||
| import { TabItem, Tabs, Render } from "~/components"; | ||
|
|
||
| You can change the connection information and credentials of your Hyperdrive configuration in one of two ways: | ||
|
|
||
| 1. Create a new Hyperdrive configuration with the new connection information, and update your Worker to use the new Hyperdrive configuration. | ||
| 2. Update the existing Hyperdrive configuration with the new connection information and credentials. | ||
|
|
||
| ## Use a new Hyperdrive configuration | ||
|
|
||
| Creating a new Hyperdrive configuration to update your database credentials allows you to keep your existing Worker configuration unchanged, gradually migrate your Worker to the new Hyperdrive configuration, and easily roll back to the previous configuration if needed. | ||
|
|
||
| To create a Hyperdrive that connects to an existing PostgreSQL database, use the [Wrangler](/workers/wrangler/install-and-update/) CLI or the [Cloudflare dashboard](https://dash.cloudflare.com/?to=/:account/workers-and-pages/hyperdrive). | ||
thomasgauvin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```sh | ||
| # wrangler v3.11 and above required | ||
| npx wrangler hyperdrive create my-updated-hyperdrive --connection-string="<YOUR_CONNECTION_STRING>" | ||
| ``` | ||
|
|
||
| The command above will output the ID of your Hyperdrive. Set this ID in the `wrangler.toml` configuration file for your Workers project: | ||
|
|
||
| ```toml | ||
| # required for database drivers to function | ||
| compatibility_flags = [ "nodejs_compat" ] | ||
| compatibility_date = "2024-09-23" | ||
|
|
||
| [[hyperdrive]] | ||
| binding = "HYPERDRIVE" | ||
| id = "<your-hyperdrive-id-here>" | ||
| ``` | ||
|
|
||
| To update your Worker to use the new Hyperdrive configuration, redeploy your Worker or use [gradual deployments](/workers/configuration/versions-and-deployments/gradual-deployments/). | ||
|
|
||
| ## Update the existing Hyperdrive configuration | ||
|
|
||
| You can update the configuration of an existing Hyperdrive configuration using the [wrangler CLI](/workers/wrangler/install-and-update/). | ||
|
|
||
| ```sh | ||
| # wrangler v3.11 and above required | ||
| npx wrangler hyperdrive update <HYPERDRIVE_CONFIG_ID> --origin-host <YOUR_ORIGIN_HOST> --origin-password <YOUR_ORIGIN_PASSWORD> --origin-user <YOUR_ORIGIN_USERNAME> --database <YOUR_DATABASE> --origin-port <YOUR_ORIGIN_PORT> | ||
| ``` | ||
|
|
||
| :::note | ||
| Updating the settings of an existing Hyperdrive configuration does not purge Hyperdrive's cache and does not tear down the existing database connection pool. New connections will be established using the new connection information. | ||
| ::: | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.