2 Likes
Hi,
Deploy buttons are great!
I have a question though. How do we deal with KV namespaces ?
I currently associate the KV name to id in wrangler.toml but how does it work for user deploying a new worker with id that do not match ?
Is there a way to ensure that when they deploy they have their KV automatically created ?
Afaik there is no support for auto-creating KV namespaces in Wrangler Actions. However, I managed to work around with preCommand
preCommands: |
wrangler kv:namespace create KV_NAMESPACE_NAME
apt-get update && apt-get install -y jq
kv_namespace_id=$(wrangler kv:namespace list | jq -c 'map(select(.title | contains("KV_NAMESPACE_NAME")))' | jq ".[0].id")
echo "[env.production]" >> wrangler.toml
echo "kv_namespaces = [{binding=\"KV_NAMESPACE_NAME\", id=${kv_namespace_id}}]" >> wrangler.toml
1 Like
We might have soon, free Workers KV to try across accounts, that will solve this issue.
2 Likes
Here it is: