When using AWS CloudFormation to set up infrastructure, how can a developer ensure that successfully provisioned resources are preserved if an error occurs during the provisioning process, and how can they provision and update the stack using the AWS CLI?