Separate Caller Trust from Workload Service Roles
A RAM role is two documents that answer two different questions. The trust policy answers who may assume the role. The permission policy answers what the resulting session may call. Federation changes only the first one, and that is why a correctly federated role can still be completely useless.
Caller trust sits on the role, never on the identity provider. An OIDC provider declares an issuer and the audiences it will accept, and grants nothing by itself. The role that names that provider in its trust policy is the object that admits a caller, so deleting the provider breaks every role that names it in one action.
A workload service role is a third kind of object. It trusts a cloud service principal rather than a person or an IdP, and ACK assumes it to reach ECS, VPC, SLB, SLS or ACR on your behalf. Almost every role in the family trusts the same principal, while the node-pool lifecycle role trusts the orchestration service instead, and that single exception is the kind of detail a reviewer has to be told.
A service-linked role looks similar and behaves differently. The service creates it, the service fixes its policy, and it cannot be declared as an ordinary role. Provider 2.2.0 exposes a service-linked-role resource for a handful of products only, and ACK is not among them, so those roles appear on first use and stay outside your graph.
Activation is an account fact with no resource address. ACK activation is performed by reading a data source, so an apply can report zero resources added while the account has just been opened. Nothing in state records that it happened, which is why the evidence has to be a written record rather than a diff.
Table 1 keeps the five objects apart, because each one is created by a different owner and removed by a different action.
| Object | Created by | Trusts | What it proves | Fails as |
|---|---|---|---|---|
| RAM OIDC provider | Terraform, once per issuer | the external IdP | the issuer and the audience set | every token is rejected before a role is read |
| CI deploy role | the bootstrap root | that provider, one subject | a named session, no key at rest | assumption denied, no session at all |
| ACK component role | the bootstrap root | the container service principal | a role name ACK can find | add-on degraded while the cluster reports healthy |
| ACK service-linked role | the ACK service | fixed by the service | nothing you can declare | cannot be planned, only observed |
| ACK activation | one privileged run | not applicable | the service status string | cluster creation rejected at the first call |
Figure 1 draws the planes that the rest of this part keeps separate. Account authority creates once, the federated caller runs repeatedly, and the service plane is consumed by add-ons rather than by pipelines. A workload that can assume a component role has been handed cluster-wide cloud authority by accident.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','signalColor':'#5a6e82','noteBkgColor':'#c4873b','noteTextColor':'#132440','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
BG["Break-glass administrator
account holder or account admin
MFA, no static key"] --> IDP["RAM OIDC provider
issuer plus client IDs
a trust anchor, not a role"]
BG --> CIR["CI deploy role
trusts one subject
permission names actions"]
BG --> CSR["ACK component roles
AliyunCS family
trust the container service"]
ACT["ACK activation
a read with no resource address"] --> CSR
IDP --> CIR
CIR --> CL["Cluster root
and workload roots"]
CSR --> ADD["Add-ons
network, storage, logging"]
SLR["Service-linked roles
created by the service"] -.-> ADD
ADD --> RES["ECS, VPC, SLB, SLS, ACR"]
CL --> WORK["Application pods
their own service account role"]
WORK -.->|"never this role"| CSR
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class BG primary;
class IDP,CIR,CSR,SLR secondary;
class ACT warn;
class CL,ADD,RES,WORK ok;
Figure 2 puts the same three planes on one canvas with activation underneath. Activation is drawn outside the caller column because it is an account action rather than a pipeline step, and the service-linked roles are drawn dotted because Terraform never creates them.
Verify Credential Chain and Token Claims
The chain begins at a token file, not at a key. A runner asks its identity provider for a signed token, writes it where the provider block can read it, and never handles an Alibaba Cloud secret. The exchange call is anonymous by design, so there is nothing to leak before the session exists.
Three strings must agree before STS issues anything, and a fourth value decides how long the agreement lasts. The issuer, the audience and the subject are declared in three different places and checked by three different objects. Table 2 is the map, and every row is a place where a correct token is still refused.
The audience is a value you choose, not a product name. Alibaba's own credential action defaults to one audience string while other community actions default to another, and whichever you pick must also appear in the provider's client ID list. Change it in the workflow and not in RAM, and the exchange fails with a message that rarely names the audience.
The subject is the only claim that can name a repository. A branch pipeline and an environment pipeline mint different subject strings, and a condition written for one refuses the other even though the issuer and audience match. Write the condition for the narrowest subject that still deploys.
Session length is capped by two independent clocks. The provider block requests an expiry, the role imposes a maximum, and the token itself expires earlier than both. The OIDC block stops at one hour, so a longer apply needs a token file rather than a longer session.
An inline token is exchanged once; a token file is re-read. The first works for a short plan and fails mid-apply on a slow cluster, with an expired-token error that looks like a permissions problem. The second lets the provider re-assume the role before the session runs out.
| Claim | Declared in | Enforced at | Typical mismatch |
|---|---|---|---|
| issuer | the provider's issuer URL | the issuer condition | a scheme or trailing slash differs |
| audience | the provider's client ID list | the audience condition | the runner requests a different value |
| subject | nowhere on the provider | the subject condition | a branch subject where an environment subject was written |
| expiry | the IdP token lifetime | the STS exchange and the refresh | a long apply outlives the token file's remaining life |
Figure 3 walks the exchange and keeps all five failure branches on the diagram. Four of them stop before a single API call is signed, which is the useful property: a trust mistake never looks like a resource mistake.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','signalColor':'#5a6e82','noteBkgColor':'#c4873b','noteTextColor':'#132440','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
T["IdP issues a token
issuer, audience, subject, expiry"] --> F{"Token file readable
at provider configuration?"}
F -->|"no"| X1["No credential source
plan stops before a graph walk"]
F -->|"yes"| P["Provider reads the provider ARN
and the role ARN"]
P --> C1{"Issuer matches
the issuer condition?"}
C1 -->|"no"| X2["Assumption denied
issuer not trusted"]
C1 -->|"yes"| C2{"Audience in the provider
client IDs and in the condition?"}
C2 -->|"no"| X3["Assumption denied
audience mismatch"]
C2 -->|"yes"| C3{"Subject matches
the condition?"}
C3 -->|"no"| X4["Assumption denied
wrong repository or environment"]
C3 -->|"yes"| S["STS returns a session
AccessKey pair, token, expiry"]
S --> A{"Session still valid
at the next API call?"}
A -->|"no"| X5["Expired token mid-apply
an inline token was exchanged once"]
A -->|"yes"| OK["Request signed
permission decided separately"]
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class T,P primary;
class F,C1,C2,C3,A secondary;
class S,OK ok;
class X1,X2,X3,X4,X5 danger;
Every branch above ends before a resource is touched, and most of them end at trust. An identical provider block can pass on one repository and fail on the next because the subject changed. Keep the subject string in the same review as the workflow file that produces it.
Bootstrap ACK Roles Without Broad Application Grants
Least privilege here starts with the role name, not the action list. ACK looks up a fixed set of names, and a role with the right trust and the right system policy but a different name is invisible. The service then reports that the role does not exist, which reads like a missing policy and is really a naming decision.
The published quick-start list is longer than any one cluster needs. It covers logging, monitoring, storage, audit, autoscaling, diagnostics, cost and edge control, because it is written for every cluster shape at once. A lab cluster installs four of them, and each extra role is standing permission with no owner and no review path.
Trust is nearly constant across the family, and that is the trap. Almost every role trusts the same container service principal, while the node-pool lifecycle role trusts the orchestration service. The name and the attached system policy are therefore the only things a reviewer can use to tell a log reader from cluster administration, so read the attachment rather than the description.
The published sample still sets a delete flag and two deprecated arguments. It writes the role name and the trust document through fields that the previous part already flagged as replaced, and it sets a force flag so a role with attachments can be removed. The flag is convenient in a sandbox and dangerous against a running cluster.
The set-difference pattern makes adoption a silent no-op. The sample reads existing custom roles, subtracts them from the wanted list, and creates only what is missing. When the console already made the roles, the apply adds nothing and state owns nothing, so a later destroy removes only what Terraform created and leaves the rest.
A CI role should not be able to create any of this. Table 3 assigns each action to exactly one identity, and the row that matters is the intersection: the pipeline may create a cluster but not the permission that a cluster's add-ons use.
The first loop is a credential loop, and Terraform cannot see it. The role that runs the bootstrap is one of the objects the bootstrap creates, so the run needs a credential that does not exist yet. Terraform resolves this the same way it resolves a Kubernetes provider: the credential is supplied before the graph is walked, so no dependency edge can wait for a role the same run is supposed to create. Break it by creating the provider and the CI role once from the break-glass identity, and letting every later run assume that role.
The second loop is an ordering loop inside the service plane. Activation arrives as a read rather than a resource, so nothing implies an edge between opening the service and creating the roles that trust it. Write the dependency explicitly, and keep both steps in one root whose only job is account-level work. Split them across roots and the edge disappears with the state boundary.
The third loop is a dependency you do not own. A managed cluster also needs the network, load balancing, autoscaling and logging services opened, and those activations are owned by other roots or by a console habit. Treat the activation set as an input contract from the account root, not as something the cluster root discovers at create time.
| Action | Break-glass run | Bootstrap role | CI deploy role | ACK service |
|---|---|---|---|---|
| Activate ACK | yes, once | reads the status only | no | not applicable |
| Create component roles | yes | yes, if the set changed | no | no |
| Create the cluster | yes | yes | yes | not applicable |
| Create workload objects | not applicable | not applicable | through Kubernetes RBAC | not applicable |
| Create service-linked roles | no | no | no | yes, on first use |
Figure 4 shows the grid as a boundary rather than a hierarchy. Authority narrows from left to right, and the only column that can widen its own permissions is the one no pipeline holds. The dotted cell is the role ACK creates for itself, which no plan can produce.
The only thing the bootstrap root owes the cluster root is a list of names. Publish the role names, the provider ARN and the activation status as outputs, and never publish a credential. The cluster root reads those outputs and holds no RAM write permission at all, which is what lets the boundary survive the next refactor.
Test One Allowed and One Denied Service Operation
The denial is the assertion; the allow is only the control. A plan that succeeds proves the credential works. Only a call that is refused proves the boundary is where the documents say it is.
The cheapest allowed call is a role check. The container service exposes a read that reports whether it can see each named role, and its failure message names the role it could not find. It mutates nothing, and it proves exactly the wiring that a cluster's add-ons will depend on.
The cheapest denied call is a role creation. The create action mutates nothing when it is refused, and it is the one action that separates the bootstrap identity from the pipeline. Run it from the CI session and expect a refusal that names the action rather than the resource.
Activation must not share an identity with either probe. If the deploy role can open services, the grid in Table 3 is decorative, because the role can grant itself whatever the service can reach. The activation record belongs to the privileged run and the probes belong to the pipeline.
Three refusals look alike and are fixed in three places. A denied assumption, a denied action and an unopened service all stop the run, and only one of them is a policy problem. Table 4 sorts them by where the fix lives.
| Failure | What the message points at | Where the fix lives |
|---|---|---|
| assumption denied | the principal or a token condition | the role trust policy |
| action denied | the action name in the request | the role permission policy |
| role not found | a role name the service looked up | the role name, not its policy |
| service not opened | the product rather than the action | the privileged activation run |
Figure 5 contrasts one identity with a split that can be proved. The left side shows the shape that works in a lab and fails an audit, where the same credential activates the service, creates the roles and deploys the workload. The right side shows the same work split across three identities, with the denial drawn as the evidence rather than as an incident.
Record Recovery and Credential Rotation
Federation removes the static key and nothing else. The build identity still pushes images, the runner still caches artifacts, and the state file still records whatever values were written through it. A repository that carries a long-lived registry credential is not improved by an OIDC role sitting in front of the same pipeline.
Revocation is a policy edit, not a key rotation. Narrowing the subject condition, or removing a client ID from the provider, invalidates a session on its next exchange. There is no key to hunt down and no log to scrub, which is the real gain, and it only works if the trust documents are the thing you control.
The provider is a single point of failure for every role that names it. Deleting it, or narrowing its accepted audiences, invalidates the whole set at once. Record which roles name which provider before editing either, because the blast radius is a list you can write down and not one you can guess.
Three clocks have to rotate together. The role's maximum session duration, the token lifetime, and any recorded certificate fingerprint are separate values with separate owners. A provider that stores fingerprints turns the identity provider's certificate rotation into your maintenance event.
Recovery has an order, and it is the reverse of the teardown. Restore the trust anchor, then the CI role, then the component roles, then the cluster. Deleting a component role while a cluster still installs its add-on degrades the add-on without touching the control plane, which is the failure that survives a rollback.
| Surface | What changing it does | Blast radius | Owner |
|---|---|---|---|
| provider client IDs | changes which audiences are accepted | every role on the provider | platform |
| subject condition | changes who may assume | one role | the team that owns the repository |
| provider deletion | removes the trust anchor | every role naming it | break-glass run |
| role maximum session | changes the ceiling, not the token | one role | the team |
| registry push credential | untouched by federation | the build pipeline | build owner |
Table 5 is the rotation plan, and it is short on purpose. Four rows change something in RAM and review like code; the fifth changes a registry credential and reviews like nothing at all.
Record Recovery and Credential Rotation
Status: design-only. This is a rehearsal plan for Terraform 1.17.1 and aliyun/alicloud 2.2.0 against a disposable account. No account, credential or cluster is recorded here, no command output is quoted, and none of these steps was run.
Prerequisites. A sandbox account on the site you intend to use, one break-glass administrator with MFA, a repository that can request a short-lived identity token, and one deliberately un-granted action. Everything is free until step 8, where a zero-worker cluster becomes the only billable object.
| Boundary | Owner | Pass condition |
|---|---|---|
| activation | break-glass run | the status reads opened and the plan reports zero added |
| trust anchor | break-glass run | the provider exists with the audience you will request |
| CI role | break-glass run | one subject string, one permission policy |
| role set | bootstrap root | every role name matches what the service looks up |
| probe pair | CI session | one call succeeds and one is refused |
- Confirm the CLI and provider versions before touching the account: 1.17.1 and 2.2.0, resolved rather than requested by a range.
- In a separate state, activate the service once from the break-glass identity and record the returned status plus the fact that the apply reported no added resources.
- Create the provider with the issuer of your identity provider and the exact audience your workflow will request. Output the provider ARN; do not build the string by hand.
- Create the CI role with a trust policy that names that provider and a subject condition for one repository and one ref. Attach a permission policy that names actions, not a wildcard.
- Create only the component roles the intended add-ons need, by their published names, each with the system policy that belongs to it.
- Plan the bootstrap root again with no changes. Expect an empty plan; a persistent diff means a name or a policy attachment is being rewritten each run.
- From the CI session, run the allowed probe before spending anything: the service's role check for the names you created. Expect a granted result for each, and a message naming any role it cannot see.
- Create one cluster with zero workers and only the add-ons whose roles you provisioned. This is the first billable step, and the only one that proves the role set is complete rather than merely present.
- Run the denied probe from the same session: attempt to create a role. Expect a refusal that names the action, a non-zero exit and no new role.
- Break the trust on purpose: remove the subject condition, re-run the allowed probe, and confirm the failure is an assumption denial rather than a permission denial. Restore it and confirm the allowance returns, so the pair is recorded as one condition apart.
- Destroy in order: the workload objects, the cluster, the component roles, the CI role, then the provider. After each stage, list what that stage should have removed and confirm nothing else moved.
Expected observation. The healthy run produces an empty second plan, a granted role check, a cluster that creates without a missing-role message, a refused role creation and a clean activation record. The broken run fails at the assumption, before any action is evaluated, and the message names trust rather than permission.
Failure check. The rehearsal fails if the denied probe succeeds, if the allowed probe reports a role as missing although the name matches, if the cluster create reports a missing role that the probe called granted, if the second bootstrap plan is never empty, or if the provider deletion is discovered only when the next pipeline run fails.
Evidence to keep. The activation status and its timestamp, the provider ARN with its audience list, the CI role's subject condition, the role names with their attached system policies, both probe results verbatim, and the post-destroy inventory per stage. Keep no token, no session and no plan file.