🔥Let’s Do DevOps: Assuming an IAM role from an EC2 instance

Kyler Middleton
The Startup
Published in
2 min readSep 18, 2019

--

tl;dr: A batch script (code provided) to assume an IAM role from an ec2 instance. Also provided is terraform code to build the IAM roles with proper linked permissions, which can be tricky.

This blog series focuses on presenting complex DevOps projects as simple and approachable via plain language and lots of pictures. You can do it!

I’m working through an interesting problem — syncing Azure DevOps to AWS, and making the connection functional, scalable, and simple. Sometimes, when designing anything, a path is followed that doesn’t pan out. This is one of those paths, and I wanted to share some lessons learned and code that might help you if this path is a winner for you.

Our security model for EC2 requires that a machine assume a higher IAM policy when it is required, but the rest of the time it have much lower permissions. That’s a common use case, and a best practice.

Some applications support assuming a higher IAM role natively — I later learned, after pursuing this, that terraform is one of those applications (more details on that in a future blog). However, some applications can’t, and require you to do the heavy lifting yourself.

IAM — a Sordid (and Ongoing) History

IAM (Identity and Access Management) is complex beast that controls authentication (who are you?) and authorization (what are you allowed to do?). Because even simple concepts can be made…

--

--

Kyler Middleton
The Startup

DevNetSecOps, DevRel, cloud security chick. I will teach you, it’s unavoidable. She/Her 🏳️‍🌈🏳️‍🌈, INFJ-A, support the EFF!