steep-traffic-55869
08/23/2023, 7:52 AMfrom 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?ambitious-bird-15073
08/23/2023, 1:02 PMconfig.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:
aws-vault exec default_account -- python script.py
How to run it in the prod account:
aws-vault exec prod_account -- METAFLOW_USER=prod python script.pybulky-afternoon-92433
08/23/2023, 1:16 PMMETAFLOW_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.