Skip to content

Commit

Permalink
ec2_transit_gateway_vpc_attachment - retry on IncorrectState (ansible…
Browse files Browse the repository at this point in the history
…-collections#1147)

ec2_transit_gateway_vpc_attachment - retry on IncorrectState

SUMMARY
Follows on from ansible-collections#1110 - to retry ec2_transit_gateway_vpc_attachment failures
Doing this separately because it's not in the stable-3 branch.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ec2_transit_gateway_vpc_attachment
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
  • Loading branch information
tremble authored May 17, 2022
1 parent 8794784 commit 3347cb0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion plugins/module_utils/transitgateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,23 @@ def _get_tgw_vpc_attachment(self, **params):
return attachment


class TransitGatewayVpcAttachmentManager(TGWAttachmentBoto3Mixin, BaseEc2Manager):
class BaseTGWManager(BaseEc2Manager):

@Boto3Mixin.aws_error_handler('connect to AWS')
def _create_client(self, client_name='ec2'):
if client_name == 'ec2':
error_codes = ['IncorrectState']
else:
error_codes = []

retry_decorator = AWSRetry.jittered_backoff(
catch_extra_error_codes=error_codes,
)
client = self.module.client(client_name, retry_decorator=retry_decorator)
return client


class TransitGatewayVpcAttachmentManager(TGWAttachmentBoto3Mixin, BaseTGWManager):

TAG_RESOURCE_TYPE = 'transit-gateway-attachment'

Expand Down

0 comments on commit 3347cb0

Please sign in to comment.