Hi team! I am trying to use `dagster.EnvVar` to lo...
# ask-community
b
Hi team! I am trying to use
dagster.EnvVar
to load an environment variable while constructing a resource. I am doing something like this:
Copy code
configured_cassandra_resource = Cassandra(
    clusters=os.getenv("CASSANDRA_CLUSTERS").split(),
    port=<http://EnvVar.int|EnvVar.int>("CASSANDRA_PORT"),
    user=EnvVar("CASSANDRA_USER"),
    password=EnvVar("CASSANDRA_PASSWORD")
)
Is there a way to use EnvVar and load the environment variable
CASSANDRA_CLUSTERS
as an array?
EnvVar("CASSANDRA_CLUSTERS").split()
does not work as it returns
["CASSANDRA_CLUSTERS"]
as the value (see screenshot) Alternatively, is there a more elegant way to supply an array of string to
Cassandra.clusters
?
q
You probably have to strip first before you split.
.strip("][").split(",")
t
Hey Bolin! Unfortunately, resolving arrays from environment variables is hard, but can you use
EnvVar
to take a string of comma-separated values and then split them within your custom resource at runtime?
b
Yeap, I will do that, thank you both!