Cluster OIDC values¶
AWS asks for two values the other clouds do not: the cluster's OIDC issuer URL and the IAM OIDC provider ARN. Both are needed because IRSA's trust policy names each of them, and neither is derivable from the account and region.
Where each one lands¶
data "aws_iam_policy_document" "runtime_assume_role" {
statement {
actions = ["sts:AssumeRoleWithWebIdentity"]
principals {
type = "Federated"
identifiers = ["arn:aws:iam::<aws-account-id>:oidc-provider/oidc.eks.<region>.amazonaws.com/id/<cluster-oidc-id>"]
}
condition {
test = "StringEquals"
variable = "oidc.eks.<region>.amazonaws.com/id/<cluster-oidc-id>:sub"
values = ["system:serviceaccount:dp-eu-west1:xratud"]
}
}
}
The provider ARN is the federated principal: which identity provider AWS will accept a token from.
The issuer becomes the condition variable, with :sub appended. The
condition restricts the role to exactly one Kubernetes service account in one
namespace, so the runtime role can be assumed by xratud in dp-eu-west1 and
by nothing else.
The two are related but distinct strings: the ARN embeds the issuer host and path, and the condition variable uses the issuer without its scheme.
Why GCP and Azure do not ask¶
| Cloud | How the cluster is identified |
|---|---|
| GCP | The project's fixed identity pool, <project>.svc.id.goog, derived from project_id |
| Azure | aks_oidc_issuer, asked for as one field |
| AWS | Both the issuer and the IAM provider ARN, because the provider is a separate IAM resource you create |
On AWS the IAM OIDC provider is a resource in your account, created once per cluster. The contract does not create it, so it asks for its ARN.
Getting the values¶
aws eks describe-cluster --name <cluster-name> --region <region> \
--query "cluster.identity.oidc.issuer" --output text
{
"OpenIDConnectProviderList": [
{
"Arn": "arn:aws:iam::<aws-account-id>:oidc-provider/oidc.eks.<region>.amazonaws.com/id/<cluster-oidc-id>"
}
]
}
Creating the provider¶
A cluster with no IAM OIDC provider has nothing to put in
--cluster-oidc-provider-arn. Create it once for the cluster:
Then list it again to read the ARN.
Getting them wrong¶
A mismatch between the two is the common failure, and it surfaces after apply rather than during it: Terraform creates a role whose trust policy names a provider or subject that never matches, so the pod runs and cannot obtain credentials.
The Federated principal must equal your provider ARN, and the condition
variable must be your issuer without https://, ending in :sub.