mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
* fix(cloudformation): create AWS::IAM::Role inline Policies instead of silently dropping them CreateStack now applies each entry of an IAM role's Policies array as an inline role policy (PutRolePolicy semantics), resolving intrinsics inside the policy document. Failures propagate so a policy that cannot be created fails the stack instead of reporting CREATE_COMPLETE without it. Fixes #1952 * refactor(cloudformation): move AWS::IAM::Role into its own provisioner Continues the per-service decomposition started with SQS (#1825) by taking the resource type this branch touches out of the CloudFormationResourceProvisioner switch, carrying the #1952 inline-Policies fix with it. - IamRoleCfnProvisioner owns provision and delete for AWS::IAM::Role: name resolution and same-stack adoption, managed-policy attachment with its rollback, the inline Policies of #1952, and the former deleteRoleSafe, whose only caller was the role delete arm. - CfnRollback holds what both halves of the migration need instead of duplicating it: the __FlociRollbackOwned attribute that CloudFormationService reads to decide rollback deletion, and attemptIamCleanup, still used by the AWS::IAM::Policy and AWS::IAM::ManagedPolicy arms. - ProvisionContext gains resolveStringList next to the resolveOptional and generatePhysicalName it already lifts from the monolith. - IamRoleCfnProvisionerTest covers the inline policies and the delete path with one mocked service; the existing role rollback tests keep running through the public provision entry point, now with the provisioner registered. Role provisioning behavior is otherwise unchanged. * fix(cloudformation): inline role policies fail loudly and unwind on failure Three review findings on the IAM role provisioner. A Policies entry with a null or absent PolicyDocument was skipped, so the stack reached CREATE_COMPLETE without the declared inline policy — the same silent drop this PR set out to fix, one level in. It is a ValidationError now. The inline-policy loop sat outside the block that unwinds a failed provision. When putRolePolicy failed after createRole succeeded, the resource went CREATE_FAILED, and because rollback only deletes resources that reached CREATE_COMPLETE, the role, its managed attachments and any inline policies already written were left behind. The loop now runs inside that block. A failed update that adopted an existing role kept whatever the half-applied attempt had granted. Inline writes are recorded with the value they replaced, so unwinding restores the previous document, or removes the policy when this attempt introduced the name. A role the stack did not create is not deleted. * fix(cloudformation): reconcile role policies an update stopped declaring An inline policy or managed attachment written by a previous execution and absent from the new template stayed on the role while the stack still reported UPDATE_COMPLETE. Both sets are now recorded on the resource and reconciled on the success path, so what the template drops is removed. Only names a previous execution recorded are touched, which leaves out-of-band policies alone. PolicyName is required on AWS::IAM::Role Policies. Generating one gave the same policy a fresh name on every execution, so an update accumulated copies instead of replacing it. A missing PolicyName is now a ValidationError, matching what this resource already does for a missing PolicyDocument. * fix(cloudformation): skip reconciliation of a role policy already removed deleteRolePolicy and detachRolePolicy both raise NoSuchEntity on an absent target, so a tracked policy removed out of band between executions failed an update whose desired end state already held. Reconciliation now skips what the role no longer carries.