Added logic to use local credentials if available and fallback to an IAM role if not