Fix stacktrace in ec2 provider

Closes #15320
Merge pull request #16126 from cachedout/issue_15320

Fix stacktrace in ec2 provider