AWS resources¶
The generated terraform/main.tf creates two IAM roles and their inline
policies. It creates no ECR repository and no S3 bucket: those are yours, named
in the install spec, and Terraform grants access to them.
What it renders¶
terraform {
required_providers {
aws = { source = "hashicorp/aws", version = "~> 5.0" }
}
}
provider "aws" {
region = "<region>"
}
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"]
}
}
}
resource "aws_iam_role" "runtime" {
name = "dp-eu-west1-runtime"
assume_role_policy = data.aws_iam_policy_document.runtime_assume_role.json
}
Then its two inline policies, and the same three blocks again for the build
role with system:serviceaccount:xratu-build-bootstrap:builder as its subject.
The two identities¶
| Identity | Role name | Assumed by |
|---|---|---|
| Runtime | dp-eu-west1-runtime |
xratud in namespace dp-eu-west1 |
| Build | dp-eu-west1-build |
builder in namespace xratu-build-bootstrap |
Two rather than GCP's three: AWS has no publish delegate, because the ECR grant is an inline policy on each role rather than a separate impersonation step.
Role names derive from dp_install, so two installations in one account do not
collide. See dp_install.
One trust policy per role¶
Each role's trust policy names the OIDC provider and pins the subject to one Kubernetes service account:
The runtime role cannot be assumed by the builder service account, and the reverse holds. That pinning is the whole of IRSA's security boundary, which is why both OIDC values have to be right. See Cluster OIDC values.
What you bring¶
| Resource | Created by |
|---|---|
| The AWS account | You |
| The EKS cluster | You |
| The IAM OIDC provider for that cluster | You, once per cluster |
| The ECR repository | You |
| The S3 bucket | You |
| IAM roles and policies | This Terraform |
An S3 bucket that does not exist still lets the policy be created, because an S3 resource ARN in a policy does not have to resolve. That failure appears later, when the node cannot read or write. Confirm the bucket before you apply.
Related¶
- AWS IAM policies for what each policy allows.
- IRSA for the annotation that pairs with these roles.