Fix up AWS support...

This is adapted from #2624 with a few patches to make it merge.