Hey all! We're working through an IAM role delegat...
# terraform
y
Hey all! We're working through an IAM role delegation pattern for a central primary role (for Spacelift/Terraform executions), which would then assume into downstream account roles. The setup: • Primary role in the "Identity" account (Spacelift or any automation system like GHA assumes this) • The primary role can then assume into delegated admin roles in downstream accounts (trust policy allow) • The delegated roles have admin permission in their respective accounts BUT, now how do we, if we want to perform Terraform locally, assume into the Primary role in the Identity account? 1. Chain role a. Users authenticate via AWS SSO -> Primary TF admin role Identity account b. How do we do this? Leapp, we can do this via Chained Roles... but local CLI, we'd have to do an additional step to assume role via AWS CLI 2. We don't assume into primary role, Delegated roles directly have trust policy to allow the AWS SSO admin role in the Identity account. This is very similar to the CloudPosse's architecture guide, https://docs.cloudposse.com/layers/identity/centralized-terraform-access/ but from the Permission Set -> intermediary Primary role in the Identity account, how is that assumption usually done? Is an additional AWS CLI command the best option? I'm not sure which is the best path.
@Matt Gowie reference for this btw!
e
This will make things possibly much easier
Atmos can natively handle all SSO, SAML, OIDC and IAM users.
It replaces leapp.
You can configure multiple identities
it handles all aws config management
ETA next week for the PR to be merged.
cc @Ben Smith (Cloud Posse)
b
So as Erik said, the atmos-auth PR should help with this. But in the meantime, typically our AWS team roles (which are the admin roles in the delegated accounts) usually trust the permission sets directly of whatever teams. So this means that locally, all you need to do is sign into your SSO team permission set, and then that'll directly jump to whatever team delegated account you need. Locally, what happens is you usually Leapp—or outside of your geodesic shell, you authenticate to AWS SSO to your team's permissions set like identityDevOpsTeamAccess. This, you then store the credentials with Leapp or some way into a profile—usually your namespace-identity like acme-Identity. Then, you have your AWS config. This trust uses a bunch of roles that use a source profile of your acme-Identity profile that you just created. So this then lets you locally sign in directly with AWS. But again, we kind of skip over that—the first role chain that you're talking about. So typically you're authenticated with your permission set and then you have your AWS config ready to go—and that lets you use the assume role if you want to use AWS CLI to access something in an account. Then you have Terraform. The providers.tf uses the account map to figure out, based on your stack and configuration, what Terraform role do we need to assume? This is done after the reason being: your identity account needs to be able to, your identity permission set needs to be able to access the Terraform state backend. And this is done through a role. Usually the Terraform state component creates a role that also trusts whatever identity permissions that you're signing into. So then what happens is your identity permissions sign into the Terraform state backend, authenticate to the backend, read state, and then the providers.tf kicks in—and you now authenticate to whatever account you're actually planning in, like dev or sandbox. --- I believe that's what you were getting at with option two, which is the delegated-roles (also known as aws-team-roles component) —just directly trust the permission set. This has been our evolved solution because we recommend AWS SSO for all of our clients now.
y
Ah gotcha. Thank you both. That makes sense. Checking out that Atmos feature, replacing Leapp sounds nice.
But in the meantime, typically our AWS team roles (which are the admin roles in the delegated accounts) usually trust the permission sets directly of whatever teams.
So this means that locally, all you need to do is sign into your SSO team permission set, and then that'll directly jump to whatever team delegated account you need.
Makes more sense now on this. Originally looking at the diagram in the reference guide, I was thinking the PermissionSet == Identity SSO role created by permission set, which assumes into another role in the Identity account, which assumes into downstream accounts.
For automation platforms then, like Spacelift or GitHub Actions, are y'all letting it assume into an intermediary role -> the team roles(through providers.tf)? Is it another role that the
delegated-roles
/
aws-team-roles
has a trust policy to accept?
e
Correct we have relied on providers.tf doing the role assumptions from an intermediary role.
That said, we are moving away from this and moving identity into the atmos framework so we can have more control over the identities depending on execution context
y
Exciting stuff! Looking forward to checking it out!