How to configure AWS SSO enabling access for a user in two different AWS accounts using a customized user-portal
Tags: awss3, awssso, awsrds, security
Published: 2021-08-30 17:33:44

“Challenges faced to find the solution of how to configure AWS SSO enabling access for a user in two different AWS accounts using a customized user-portal”. I have checked different ways so that I can be able to access different accounts in the simplest way without having to login to all accounts again and again. I got the solution as users are able to login the accounts once using the switch role for IAM users feature of AWS or using AWS Single Sign-On service. The AWS Single Sign-On service is a short-term access or we can say it gives a user session-based access so the access key and secret key also get changed automatically. As per my requirement, I have chosen AWS Single Sign-On service. In terms of cost, the AWS Single Sign-On service has no charges.

AWS Single Sign-On (AWS SSO) is a cloud service that allows you to grant your users access to AWS resources, such as Amazon EC2 instances, across multiple AWS accounts. By default, AWS SSO now provides a directory that you can use to create users, organize them in groups, and set permissions across those groups. You can also grant the users that you create in AWS SSO permissions to applications such Salesforce, Box, and Office 365. AWS SSO and its directory are available at no additional cost to you. To learn more, read the [AWS Single Sign-On](https://docs.aws.amazon.com/singlesignon/latest/userguide/what-is.html). 

In this post, you will get to know how to configure AWS SSO enabling access for a user in two different AWS accounts using a customized user-portal. Here I have taken two aws accounts, s3 bucket and rds database. I have enabled SSO with the creation of user, group and permission sets(s3fullaccess and rdsfullaccess). Users are able to access the accounts with s3 and rds services with appropriate permissions using the user portal URL.

#Prerequisites
You’ll need an Amazon Simple Storage Service and Amazon Relational Database Service for this post. [Getting started with Amazon Simple Storage Service](https://aws.amazon.com/s3/getting-started/) provides instructions on how to create a bucket in a simple storage service. [Getting started with Amazon Relational Database Service](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_GettingStarted.htm) provides instructions on how to create a relational database. You’ll also need [AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/installing.html) (AWS CLI) installed and configured on your machine. For this blog, I assume that I have two AWS accounts in an organization(root account and sub-account), S3 bucket with file and RDS database.

#Architecture Overview    
Diagram 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g7uqwfbzqrfi3at00wom.png)                                                                                                           
The architectural diagrams show the overall deployment architecture with AWS S3, AWS RDS, AWS Single Sign-On and AWS Accounts.

#Solution overview
The blog post consists of the following phases:
1. Setup of identity source settings in aws single sign-on console 
2. Create a User, group and set a permission set on group in aws single sign-on
3. Verification of invitation for sso by users and login to aws accounts using MFA authentication with sso service
4. Testing of access to the account for users from the management console and command line

I have two AWS accounts in an organization(root account and sub-account), S3 bucket with file and RDS database as below →
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zoqrmkjz34b06k4wr41h.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qozw1la2c2b6tuf9mtd5.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/skaft05x6ncox39zeh5e.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p1i6igy4m4viaaf17yd6.png)

##Phase 1: Setup of identity source settings in aws single sign-on console 
1. In the AWS Single Sign-On console, click on the aws sso option to enable it.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mk3mm6yjfkbcfv16bgb8.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ybgl6bf9eotewjrrmm5y.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4udieolrx4mi10ldxttz.png)
2. Choose your identity source option, In identity source select aws sso option. Other options are also available as active directory and external identity provider. Click on the customize button and give the user portal URL of choice.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9xryuco6iaicogvownir.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xw3o8hbhhm105x749b3b.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k5w0kz5fdtq2t95zzqom.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l7584qoulbag63fxsjqe.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z74atz8t01tfqk2rytds.png)
3. You can also set the multi-factor authentication settings as per your requirement. I have set every time they sign in with both security authentication MFA types. And set the option as required to sign in with MFA only.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y505oyu16baeg92w743h.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3fql7gn85wh0y2d70tfp.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rumjfa14okcpg22lwdaw.png)

##Phase 2: Create a User, group and set a permission set on group in aws single sign-on 
1. In the dashboard click on users option, I have added a user named as gargee with email verification option and give required details of user such as email id, first name, last name... And leaving other options as default.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rivdciv4ogcx83taha45.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/17cx96jzu4c0xqz8xpif.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ljtxgo1cwi3twnkb6p89.png)
2. Click on the create group option, specify the group name as S3andRDSaccess and then create it. Then select the group and add a user in it. User "Gargee Bhatnagar" has been successfully added to the group.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/41x8usz50ap2h40z4ywr.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p8m2pp6ncsqx8ans526x.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4jm2y3h2i0gmiwuj2u0o.png)
3. Goto AWS Accounts option, click on the permission sets tab then create a permission set as custom named as S3andRDSaccess with 12 hours session duration and AWS managed policies(S3fullaccess and RDSfullaccess) and create it.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vqt49dbgl691g5tqy3b1.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hn9uqsd0c2ieix80jih0.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dl3xox1tmvql5d3ai5j2.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/93pfzgfe2ousp7ao8917.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fmpjd54ma9qlgnapygxo.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nb3tbmqkr0ekpnkqbuwt.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/stbtr8y9nb373bfc0sce.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pqiianm7s9amdegvflu1.png)
4. In the AWS Organization tab, assign users all existing AWS accounts and assign a permission set to the group.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qzuw281wwg3bvtt8zhto.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6yc240i7wsv424qbo2mv.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4t6jzlocjvrdie3biu4c.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ygb14irobr5quoveqg7i.png)

