Back to Terraform

Alibaba Deep Dive: RAM Federation, Service Roles and ACK Bootstrap

November 6, 2026 Wasil Zafar 26 min read

Map RAM, STS/OIDC and service activation owners through a controlled provider-specific rehearsal

Table of Contents

  1. Separate Caller Trust from Workload Service Roles
  2. Verify Credential Chain and Token Claims
  3. Bootstrap ACK Roles Without Broad Application Grants
  4. Test One Allowed and One Denied Service Operation
  5. Record Recovery and Credential Rotation

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.

ObjectCreated byTrustsWhat it provesFails as
RAM OIDC providerTerraform, once per issuerthe external IdPthe issuer and the audience setevery token is rejected before a role is read
CI deploy rolethe bootstrap rootthat provider, one subjecta named session, no key at restassumption denied, no session at all
ACK component rolethe bootstrap rootthe container service principala role name ACK can findadd-on degraded while the cluster reports healthy
ACK service-linked rolethe ACK servicefixed by the servicenothing you can declarecannot be planned, only observed
ACK activationone privileged runnot applicablethe service status stringcluster 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.

Separate Caller Trust from Workload Service Roles
%%{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.

Three ownership planes: account authority, federated caller, workload service plane The account authority column contains a break-glass administrator who creates the OIDC provider, the CI role and the component role set once. The federated caller column contains the provider, the CI role and a short-lived session. The workload service plane contains the AliyunCS role family, the add-ons that assume those roles and the service-linked roles created by the service itself. A footer states that activation is an account fact with no resource address, and that a workload root must never receive a component role. Three planes, three lifetimes Who may assume, what the session may call, and what a service may reach are three decisions. ACCOUNT AUTHORITY Break-glass administrator MFA, no key on disk, runbook Creates once provider, CI role, role set Records activation a status string, not a resource FEDERATED CALLER RAM OIDC provider issuer plus accepted client IDs CI deploy role trusts one subject string STS session expires, refreshes, never stored WORKLOAD SERVICE PLANE AliyunCS role family trusted by the container service Add-ons assume them network, storage, logging Service-linked roles created by the service, not by you Activation is an account fact: a read with no resource address, and a plan that adds zero resources. The workload root never receives a component role. A role that outlives its cluster is not the workload's to delete.

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.

ClaimDeclared inEnforced atTypical mismatch
issuerthe provider's issuer URLthe issuer conditiona scheme or trailing slash differs
audiencethe provider's client ID listthe audience conditionthe runner requests a different value
subjectnowhere on the providerthe subject conditiona branch subject where an environment subject was written
expirythe IdP token lifetimethe STS exchange and the refresha 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.

Verify Credential Chain and Token Claims
%%{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.

ActionBreak-glass runBootstrap roleCI deploy roleACK service
Activate ACKyes, oncereads the status onlynonot applicable
Create component rolesyesyes, if the set changednono
Create the clusteryesyesyesnot applicable
Create workload objectsnot applicablenot applicablethrough Kubernetes RBACnot applicable
Create service-linked rolesnononoyes, 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.

A permission grid: which identity may activate, create roles, create clusters and create workload objects Four identity columns and five action rows. The break-glass run may do everything once. The bootstrap role may create roles and clusters but only read activation status. The CI deploy role may create clusters and objects but never activate the service or create roles. The ACK service itself is the only column that creates service-linked roles. A crimson footer states that a pipeline holding role creation can grant itself any permission the account has. One action, one identity If a pipeline can create a role, it can grant itself every permission the account holds. Break-glass run Bootstrap role CI deploy role ACK service Activate ACK yes, once status read only no not applicable Create roles yes yes, when changed no not applicable Create cluster yes yes yes not applicable Workload objects not applicable not applicable through RBAC not applicable Service-linked roles no no no yes, on first use A role that can create roles is an administrator with a longer name.

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.

FailureWhat the message points atWhere the fix lives
assumption deniedthe principal or a token conditionthe role trust policy
action deniedthe action name in the requestthe role permission policy
role not founda role name the service looked upthe role name, not its policy
service not openedthe product rather than the actionthe 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.

One over-privileged identity compared with a split where the denial is the evidence The left panel is a single identity that activates the service, creates the component roles, creates the cluster and deploys workloads, with three consequences: the plan has side effects, teardown removes roles other clusters use, and a leaked runner can create roles. The right panel splits the work across a break-glass run, a federated CI session and the ACK service, then shows two probes: a role check that succeeds and a role creation that is refused. One credential, or three, and one refusal that proves it A boundary you cannot demonstrate is a boundary you are only describing. Before: one identity a lab shape that passes every test Activate the service Create the component roles Create the cluster and deploy the plan has side effects it never reports teardown removes roles another cluster still assumes After: three identities the same work, with one provable refusal Break-glass run: activate, create once Federated CI session: cluster and objects Role check allowed, proves the wiring Role creation refused, proves the boundary Both results are recorded per change, not reconstructed after an incident. A refusal that arrives as a trust error is not the test passing. Read which of the four rows in Table 4 fired before editing any policy.

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.

SurfaceWhat changing it doesBlast radiusOwner
provider client IDschanges which audiences are acceptedevery role on the providerplatform
subject conditionchanges who may assumeone rolethe team that owns the repository
provider deletionremoves the trust anchorevery role naming itbreak-glass run
role maximum sessionchanges the ceiling, not the tokenone rolethe team
registry push credentialuntouched by federationthe build pipelinebuild 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.

Lab

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.

BoundaryOwnerPass condition
activationbreak-glass runthe status reads opened and the plan reports zero added
trust anchorbreak-glass runthe provider exists with the audience you will request
CI rolebreak-glass runone subject string, one permission policy
role setbootstrap rootevery role name matches what the service looks up
probe pairCI sessionone call succeeds and one is refused
  1. Confirm the CLI and provider versions before touching the account: 1.17.1 and 2.2.0, resolved rather than requested by a range.
  2. 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.
  3. 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.
  4. 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.
  5. Create only the component roles the intended add-ons need, by their published names, each with the system policy that belongs to it.
  6. 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.
  7. 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.
  8. 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.
  9. 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.
  10. 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.
  11. 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.