Hey, I’m deploying my flows on different AWS accou...
# ask-metaflow
s
Hey, I’m deploying my flows on different AWS accounts. When I want to inspect my flows, running:
Copy code
from metaflow import Metaflow
print(Metaflow().flows())
I want to control from which account I’m pulling the results. Which environmental variable should I set, to ensure showing flows from desired AWS account?
a
@steep-traffic-55869 You would need to have a Metaflow Configuration file per account in this case. For example, you could maintain two
config.json
files under
~/.metaflowconfig
. One for the default account and another for the other account, such as
config_prod.json
. You can switch to the other one with the postfix
prod
using the environment variable
METAFLOW_USER
where you set it to
METAFLOW_USER=prod python script.py
. Another thing to make the AssumeRole between the accounts easier would be to use aws-vault with the aforementioned method. How to run in the default account:
Copy code
aws-vault exec default_account -- python script.py
How to run it in the prod account:
Copy code
aws-vault exec prod_account -- METAFLOW_USER=prod python script.py
b
if deploying to multiple accounts, do you also have multiple Metaflow configs on the machine, one for each target account?
METAFLOW_PROFILE
controls which config is picked for the library, then for authenticating against AWS resources you'd also have to set
AWS_PROFILE
to a profile that has suitable credentials (or alternatively the aws-vault approach from Yudhiesh). One thing to note is that the config seems to only be read once during module loading, so doing something like
os.environ["METAFLOW_PROFILE"]="otherprofile"
does not change anything with already imported libraries based on a quick test.