##Phase 3: Verification of invitation for sso by users and login to aws accounts using MFA authentication with sso service 
1. In the mail, accept the invitation and then access the user portal URL in the browser. Set a new password for user login and configure an MFA on users sso login. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/29ng7ydpqu8othbnwci2.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ijj8vlgge5zkghccy156.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ni56z9mka57xug34xcd.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wqsy3ohgcvbdqgeus8kg.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t5vb4n79cwal1sirctni.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fsipud59rmwa94il1gr9.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ikrpmlwnimfwewt00zvs.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/swgy9j7sjgvcnzh5vxgd.png)
2. Click on aws account, you can see the access permissions of users with console and command line links.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yp4aidojl4u2ylzglt7h.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s0hj4or23jut0wr4qzv2.png)

##Phase 4: Testing of access to the account for users from the management console and command line
1. For gargee user, check access for s3 and rds from the console. EC2 console cannot be accessible for gargee as showing API error.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/piior9ohu9qo1cr9v9rp.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/km7uygsf04zqxa8fbo49.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cgdl3zovk16wecarsobd.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0hx7g09uzn7fqiw1s74s.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3qp2ltda4fbo08m9jtxg.png)
2. For other user, check access for s3 and rds from the console as nothing is displayed due to no data being there in s3 and rds. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nhicehwb9m5ex83xbh5o.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/493wg4fk11zhm3se76kr.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5hjj2qupejkyzv05ajgf.png)
3. For gargee user, access from command line. Run command “aws configure sso” in terminal and give required details as URL and region. Give MFA and authenticate the request for command line access.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5a9yuwse4i0pzp5k2gc.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/40hk8fegknix5j1c85jo.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x43ge2ef0najfhay6qsk.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eb07s5tqq6t151bvjpmi.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h2ycvua4fa73g2qdiizw.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bsw2yuq3tcta92kx0k4y.png)
4. You can see the two accounts available with roles on it. Input the region, output format and profile name. I have set up a profile for gargee and other users. You can list the s3 bucket using the “aws s3 ls --profile gargee-access” command for users with a profile name. You can even list rds using the “aws rds describe-db-instances --db-instance-identifier database-testsso --profile gargee-access” command.
You can even check configuration and expiration of a session with access and secret key in folders of aws config files.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/61n9j888ftbbgdcjwsoq.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/otsc6abofko65wtgr4eh.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y34xgb2gipm1yqav9tw1.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6qhuy2kvfa88d3znb000.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e82skh17h6u8sd97mhp2.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sxfgudwxfanwkcyfogzu.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9gsl9qrqoud2zqcopo4s.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bdddaupxz8orz9ygzvxe.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/19s34x6gcy1dbzfjrx6s.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qvd7iirr95j56ezpi5ql.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sxt0ph2sol7hxu0ewcx8.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h3bt64qi9n9j3nrx587w.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hkvjwa96s9l5mkae5z8f.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5a50snfi9gv4cz9hvql5.png)
5. After deletion of an aws sso, you are not able to access the user portal URL.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/omrutry79hozm1nfiio0.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p2uzv8er39ogroovazud.png)

#Clean-up
Delete the environment as: Single Sign-On Service, RDS, S3. 

#Pricing
I review the pricing and estimated cost of this example - 
For Relational Database Service →
Cost for USD 0.024 per db.t2.micro instance hour (or partial hour) running MySQL = $0.05
For Simple Storage Service →
Cost of APS3-Requests = $0.00
No charges for AWS Single Sign-On Service.
Total Cost = $(0.05+0.00) = $0.05

#Summary
In this post, I have shown you how to configure AWS SSO enabling access for a user in two different AWS accounts using a customized user-portal. 
For more details on single sign-on service, Checkout Get started with AWS Single Sign-On, open the [AWS Single Sign-On Service console](https://ap-south-1.console.aws.amazon.com/singlesignon/home?region=ap-south-1#/). To learn more, read the [AWS Single Sign-On documentation](https://docs.aws.amazon.com/singlesignon/?id=docs_gateway). 

Thanks for reading!

Connect with me: [Linkedin](https://www.linkedin.com/in/gargee-bhatnagar-6b7223114)