However, I do not understand why you need to swap credentials. If the machine is successfully removed from Juju, you should be able to re-validate that credential immediately 'juju update-credential <MAAS cloud name> <credential name> --controller <controller name>' since the machine check will pass.
What version of Juju are you using? Do you have logs from a failed credential re-validation? Could you please share your model's status at this stage?
@Richard Harding (rharding) is right: when Juju gets MAAS permission errors https:/ /github. com/juju/ juju/blob/ develop/ provider/ maas/errors. go#L13, it will invalidate used cloud credential.
However, I do not understand why you need to swap credentials. If the machine is successfully removed from Juju, you should be able to re-validate that credential immediately 'juju update-credential <MAAS cloud name> <credential name> --controller <controller name>' since the machine check will pass.
What version of Juju are you using? Do you have logs from a failed credential re-validation? Could you please share your model's status at this stage?