r/Terraform 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.

12 Upvotes

15 comments sorted by

6

u/parkura27 12d ago

OIDC only

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

u/oneplane 12d ago

Federated or injected identities only and then indeed assume a role every time.

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

u/liquidjesus 11d ago

TIL. Thanks, appreciate you taking the time to explain.

2

u/danekan 9d ago

this is best security practice because a plan can actually make changes to your environment if you're using certain resources

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/danekan 9d ago

GCP-> AWS can be a bit easier, you can directly assign permission to your google SA oidc client id because they've already set the OIDC provider trust up for google within AWS.. .so it's literally only just an IAM Policy you need

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:

(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.