Skip to content

Commit f5af6df

Browse files
authored
Merge pull request #25 from belodetek/ab77/patch
patch: Use boto session for all clients
2 parents 22b7bc5 + 8cf6f0c commit f5af6df

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

generic_provider/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ FROM public.ecr.aws/lambda/python:3.11 AS build
33

44
WORKDIR ${LAMBDA_TASK_ROOT}/build
55

6+
# FIXME: https://github.com/aws/aws-lambda-base-images/issues/245#issuecomment-2725656680
67
RUN yum update -y \
78
&& yum groupinstall "Development Tools" -y \
8-
&& yum install -y ibffi openssl-devel
9+
&& yum install -y ibffi openssl-devel-1.0.2k-24.amzn2.0.14
910

1011
COPY requirements.txt .
1112

generic_provider/autoscaling.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ def __init__(self, *args, **kwargs):
1515
'args: {}, kwargs: {}'.format(args, kwargs),
1616
file=sys.stderr
1717
)
18-
18+
self.session = boto3.session.Session(**kwargs)
19+
self.region_name = kwargs['region_name']
1920

2021
def filter_launch_configuration(self, *args, **kwargs):
2122
if self.verbose: print(
@@ -71,7 +72,7 @@ def filter_launch_configuration(self, *args, **kwargs):
7172
instance_profile = kwargs['launch_template_data']['IamInstanceProfile'].split('/')[-1:][0]
7273
kwargs['launch_template_data'].pop('IamInstanceProfile', None)
7374
kwargs['launch_template_data']['IamInstanceProfile'] = {}
74-
client = boto3.client('iam')
75+
client = self.session.client('iam')
7576
response = client.get_instance_profile(
7677
InstanceProfileName=instance_profile
7778
)
@@ -109,7 +110,7 @@ def describe_launch_configuration(self, *args, **kwargs):
109110
file=sys.stderr
110111
)
111112

112-
client = boto3.client('autoscaling')
113+
client = self.session.client('autoscaling')
113114
response = client.describe_launch_configurations(
114115
LaunchConfigurationNames=[kwargs['launch_configuration_name']]
115116
)
@@ -136,7 +137,7 @@ def create_launch_template_from_configuration(self, *args, **kwargs):
136137
launch_template_name = kwargs['LaunchTemplateName']
137138
description = kwargs['Description']
138139

139-
client = boto3.client('ec2')
140+
client = self.session.client('ec2')
140141
response = client.create_launch_template(
141142
LaunchTemplateName=launch_template_name,
142143
VersionDescription=description,
@@ -160,7 +161,7 @@ def delete_launch_template(self, *args, **kwargs):
160161
file=sys.stderr
161162
)
162163

163-
client = boto3.client('ec2')
164+
client = self.session.client('ec2')
164165
response = client.delete_launch_template(**kwargs)
165166

166167
if self.verbose: print(
@@ -189,7 +190,7 @@ def update_auto_scaling_group(self, *args, **kwargs):
189190
file=sys.stderr
190191
)
191192

192-
client = boto3.client('autoscaling')
193+
client = self.session.client('autoscaling')
193194
response = client.update_auto_scaling_group(
194195
AutoScalingGroupName=auto_scaling_group_name,
195196
MixedInstancesPolicy=mixed_instances_policy

0 commit comments

Comments
 (0)