Get in touch

26 März 2020

Simplifying account management on AWS cloud using AssumeRole

Welcome to the first edition of our series on technology case studies from our portfolio companies.

In this post, RMC DevOps Consultant Eryk Zalejski and Quoka CTO Holger Marquetant will show you how to simplify account management on the AWS cloud using AssumeRole.

This post was also published on Medium.

Enter Eryk and Holger:

Bit of Quoka’s background

Our history reaches back to 1983. Soon we will turn 40, but it does not mean we are getting old. Our CTO Holger Marquetant is passionate about the newest technologies and we tend to always improve and modernize our platform. A few years back we started our cloud journey. First, we migrated to docker, then ECS and finally, we landed on EKS. As you may expect with all the migrations we learned quite a few things. We decided it will be great to share some of it with the world.

Multiple AWS accounts issue

During our cloud journey, we always planned to go on with as much automation as possible. We have also chosen to describe our infrastructure as a terraform code. Having everything terraformed we went with multiple AWS accounts, we wanted to separate our “PROD” “DEV” and “Other” environments as much as possible.

At first, managing users seemed easy — we defined users in our .tfvars and applied the terraform configs using separate workspaces. From the administration perspective, it seemed perfectly OK, but soon we realized it was a true nightmare to our developers and other AWS users. We ended up with a ton of AWS profiles in our .aws/credentials that we needed to maintain between console sessions and we needed to run multiple browsers or at least multiple browser profiles when working on many AWS accounts concurrently.

The solution: AWS AssumeRole

We finally discovered the AWS Mechanism that allows transferring permission from one account to another. It seemed like bingo to us! Here is the initial draft of how we planned to do this:

Putting the idea into the code

We chose to have one and only account defining our users and their roles. It basically means one user for everyone, one AWS credential and just one place to log into AWS console. Bingo right? We only define our master account and define other profiles once. This is how our .aws/credentials is looking like:

https://gist.github.com/ezalejski/5b8038101c6e30dc48df7d52292bce47#file-credentials_example

All of the user management goes to our ‘Master’ AWS admin account:

Users.tf:

https://gist.github.com/ezalejski/8702b31d9f153a7a78e112be776beaac#file-users-tf

Groups.tf (this example shows just one group — administrator access to prod account):

https://gist.github.com/ezalejski/a8f8698b9925591ccb4da54c267e67e7#file-groups-tf

And finally group_membership.tf:

https://gist.github.com/ezalejski/5c80ad902304d0bfad5d3de779ff2f72#file-group_membership-tf

Each target (AssumeRole managed) AWS account (like “PROD” “DEV” and “Other”) needs to have such config applied in order to create “Trust” (please replace <MASTER_ACCOUNT_ID> with the ID of the account you manage your user in):

Assumed_roles.tf:

https://gist.github.com/ezalejski/11f80380370d81847cf6a046e561717c#file-assumed_roles-tf

Now in order to use only quoka-master AWS profile within the shell and during our terraform plan and applies, we only needed to instrument our terraform installations to use the assume-role profile (<PROD_ACCOUNT_ID> can be used as a per workspace terraform variable i.e. ${var.aws_account_id}) :

Providers.tf:

https://gist.github.com/ezalejski/7cc31ac4f5468aa9aeff4e75b13669ba#file-providers-tf

Summary

It took us a while to find this solution. We realize that it is never one size fits all option, but if this article can help you and users within the company we will be very pleased. Quoka is part of Russmedia Group. We are a group of companies that embrace knowledge and tech sharing. We regularly meet at internal conferences and organize calls to make it happen. It is seriously pushing us forward and we are hoping to spread this kind of spirit all over the world. Let this article be the first of a long series. Enjoy!

More from Russmedia Equity Partners

Russmedia Digital Romania managed to complete the acquisition transaction of Startapro.hu.

Russmedia Digital acquires Startapro.hu

13 Juli 2021

Russmedia Digital Romania, the company that also operates Publi24.ro managed to finalize the transaction with Central Media Group in acquiring Startapro.hu.
Read more

Tech sharing

One team to unite them all - the R-Team

23 Juni 2021

Great teams are what every company is looking for. But how exactly can you achieve this? Especially if team members are sitting in different countries, different companies and have completely different skill sets. Well, like in our case, probably you don’t even plan it ahead. Great people find each other and sometimes pieces just fall into the right place.
Read more

You’re next Let’s go