Is it possible to specify different Hyperdrives for different environments in TOML?

I need to specify stage and live environments in my TOML. The stage one has its own Hyperdrive, while production needs to have two differen Hyperdrives (production connects to one of two databases depending on user). Is this possible? Thank you.
4 Replies
kian
kian13mo ago
[[env.foo.hyperdrive]]
foo = "bar"

[[env.bar.hyperdrive]]
foo = "baz"
[[env.foo.hyperdrive]]
foo = "bar"

[[env.bar.hyperdrive]]
foo = "baz"
In JSON, Wrangler's config looks like this - all non-inheritable keys (i.e bindings) need to be defined on a per-environment basis but otherwise it's just standard TOML.
{
"env": {
"foo": {
"hyperdrive": [{}]
}
}
}
{
"env": {
"foo": {
"hyperdrive": [{}]
}
}
}
Mitya
MityaOP13mo ago
Thank you! It was that [[env.foo.hyperdrive]] syntax I was missing - didn't realise you could bolt .hyperdrive onto the end of the environment name. Incidentally, what is the difference between [foo] and [[foo]]?
kian
kian13mo ago
Table vs array of tables. To compare it to TS, {} and {}[]
[foo]
a = "b"
# { foo: { a: "b" } }

[[bar]]
a = "b"

[[bar]]
a = "c"

# { bar: [ { a: "b" }, { a: "c" } ] }
[foo]
a = "b"
# { foo: { a: "b" } }

[[bar]]
a = "b"

[[bar]]
a = "c"

# { bar: [ { a: "b" }, { a: "c" } ] }
You could also do an inline (array of) tables.
foo = { a = "b" }

bar = [
{ a = "b" },
{ a = "c" }
]
foo = { a = "b" }

bar = [
{ a = "b" },
{ a = "c" }
]
They are the exact same, just a different syntax. So you could do...
env.dev.hyperdrive = [
{ binding = "...", etc },
{ binding = "...", etc },
]
env.dev.hyperdrive = [
{ binding = "...", etc },
{ binding = "...", etc },
]
to have multiple Hyperdrive bindings on your dev environment
Mitya
MityaOP13mo ago
Really helpful, thanks!
Want results from more Discord servers?
Add your server