-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
credentials mocking #889
Comments
When you say If you could add some code, that might help me understand the use case. |
I've since forgotten the specifics, but I think it comes down to calling boto3.Session with a profile or attempting to use it caused it to look for (and not find) the I fixed by manually mocking the call expanduser call. If I am doing this poorly, please do let me know (especially if you can suggest a fix!) I'm not great at testing. https://github.com/sean-abbott/terraform.py/blob/master/tests/remote/test_s3.py |
Hmmmm. What happens if you don't mock the credentials? |
botocore.exceptions.ProfileNotFound: The config profile (testawsprofile) could not be found call is in test_get_remote_state, calling ati.remote.s3_remote_state.get_remote_state (line 69) s3_remote_state.py:36: This happens if I comment line 60 in tests/remote/test_s3.py (which is where I patch expanduser) Here's a branch which demos the issue. You can run |
@sean-abbott Apologies, I tried to find where you were mocking the credentials but I'm not sure I found the right place. Is it this?: sean-abbott/terraform.py@d2ed646 |
@sean-abbott I'm going to close this for now but please reopen when you get the chance. |
I think I've come across this same issue and have a relatively easy way to reproduce it. Essentially, if the AWS_PROFILE environment variable is set but the profile isn't found in ~/.aws/config, it raises an exception on import:
If I |
I suspect I'm witnessing a related, but different, issue. When I run the tests locally everything is fine (and I have the AWS credentials in
This is thrown right after appearances of: s3_conn = boto3.client('s3', 'us-west-2')
s3_conn.create_bucket(Bucket='test-bucket') If, when I start the container, I mount my credentials the tests all pass. Furthermore, creating a dummy
is enough and the tests passes. NB: I'm not sure if it is related, but I have update some dependencies:
This might be related. |
This is either a question or a request.
I've been unable to find any references to credentials profiles in the code, so I'm guessing these aren't implemented yet.
I'm using different profiles for different groups, and I need to make my s3 connection using profile (i.e.,
aws_session = boto3.Session(profile_name=profile_name)
moto does not appear to mock the profile name; it must exist in the developers
~/.aws/credentials
(or config).Any chance this can be implemented and that other folks need it?
The text was updated successfully, but these errors were encountered: