Pass fileDatastore explicit AWS credentials

1 回表示 (過去 30 日間)
Carlos Aguilar
Carlos Aguilar 2019 年 4 月 30 日
回答済み: Rick Amos 2019 年 5 月 14 日
Hi,
Is it possible to pass explicit AWS credentials to the function fileDatastore?
I have two different AWS accounts and ideally I'd like to switch between them. From reading the setenv documentation I understand it overwrites the system's variables, which is something that I want to avoid (variables AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY are used by other non-Matlab applications).
Any workaround for the first line of the following code? Many thanks
setenv('AWS_ACCESS_KEY_ID', getenv('AWS_ACCESS_KEY_ID_PERSONAL'));
ds = fileDatastore(s3_path, 'ReadFcn', @load, 'FileExtensions', {'.mat'});
ds.preview

回答 (1 件)

Rick Amos
Rick Amos 2019 年 5 月 14 日
It is currently not possible to pass explicit credentials directly into fileDatastore. Datastore retrieves the credentials in the same way as the Amazon command line interface, either from environment variables or from the Configuration and Credential pair of files as described by Amazon.
With that said, different processes can have their own credentials. The setenv function in MATLAB affects only the MATLAB process itself, as well as any application launched by calling the system function in MATLAB. It is safe to use setenv in MATLAB, all other applications outside of MATLAB will continue to see their own copy of the environment variables and use their own credentials.

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by