Ported the Amazon client code from Scala