I think there's a much stronger argument that cloudformation deploying your stacks gets to being imperative than the way you produce your cloudformation file.
The file is still declarative regardless, and the functions you write to create that file don't per se have side effects outside that file