Skip to content

Commit

Permalink
module_utils.batch remove unused AWSConnection (#831)
Browse files Browse the repository at this point in the history
module_utils.batch remove unused AWSConnection

SUMMARY
Remove deprecated and unused AWSConnection class from ansible_collections.amazon.aws.plugins.module_utils.batch
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
plugins/module_utils/batch.py
ADDITIONAL INFORMATION
See also ansible/ansible#67191

Reviewed-by: Alina Buzachis <None>
  • Loading branch information
tremble authored May 24, 2022
1 parent b002515 commit 165a881
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 48 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/67191-remove-AWSConnection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
removed_features:
- module_utils.batch - the class ``ansible_collections.amazon.aws.plugins.module_utils.batch.AWSConnection`` has been removed. Please use ``AnsibleAWSModule.client()`` instead (https://github.com/ansible-collections/amazon.aws/pull/831).
48 changes: 0 additions & 48 deletions plugins/module_utils/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,56 +32,8 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

try:
from botocore.exceptions import ClientError
except ImportError:
pass

from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict

from .ec2 import boto3_conn
from .ec2 import get_aws_connection_info


class AWSConnection(object):
"""
Create the connection object and client objects as required.
"""

def __init__(self, ansible_obj, resources, boto3=True):

ansible_obj.deprecate("The 'AWSConnection' class is deprecated, please use 'AnsibleAWSModule.client()'",
date='2022-06-01', collection_name='amazon.aws')

self.region, self.endpoint, aws_connect_kwargs = get_aws_connection_info(ansible_obj, boto3=boto3)

self.resource_client = dict()
if not resources:
resources = ['batch']

resources.append('iam')

for resource in resources:
aws_connect_kwargs.update(dict(region=self.region,
endpoint=self.endpoint,
conn_type='client',
resource=resource
))
self.resource_client[resource] = boto3_conn(ansible_obj, **aws_connect_kwargs)

# if region is not provided, then get default profile/session region
if not self.region:
self.region = self.resource_client['batch'].meta.region_name

# set account ID
try:
self.account_id = self.resource_client['iam'].get_user()['User']['Arn'].split(':')[4]
except (ClientError, ValueError, KeyError, IndexError):
self.account_id = ''

def client(self, resource='batch'):
return self.resource_client[resource]


def cc(key):
"""
Expand Down

0 comments on commit 165a881

Please sign in to comment.