@@ -15,7 +15,8 @@ def __init__(self, *args, **kwargs):
15
15
'args: {}, kwargs: {}' .format (args , kwargs ),
16
16
file = sys .stderr
17
17
)
18
-
18
+ self .session = boto3 .session .Session (** kwargs )
19
+ self .region_name = kwargs ['region_name' ]
19
20
20
21
def filter_launch_configuration (self , * args , ** kwargs ):
21
22
if self .verbose : print (
@@ -71,7 +72,7 @@ def filter_launch_configuration(self, *args, **kwargs):
71
72
instance_profile = kwargs ['launch_template_data' ]['IamInstanceProfile' ].split ('/' )[- 1 :][0 ]
72
73
kwargs ['launch_template_data' ].pop ('IamInstanceProfile' , None )
73
74
kwargs ['launch_template_data' ]['IamInstanceProfile' ] = {}
74
- client = boto3 .client ('iam' )
75
+ client = self . session .client ('iam' )
75
76
response = client .get_instance_profile (
76
77
InstanceProfileName = instance_profile
77
78
)
@@ -109,7 +110,7 @@ def describe_launch_configuration(self, *args, **kwargs):
109
110
file = sys .stderr
110
111
)
111
112
112
- client = boto3 .client ('autoscaling' )
113
+ client = self . session .client ('autoscaling' )
113
114
response = client .describe_launch_configurations (
114
115
LaunchConfigurationNames = [kwargs ['launch_configuration_name' ]]
115
116
)
@@ -136,7 +137,7 @@ def create_launch_template_from_configuration(self, *args, **kwargs):
136
137
launch_template_name = kwargs ['LaunchTemplateName' ]
137
138
description = kwargs ['Description' ]
138
139
139
- client = boto3 .client ('ec2' )
140
+ client = self . session .client ('ec2' )
140
141
response = client .create_launch_template (
141
142
LaunchTemplateName = launch_template_name ,
142
143
VersionDescription = description ,
@@ -160,7 +161,7 @@ def delete_launch_template(self, *args, **kwargs):
160
161
file = sys .stderr
161
162
)
162
163
163
- client = boto3 .client ('ec2' )
164
+ client = self . session .client ('ec2' )
164
165
response = client .delete_launch_template (** kwargs )
165
166
166
167
if self .verbose : print (
@@ -189,7 +190,7 @@ def update_auto_scaling_group(self, *args, **kwargs):
189
190
file = sys .stderr
190
191
)
191
192
192
- client = boto3 .client ('autoscaling' )
193
+ client = self . session .client ('autoscaling' )
193
194
response = client .update_auto_scaling_group (
194
195
AutoScalingGroupName = auto_scaling_group_name ,
195
196
MixedInstancesPolicy = mixed_instances_policy
0 commit comments