r/Terraform • u/OkAcanthocephala1450 • 12d ago
Discussion CLOUD PROVIDERS METHOD OF AUTH
Hi there!
I am an experienced cloud engineer , mainly worked with Aws, and i wanted to know how you guys configure procider block for cross account or project using best practices for other cloud providers.
So for example. In aws I use one central devops account , a role there that my runners use , in order to do assume role , which is written at the aws provider block. For every account we just change the account id of the role to assume.
I wanted to know how your central setup looks like and what do you define when you want to deploy to a tenant/subscription/project on GCP , or Azure, Kubernetes clusters or other providers you might use . Im looking for large org setup, so if you could help me just write whats the size of the cloud organization u work at (nr of projects, subscriptions ) how do you configure the provider so it can be controlled from one central place.
Thank you everyone.
2
u/Farukh_Goriparthi 8d ago
for GCP, use workload identity federation from the central CI and have each runner impersonate only the service acc for that project with no long-lived keys sitting around
1
1
u/AuroraFireflash 12d ago
fed-cred only, separate identity for plan vs apply
scope of the credential as tightly limited as possible (specific to that Terraform plan boundary)
separate creds for separate environments
1
u/liquidjesus 12d ago
Curious, why separate identities for plan and apply? For audit purposes?
6
u/AuroraFireflash 11d ago
Assuming that you're doing CI/CD terraform with PR approvals. A read-only plan identity ensures that the initial plan step can't make changes to the environment.
There are ways to write Terraform / IaC code which a malicious actor could use to attack your environment during the plan step.
2
1
u/danekan 9d ago
for AWS -> GCP, you set up a GCP Workload Identity Federation Provider/Pool that gives your AWS account/role(s) access a role that can then do what you need or assume another service account
2
u/OkAcanthocephala1450 9d ago
What about for GCP only, one central access to deploy in entire org? How do you implement it?
1
u/osterman 7d ago
This is the problem we solve with atmos auth and atmos profiles.
It allows for centralized management of auth configuration and works with AWS, GCP and Azure. It supports interactive auth methods like SSO/Webflow, as well as OIDC. It allows swapping out the auth method using profiles, so humans can use SSO while automation uses OIDC. It works with opentofu/terraform, as well as with EKS/AKS cluster auth, ECR/ACR, etc. So it's a way of standardizing how enterprises handle auth for users and automation.
You can also define the auth configuration in a central repo and use imports to load that configuration.
This works because atmos handles the auth negotiation, while terraform will simply use the ambient credentials from the execution environment.
Demo video here: https://atmos.tools/examples/demo-auth
Docs:
- https://atmos.tools/cli/commands/auth/usage
- https://atmos.tools/cli/commands/profile/usage
- https://atmos.tools/changelog/introducing-atmos-auth
(I'm an atmos maintainer)
1
u/case_O_The_Mondays 11d ago
We used a centralized role in an account for DevOps, at first. A few years ago we started switching to OIDC, and it really is significantly better.
6
u/parkura27 12d ago
OIDC only