Files
floci/compatibility-tests/sdk-test-java/src/test
Mario Toffia e9f2463103 fix(cloudformation): replace Cognito user pool groups like CloudFormation (#4841)
* test(cloudformation): cover AWS::Cognito::UserPoolGroup replacement against AWS

* fix(cloudformation): replace Cognito user pool groups on create-only changes

AWS::Cognito::UserPoolGroup left the old group behind on a rename, kept
the explicit name when GroupName was dropped, and tried to update a
group that did not exist when UserPoolId changed.

The provisioner now creates the group whenever a create-only property
changes and hands the displaced group to ReplacementCleanup, which
deletes it once the update commits or deletes the replacement and
restores the prior name and pool when the update rolls back. A pool
move that keeps an explicit name keeps the physical id, so, as on AWS,
nothing is deleted and the old-pool group stays. A generated name is
kept only for an in-place update; a pool move or a dropped explicit
name generates a fresh one. Each provisioned name is recorded with its
pool so a displaced group is deleted from the pool it lives in.

Closes #4836

* test(cloudformation): cover a failed update after moving a named Cognito group against AWS

* fix(cloudformation): roll back named Cognito group pool moves and read legacy name modes

A named pool move keeps the physical id, so it now records a replacement that displaces nothing. A failed update points the group back at the old pool and, as measured on AWS, leaves the new pool's group, and the stack delete reads the pool from UserPoolId. A resource persisted without FlociGroupNameMode reads its name as generated only when it has the generated shape, so dropping an explicit GroupName replaces it.

* test(cloudformation): cover declaring a Cognito group's generated name explicitly against AWS

Measured on AWS (eu-west-1): updating an unnamed group to declare GroupName
equal to its generated name, same pool, fails the Group with UPDATE_FAILED
"CloudFormation cannot update a stack when a custom-named resource requires
replacing. Rename <name> and update the stack again." before anything is
created. The stack ends UPDATE_ROLLBACK_COMPLETE, Ref and the physical id stay
the generated name, and the group keeps its pool, description, precedence and
creation date.

* fix(cloudformation): refuse declaring a Cognito group's generated name explicitly

GroupName is create-only, so declaring an unnamed group's generated name
explicitly in the same pool requires a replacement that keeps both the pool
and the name. Measured on AWS, CloudFormation refuses it before creating
anything: the Group goes UPDATE_FAILED with "CloudFormation cannot update a
stack when a custom-named resource requires replacing. Rename <name> and update
the stack again.", the stack ends UPDATE_ROLLBACK_COMPLETE, and Ref and the
group stay unchanged. Floci updated the group in place and reported
UPDATE_COMPLETE; it now raises the same ValidationError.

* fix(cloudformation): keep only owed and current Cognito groups in the pool record

The group pool record added the prior and current name on every provision and
never dropped one, so it grew with every name the resource ever had. It is now
rebuilt after the replacement record, keeping only the names still owed a
delete, with their recorded pools, plus the current name.

* fix(cloudformation): refuse a declared generated Cognito group name only when the mode was recorded

The refusal of a declared generated name read the prior mode from the name's
shape when no mode was recorded, so a legacy group explicitly named in the
generated shape had a valid in-place update refused. Only a recorded generated
mode refuses now; a legacy record updates in place, as before the mode existed.

* test(cloudformation): read stack outputs with XmlParser

The Cognito group integration test read stack outputs by splitting the
DescribeStacks XML on tag strings. It now uses XmlParser.extractPairs, as the
other CloudFormation integration tests do.
2026-10-06 10:24:56 -04:00
..