added exception handler which then creates the role is none found
@@ -165,9 +165,10 @@ def hashivault_iam_role_create(params):
if value is not None:
kwargs[arg] = value
- if client.get_role(role_name=name, mount_point='aws'):
+ try:
+ if client.get_role(name, 'aws'):
return {'changed': False}
- else:
+ except exceptions.InvalidPath:
client.create_role(name, mount_point='aws', **kwargs)
return {'changed': True}
