When AWS CloudFormation encounters an error during the stack creation or update process, its default behavior is to terminate the stack and roll back all resources that have been created up to that point. This rollback process ensures that if an issue occurs, no partial resources or configurations are left in place, which could lead to inconsistencies and potential issues in your infrastructure.
The rollback feature is particularly crucial in maintaining the integrity of the environment, ensuring that if a stack fails due to an invalid specification or an issue with resource dependencies, all resources are reverted to their previous stable state before the stack operation began.
This behavior is intended to simplify the management of stacks by providing a clean slate in the event of errors and is integral to how AWS CloudFormation operates to maintain a predictable and reliable infrastructure management experience.