Can AWS CLI be used with a federated login? - amazon-web-services

I login to AWS with my Active Directory account in my company. We are using federated login, as described here:
Federated Users and Roles
Federated users don't have permanent identities in your AWS account the way that IAM users do. To assign permissions to federated users, you can create an entity referred to as a role and define permissions for the role. When a federated user signs in to AWS, the user is associated with the role and is granted the permissions that are defined in the role. For more information, see Creating a Role for a Third-Party Identity Provider (Federation).
My company has a Security Token Service (STS) which is a SAML provider.
I can use that to login to AWS management console, but can I login to AWS CLI as well with my federated login?

saml2aws can be used for AWS CLI for the federated user.
Refer https://github.com/Versent/saml2aws this is based on python code from https://aws.amazon.com/de/blogs/security/how-to-implement-federated-api-and-cli-access-using-saml-2-0-and-ad-fs/
You can use the below command to login to default IDP AWS account, your organization will provide you the IDP account name.
saml2aws --idp-account="default" --username=USERNAME --password=PASSWORD
For using the federated user for automation, you need to use exec
saml2aws --idp-account="default" --username=USERNAME --password=PASSWORD exec command

Yes, it is possible, however it's not straight forward. There is a rather long blog post in the AWS Security Blog explaining how to be able to use the CLI as SAML-federated user: https://aws.amazon.com/de/blogs/security/how-to-implement-federated-api-and-cli-access-using-saml-2-0-and-ad-fs/

Related

Does AWS deletes/disable account users when you create aws organizations and enable Idp using azure ad?

I have AWS account A which has some users and roles I created manually. Now I created AWS Organizations and created account B. I wanted to connect azure id as External Identity Provider(Idp) to AWS SSO.
would it delete/disable users and roles I created manually in account A when I enable Idp?
I found some information on this page https://docs.aws.amazon.com/singlesignon/latest/userguide/manage-your-identity-source-considerations.html but all it says it will disable users created using AWS SSO but doesn't say anything for users and roles created manually.

Is there any way to restrict IAM users/Asumed Roles from enabling unauthenticated user identities in AWS cognito?

As an admin, I wanted my AWS users not to enable unauthenticated user identity in AWS Cognito. Is there any way to restrict this action? Can this be achieved through service control policy?
Basically I don't want my AWS users to enable AWS resource access to any guest users.
I don't think you can do anything but prevent them from creating Cognito resources entirely.
There is nothing in the Cognito SAR pages that indicates that you can differentiate on authenticated/unauthenticated identities.

Putting AWS federated user into separate IAM groups?

At my employer, we have an AWS account that uses SAML 2.0 to federate in your user access from the company SSO login to the AWS console. The net effect is that everyone has admin access. Is there a way to place federated users into different IAM groups, thereby giving least privilege access?
The answer we came up with is that all federated users would have very limited access to the console with no programmatic access. Then, create separate IAM users for everyone for programmatic access (no console login) and to place these separate users into IAM groups with varying access. Would this method be considered best practice or is there a better way to accomplish what we would like to do in this case?
The best practices is to use groups to set permissions (policies) for each class of user.
Grant users SSO access to AWS accounts in your organization by
selecting the AWS accounts from a list populated by AWS SSO, and then
selecting users or groups from your directory and the permissions you
want to grant them.
AWS Single Sign-On
Your SSO SAML 2.0 provider should be able to pass role information to AWS at sign-in. You can then have corresponding IAM roles setup in AWS.
We use Azure AD for SSO and set it up using this example: https://blog.flux7.com/aws-best-practice-azure-ad-saml-authentication-configuration-for-aws-console
Basically you create Azure AD Security Groups and map them to IAM roles.

Create AWS IAM users based on e-mail domain

I am setting up an AWS Account, the account will be used by an organization of employees for EC2 use/experimentation. Obviously, I do not want to distribute the root login info or set up one single IAM user for everyone to use. Unfortunately, I do not have the time to manage creating individual IAM users for everyone on a regular basis.
So, is there a way to auto-create IAM users based on a given email's domain on their first login attempt? The users should have read-only roles to begin, then an Administrator could give more roles as needed to each user. I am open to suggestions, perhaps lambda functions or linking to an identity provider?
Keep in mind that these new IAM users need to have access to the AWS Management Console, this is not necessarily intended for login to applications hosted on AWS.
Update:
Moving forward using this AWS Management Console Federation Proxy Sample found in Amazon's code reference, using with Microsoft Exchange hosted email.
If your existing identity provider supports SAML2 Federation, you can set it up to login to the AWS Management Console.
For more details refer Enabling SAML 2.0 Federated Users to Access the AWS Management Console.
Else you can implement a custom Federation Broker to return an URL to the user, after they authenticate with their corporate credentials.
For more details refer Creating a URL that Enables Federated Users to Access the AWS Management Console (Custom Federation Broker).

Add AWS IAM users to AWS Cognito Pool

I'm a newbie to AWS, I'm building an application where the users should be logged in via AWS account.
So I created a user pool and authenticated via AWS SDK using the federated identities. But the users were created manually in the Cognito UI.But the requirement is to authenticate the user if they already resides in AWS as an IAM user. But AWS cognito does not provide a workflow to import the IAM users to cognito pool. So is there another way to accomplish this via AWS ? Thanks in Advance.
This is currently not possible. Although AWS Cognito Federated Identities allows, federating an external identity provider to grant AWS access, the other way around is not possible.
In addition, there is no method in AWS IAM SDK to verify AWS Username and Password, which also limits verifying them through your own implementation.