Fixes ec2.py assume_role. (#37357)

* Fixes ec2.py assume_role

Previously when connect_to_aws was called it updated the credentials in place.  "connect_to_aws" is called multiple times: on the second run it tries to assume the same role it is already using, and potentially failing depending on your iam policies.
This commit is contained in:
Max Cameron 2018-09-04 14:43:58 +01:00 committed by Sloane Hertel
parent 324b57d6ae
commit cf1006179d

View file

@ -159,6 +159,7 @@ import os
import argparse
import re
from time import time
from copy import deepcopy
import boto
from boto import ec2
from boto import rds
@ -569,7 +570,7 @@ class Ec2Inventory(object):
return connect_args
def connect_to_aws(self, module, region):
connect_args = self.credentials
connect_args = deepcopy(self.credentials)
# only pass the profile name if it's set (as it is not supported by older boto versions)
if self.boto_profile: