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>

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@3347cb0
  • Loading branch information
tremble authored and alinabuzachis committed Oct 18, 2024
1 parent c278853 commit 146535f
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 146535f

Please sign in to comment.