Fix bug in iam_role (#22618)

pull/24614/head
Jonathan Davila 8 years ago committed by GitHub
parent f9b4499082
commit 6410e13903

@ -190,7 +190,7 @@ def create_or_update_role(connection, module):
changed = False changed = False
# Get role # Get role
role = get_role(connection, params['RoleName']) role = get_role(connection, params['RoleName'], module)
# If role is None, create it # If role is None, create it
if role is None: if role is None:
@ -258,7 +258,7 @@ def create_or_update_role(connection, module):
connection.add_role_to_instance_profile(InstanceProfileName=params['RoleName'], RoleName=params['RoleName']) connection.add_role_to_instance_profile(InstanceProfileName=params['RoleName'], RoleName=params['RoleName'])
# Get the role again # Get the role again
role = get_role(connection, params['RoleName']) role = get_role(connection, params['RoleName'], module)
role['attached_policies'] = get_attached_policy_list(connection, params['RoleName']) role['attached_policies'] = get_attached_policy_list(connection, params['RoleName'])
module.exit_json(changed=changed, iam_role=camel_dict_to_snake_dict(role)) module.exit_json(changed=changed, iam_role=camel_dict_to_snake_dict(role))
@ -269,7 +269,7 @@ def destroy_role(connection, module):
params = dict() params = dict()
params['RoleName'] = module.params.get('name') params['RoleName'] = module.params.get('name')
if get_role(connection, params['RoleName']): if get_role(connection, params['RoleName'], module):
# We need to remove any instance profiles from the role before we delete it # We need to remove any instance profiles from the role before we delete it
try: try:
@ -301,7 +301,7 @@ def destroy_role(connection, module):
module.exit_json(changed=True) module.exit_json(changed=True)
def get_role(connection, name): def get_role(connection, name, module):
params = dict() params = dict()
params['RoleName'] = name params['RoleName'] = name

Loading…
Cancel
Save