sparse-forest-27046
08/07/2024, 6:01 PMconfig:
transactionsDb:
locationId: nam5
firestore.go
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/firestore"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func transactionsFirestoreDb() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
locationId := cfg.Require("transactionsDb:locationId")
_, err := firestore.NewDatabase(ctx, "database", &firestore.DatabaseArgs{
LocationId: pulumi.String(locationId),
})
if err != nil {
return err
}
return nil
})
}
Is that right or is it fine to skip those Require()'s?modern-zebra-45309
08/07/2024, 6:04 PMconfig.Get
or config.Require
. Using config.Get
will return nil
if the configuration value was not provided, and config.Require
will raise an exception with a helpful error message to prevent the deployment from continuing until the variable has been set using the CLI.
https://www.pulumi.com/docs/concepts/config/#codesparse-forest-27046
08/07/2024, 6:06 PMsparse-forest-27046
08/07/2024, 6:08 PMcfg := config.New(ctx, "transactionsDb")
locationId := cfg.Require(locationId")
modern-zebra-45309
08/07/2024, 6:10 PMfuture-hairdresser-70637
08/07/2024, 6:12 PMtransactionsDb
then New(ctx, "")
would provide the same result (i.e. if ""
then namespace is set to your project's name)modern-zebra-45309
08/07/2024, 6:13 PMcfg := config.New(ctx, "transactionsDb")
locationId := cfg.Require(locationId")
and
cfg := config.New(ctx, "")
locationId := cfg.Require("transcationsDb:locationId")
give the same result, right?future-hairdresser-70637
08/07/2024, 6:14 PMRequire
there if the config value is in the project namespace. it's a bit confusingmodern-zebra-45309
08/07/2024, 6:14 PMconfig.New(ctx, "name-of-my-project")
is identical to config.New(ctx,"")
? That's something I did not knowsparse-forest-27046
08/07/2024, 6:15 PMmodern-zebra-45309
08/07/2024, 6:16 PMconfig = pulumi.Config(); config.get("aws:region")
beforefuture-hairdresser-70637
08/07/2024, 6:16 PM:
it will add the namespace implicitlysparse-forest-27046
08/07/2024, 6:17 PMsparse-forest-27046
08/07/2024, 6:19 PMfuture-hairdresser-70637
08/07/2024, 6:23 PMsparse-forest-27046
08/07/2024, 6:30 PMconfig:
transactionsDbName: transactionsDb
transactionsDbType: FIRESTORE_NATIVE
over
config:
transactionsDb:
name: transactionsDb
type: FIRESTORE_NATIVE
is that right?future-hairdresser-70637
08/07/2024, 6:35 PMfuture-hairdresser-70637
08/07/2024, 6:37 PMsparse-forest-27046
08/07/2024, 6:37 PMsparse-forest-27046
08/07/2024, 6:38 PMfuture-hairdresser-70637
08/07/2024, 6:41 PMsparse-forest-27046
08/07/2024, 6:42 PM