Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting access key/secret as environment varaible #640

Open
beeradmoore opened this issue Apr 1, 2024 · 3 comments
Open

Setting access key/secret as environment varaible #640

beeradmoore opened this issue Apr 1, 2024 · 3 comments

Comments

@beeradmoore
Copy link

I am using a docker image (made from a base linux image, not an existing IA docker image) to access Internet Archive. As a part of this I pass through access and secret keys as environment varaibles.

Looking back (almost a decade ago) in v0.6.8 I can see the following changes

AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are now deprecated. IAS3_ACCESS_KEY and IAS3_SECRET_KEY must be used if setting IAS3 keys via environment variables.

Shortly after while testing my docker image I was unable to us the ia cli tool to upload. Errored with no/invalid auth. I confirmed they exist in the docker images env.

Searched the repo and the only issues filed with IAS3_ACCESS_KEY also appear to be since 2014. I figured why talk about it if it isn't broken 😅, but then I realised it does not exsit in code. Downloading v0.9.3 I can see they are used in code but at some point they were removed.

I searched all the releases page for "env" to see something liike "removed environment variables support" but I only found a custom config location.

I assume IAS3_ACCESS_KEY and IAS3_SECRET_KEY no longer exist, does this mean there is no way to set those values as environment variables?

As a workaround for now I've made my source code look for ~/.config/internetarchive/ia.ini and if it doesn't exsit but the environment varaibles do then it will create the ia.ini.

@JustAnotherArchivist
Copy link
Contributor

I noticed this as well a while ago. They were removed in a big refactor between versions 0.9.8 and 1.0.0: 2b82488

@jjjake
Copy link
Owner

jjjake commented Apr 4, 2024

Sorry for the trouble and confusion @beeradmoore.

As JustAnotherArchivist mentioned, these were removed about a decade ago as we refactored the configuration workflow (along with a lot of other big changes).

Note that you can also provide get_session() with a config dict or config_file if depending on the default config file location is not an option, for example:

In [1]: from internetarchive import get_session

In [2]: import os

In [3]: s = get_session(config={"s3": {"access": os.environ["IAS3_ACCESS_KEY"], "secret": os.environ["IAS3_SECRET_KEY"]}})

In [4]: s.access_key
Out[4]: 'foo'

In [5]: os.environ["IAS3_ACCESS_KEY"]
Out[5]: 'foo'

I'm not opposed to adding support for setting S3 keys via environment variables, but we should always default to the config file if it exists in any of the checked locations first.

@beeradmoore
Copy link
Author

Thanks for the response @jjjake (and sorry @JustAnotherArchivist, I thought I had replied to you much earlier).

For the above stuff, do you mean making changes to the python code itself, or is it possible to provide the ia cli tool a way to configure it?

For now my workaround of having a docker image generate the expected ini file works a treat. Having it use environment variables again would be nice, but it is far from a deal breaker by not having them. I am sure there are more important things you can be doing than adding that, considering it doesn't appear to come up often.

At least with this issue having those keywords hopefully if people need to find info they will land here and may do the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants