@@ -209,13 +209,14 @@ def get_account_id(aws_access_key_id, aws_secret_access_key):
209209 return client .get_user ()['User' ]['Arn' ].split (':' )[4 ]
210210
211211
212- def get_client (client , aws_access_key_id , aws_secret_access_key ):
212+ def get_client (client , aws_access_key_id , aws_secret_access_key , region = None ):
213213 """Shortcut for getting an initialized instance of the boto3 client."""
214214
215215 return boto3 .client (
216216 client ,
217217 aws_access_key_id = aws_access_key_id ,
218- aws_secret_access_key = aws_secret_access_key
218+ aws_secret_access_key = aws_secret_access_key ,
219+ region_name = region
219220 )
220221
221222
@@ -230,7 +231,8 @@ def create_function(cfg, path_to_zip_file):
230231 account_id = get_account_id (aws_access_key_id , aws_secret_access_key )
231232 role = get_role_name (account_id )
232233
233- client = get_client ('lambda' , aws_access_key_id , aws_secret_access_key )
234+ client = get_client ('lambda' , aws_access_key_id , aws_secret_access_key ,
235+ cfg .get ('region' ))
234236
235237 client .create_function (
236238 FunctionName = cfg .get ('function_name' ),
@@ -253,7 +255,8 @@ def update_function(cfg, path_to_zip_file):
253255 aws_access_key_id = cfg .get ('aws_access_key_id' )
254256 aws_secret_access_key = cfg .get ('aws_secret_access_key' )
255257
256- client = get_client ('lambda' , aws_access_key_id , aws_secret_access_key )
258+ client = get_client ('lambda' , aws_access_key_id , aws_secret_access_key ,
259+ cfg .get ('region' ))
257260
258261 client .update_function_code (
259262 FunctionName = cfg .get ('function_name' ),
@@ -267,7 +270,8 @@ def function_exists(cfg, function_name):
267270
268271 aws_access_key_id = cfg .get ('aws_access_key_id' )
269272 aws_secret_access_key = cfg .get ('aws_secret_access_key' )
270- client = get_client ('lambda' , aws_access_key_id , aws_secret_access_key )
273+ client = get_client ('lambda' , aws_access_key_id , aws_secret_access_key ,
274+ cfg .get ('region' ))
271275 functions = client .list_functions ().get ('Functions' , [])
272276 for fn in functions :
273277 if fn .get ('FunctionName' ) == function_name :
0 commit comments