From cf1006179d039bba6f8ac48494e4833a82c929ea Mon Sep 17 00:00:00 2001 From: Max Cameron Date: Tue, 4 Sep 2018 14:43:58 +0100 Subject: [PATCH] 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. --- contrib/inventory/ec2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/inventory/ec2.py b/contrib/inventory/ec2.py index 45619c2ac3e..b5108d37565 100755 --- a/contrib/inventory/ec2.py +++ b/contrib/inventory/ec2.py @@ -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: