mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
provisionIamRole's adoption path (triggered by EntityAlreadyExists when a same-stack UpdateStack retries against a role that already exists) fetched the existing role via getRole() but never applied the template's current AssumeRolePolicyDocument. A changed trust policy was silently dropped while the stack still reported UPDATE_COMPLETE. Routes the adoption path through the existing IamService.updateAssumeRolePolicy helper, mirroring how createRole() already applies the document on first create. If a later step in the same attempt fails (e.g. a bad ManagedPolicyArns entry), the whole resource update fails and CloudFormation reports UPDATE_ROLLBACK_COMPLETE - the trust policy must actually roll back too, not stay on the new value. Captures the role's prior trust policy before applying the update and restores it in the existing failure-cleanup path alongside policy detachment. Does not re-fetch the role after applying the trust policy: nothing downstream reads anything affected by that update (Arn, RoleId, AttachedPolicyArns are unchanged by it), and a failing re-fetch there would escape before the restoration catch block, leaving the new trust policy active despite a rolled-back update. Adds an ID-verified updateAssumeRolePolicy(name, doc, expectedRoleId) overload in IamService: a role deleted and recreated under the same name between the earlier identity check and this write would otherwise silently receive an update meant for the role this stack actually owns. Both the primary write and the failure-triggered restore use this overload - restoring a trust policy is just as consequential as applying one, so both directions get the same identity guarantee. Fixes #2084.