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.
pull/45169/head
Max Cameron 6 years ago committed by Sloane Hertel
parent 324b57d6ae
commit cf1006179d

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

Loading…
Cancel
Save