https://dagster.io/ logo
#dagster-support
Title
# dagster-support
d

Daniel Mosesson

07/06/2022, 4:36 PM
Is there a way to set a StringSource to have a default value from a particular env variable?
p

prha

07/06/2022, 5:09 PM
No, StringSource expects that the value is set in the env var (if that’s the way it’s configured).
d

Daniel Mosesson

07/06/2022, 5:10 PM
how do I set that up? I only see a set to
env
option when I pass it into the execute/run stage, not on the resource itself as part of the field
p

prha

07/06/2022, 5:13 PM
For a resource, I think you could use the
configured
API to hardcode the configuration at definition time:
Copy code
my_resource.configured({"my_value": { "env": "MY_ENV_VAR" }})
d

Daniel Mosesson

07/06/2022, 5:16 PM
does that need to be passed around anywhere, or that just updates my_resource in place?
p

prha

07/06/2022, 5:21 PM
you’d pass that into the job in place of your naked resource:
Copy code
@job(resource_defs={"my_resource_key": my_resource.configured({"my_value": { "env": "MY_ENV_VAR" }})})
def my_job():
    ...
d

Daniel Mosesson

07/06/2022, 5:47 PM
the the resource needs to be configured the same way for a whole repo, is there an easy way to do that once, or I do that per job/asset list`with_resources`
p

prha

07/06/2022, 6:16 PM
We don’t currently attach resources at the repository level. Your best bet might just be to define your variable as the configured resource and use that everywhere:
Copy code
my_resource = my_unconfigured_resource.configured(...)