Closed danielmotaleite closed 2 years ago
Files identified in the description:
plugins/inventory/aws_ec2.py
](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/inventory/aws_ec2.py)If these files are inaccurate, please update the component name
section of the description or use the !component
bot command.
i found in the net this reference for the same problem: https://www.reddit.com/r/ansible/comments/qql86z/how_can_i_use_aws_sso_with_ansible_aws_ec2/ Probably the mujahidk is not really using aws sso login and so just exporting the profile with normal tokens
@danielmotaleite Thank you for raising this. I don't have much experience with aws_ec2, but it seems to me that it does not support SSO. I'll wait for @jillr's confirmation to be sure and further clarification.
If not supported, please upgrade this issue to a feature request, we use OKTA for aws authentication, so this is required... right now, as workaround, we have to login to okta, choose the aws, profile, re-authenticate and copy the AWS_* tokens ... it works, but lot more work and annoying
@danielmotaleite
The problem is that SFAIK none of the maintainers are using AWS's SSO offering, so we can't even be sure why it's not working, or test any fixes. I, for example, have direct SAML integration[1] in place, instead of using the additional AWS SSO layer. I would have expected that authentication using the profile should have worked, but since I've not used AWS SSO I don't know what differences there might be between the standard integration and AWS SSO.
What I do find odd is where the failure is occurring, it seems to imply that the iam_role_arn
parameter has been set, which doesn't match with the reproducer example you've provided.
If anyone with AWS SSO experience/access is able to produce a patch, we'll happily review the patch and can try and get it merged if it doesn't break existing functionality.
[1] https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_saml.html which predates the full SSO offering by a couple of years.
@danielmotaleite From what I can tell, boto3 support for AWS SSO was not added until 1.14.0. What happens if you upgrade your boto3 version?
@gravesm that is the problem, i upgraded the boto3 to the latest version and aws sso login works with aws_ec2 without issues
I didn't noticed that i was below the boto3 recommended version. Maybe aws_ec2 should warn about a unsupported boto3 version, that would trigger a fix by the user ?
You can reuse this to add this minimum version check, if not, i think this can be closed. Thanks for the help!
@tremble Is it worth adding a note for sso concerning boto3 version? The only branch requiring boto3 >= 1.9 is stable-1.5 at the moment.
@alinabuzachis It's documented in https://github.com/ansible-collections/amazon.aws#aws-sdk-version-compatibility since the 2.0 release (where we required boto3 >= 1.15.0
)
That said, it looks like I didn't update the inventory plugin docs to require a specific version of botocore/boto3. I think we should update this, and I wouldn't consider this a 'breaking' change since it's only documentation and we already say that the collection as a whole requires the botocore/boto3 versions.
I also think @danielmotaleite's suggestion that the remaining (non-module) plugins should also spit out warnings is a good idea, in combination with updating the inventory plugin docs.
As a bare minimum solution #819
I agree that we should also emit a warning where the minimum requirements aren't met so I'm going to leave this open for now.
This can actually happen to this day, if you're authed in a gov cloud region, and try to get a list from a commercial region. It seems like a warning should be thrown/regions disabled, when trying to get a list of contents for a region you don't have access to?
Grab the region they authed with, if gov cloud, disable all commercial. I'm guessing govcloud is disabled by default, and it's not an issue in the other direction.
my_session = boto3.session.Session()
my_region = my_session.region_name
Summary
I have a ansible with aws_ec2 configured and it works fine with normal aws credential ( ~/.aws/credentials and exporting the tokens). Now my company is migrating to OKTA, so i need to do aws sso login to get permissions for aws. aws cli is working fine after the login, but ansible fails, aws_ec2 report no credentials found
I tried exporting AWS_PROFILE, setting up in aws_ec2.yml the boto_profile and nothing work. ~/.aws/config is correct, generated by aws sso configure sso
I suspect that the code is trying to check for credentials and not allowing boto3 to run and use this new feature
Issue Type
Bug Report
Component Name
aws_ec2
Ansible Version
It also failed with ansible 2.9 by the way
Collection Versions
AWS SDK versions
Configuration
OS / Environment
Steps to Reproduce
Expected Results
aws sso login is working, aws s3 ls works fine, ansible aws_ec2 plugin should be able to use the same feature and list the hosts
Actual Results
Code of Conduct