This method is really hard to follow, due to it's length and complexity. It would probably be better to abstract out a aws response manager class or maybe just refactor out some methods with self explanatory method names. This might make it easier to test too.