org-formation / org-formation-cli

Better than landingzones!
MIT License
1.41k stars 130 forks source link

feature request: support AWS SSO #57

Closed theburningmonk closed 3 years ago

saferrer commented 4 years ago

Hi @OlafConijn! I just had a look at the commit associated with this issue and I am finding quite difficult to follow the example. In my company, we have a master account with AWS organisations enable and AWS SSO as well to manage users and access to the different AWS accounts. How is org-formation helping with this? One thing that we wanted to have "as code" was the permission-sets in SSO (so we don't rely on manual changes). Is this possible?

Thanks for the help!

OlafConijn commented 4 years ago

HI @saferrer,

the full example can be found here: https://github.com/org-formation/org-formation-cli/tree/master/examples/sso

I think SSO in this context is kinda confusing. It could mean either one of 2 things: 1) Using the AWS SSO Service to log into AWS. This is a method that relies on some manual setup in the AWS Console. I looked at automated this, but this didnt seem possible (not by supported api's).

2) Using an external SSO Provider to log in to AWS. This Is the method i/we use over at the company i work and is fully managed as code. The example also uses this approach.

Both approaches have a lot in common. they are also both build on top of the same concepts in IAM (IdentityProvider, Role).

The external SSO provider solution does mean you will have to deal with another solution provider. Think of JumpCloud, Okta, Auth0 and loads more i would assume...

The way it works:

  1. The SSO provider handles the login page and is connected to a directory with users.
  2. The users can, after logon, select the role and target account they would like to log into
  3. The trust between SSO Provider and AWS is made using an Identity Provider
  4. The permissions your user has after logging in (or: assuming a role) are declared in a regular IAM Role.

Step 1 and 2 are managed by your SSO provider. In our case a completely different department. Because we don't want to have to change the SSO Provider configuration every time we add a new account our users can use SSO to log into a special Users AWS Account. I can think of multiple reasons ('best practices') to do this so it doesn't entirely depend on having this managed by someone else. You can see this in the organization file.

if you look at the tasks file you see this is mostly regular CloudFormation and some cross account bindings.

The remaining two tasks are 2 roles: 1) SsoAuditorRole that will not notify using the SsoNotificationTopic. 2) SsoAdministratorRole that will notify using the SsoNotificationTopic.

so far so good?

The templates for the Idp, custom policies and sns topic are fairly straight forward. The template for the roles sso-generic-role.yml is somewhat more interesting... This template creates 2 roles TargetRole and SsoRole.

SsoRole will be deployed to the UsersAccount and can be assumed using the Identity Provider. TargetRole will be deployed to multiple accounts (using TargetAccountBinding). The SsoRole will allow to assume any these roles in the various accounts.

TargetRole will contain the permissions you would like to give to your users.

In the bottom of the file there is a metrics filter and alarm that can be used to send the notifications over SNS. pretty neat trick but not essential.

did that help? or only add to the confusion 😂 un saludo

Olaf

eduardomourar commented 3 years ago

For the first option (AWS SSO Service) mentioned by Olaf, you can find now an example here: https://github.com/org-formation/org-formation-reference/tree/master/src/templates/100-aws-sso