Skip to content

Commit

Permalink
ec2_vpc_route_table: Don't fail if a route was already created. (ansi…
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhorning authored and jillr committed Aug 26, 2021
1 parent cccc839 commit b16969d
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions plugins/modules/ec2_vpc_route_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,20 +492,16 @@ def ensure_routes(connection=None, module=None, route_table=None, route_specs=No

for route_spec in route_specs_to_recreate:
try:
connection.replace_route(
aws_retry=True,
RouteTableId=route_table['RouteTableId'],
**route_spec)
connection.replace_route(aws_retry=True, RouteTableId=route_table['RouteTableId'], **route_spec)
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg="Couldn't recreate route")

for route_spec in route_specs_to_create:
try:
connection.create_route(
aws_retry=True,
RouteTableId=route_table['RouteTableId'],
**route_spec)
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
connection.create_route(aws_retry=True, RouteTableId=route_table['RouteTableId'], **route_spec)
except is_boto3_error_code('RouteAlreadyExists'):
changed = False
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: # pylint: disable=duplicate-except
module.fail_json_aws(e, msg="Couldn't create route")

return {'changed': bool(changed)}
Expand Down

0 comments on commit b16969d

Please sign in to comment.