Get in touch

Contact us

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

Bergfex joins the Russmedia network

Bergfex joins the Russmedia network

Russmedia Equity Partners acquires 60% of Bergfex, Europe’s largest tourism platform in the Alps. All three founders stay on board.
Read more

Our exclusive invite-only meetup for founders and CEOs of bootstrapped companies

Our first Bootstrapping Meetup 2020

On 19th February 2020 we welcomed more than 30 founders and CEOs of bootstrapped companies to the first invite-only RMEP Bootstrapping Meetup in Vienna!
Read more

You’re next Let’s go