Probably one of the more difficult experiences I've encountered with terraform, has been that of secrets management, as sensitive data is a first-class citizen, actually performing said encryption is left to a third-party service, and most of the third-party services one would use don't allow for one particular type of handling. The shared credential has long been the bastard of passwords, because it is typically only used when performing integration work on a request basis. Well, turns out Terraform has you covered there also!
rsadecrypt
is a terraform function that decrypts an RSA-encrypted ciphertext, returning the cleartext.
rsadecrypt(ciphertext, privatekey)