Refactored internal implementation of defining an AWS client.