Is there a way to set a StringSource to have a def...
# ask-community
d
Is there a way to set a StringSource to have a default value from a particular env variable?
p
No, StringSource expects that the value is set in the env var (if that’s the way it’s configured).
d
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
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
does that need to be passed around anywhere, or that just updates my_resource in place?
p
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
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
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(...)