|
24 | 24 | from .helpers import timestamp |
25 | 25 |
|
26 | 26 |
|
| 27 | +ARN_PREFIXES = { |
| 28 | + 'us-gov-west-1': 'aws-us-gov' |
| 29 | +} |
| 30 | + |
27 | 31 | log = logging.getLogger(__name__) |
28 | 32 |
|
29 | 33 |
|
@@ -358,9 +362,10 @@ def pip_install_to_target(path, requirements=False, local_package=None): |
358 | 362 | _install_packages(path, packages) |
359 | 363 |
|
360 | 364 |
|
361 | | -def get_role_name(account_id, role): |
| 365 | +def get_role_name(region, account_id, role): |
362 | 366 | """Shortcut to insert the `account_id` and `role` into the iam string.""" |
363 | | - return 'arn:aws:iam::{0}:role/{1}'.format(account_id, role) |
| 367 | + prefix = ARN_PREFIXES.get(region, 'aws') |
| 368 | + return 'arn:{0}:iam::{1}:role/{2}'.format(prefix, account_id, role) |
364 | 369 |
|
365 | 370 |
|
366 | 371 | def get_account_id(aws_access_key_id, aws_secret_access_key): |
@@ -389,7 +394,7 @@ def create_function(cfg, path_to_zip_file): |
389 | 394 | aws_secret_access_key = cfg.get('aws_secret_access_key') |
390 | 395 |
|
391 | 396 | account_id = get_account_id(aws_access_key_id, aws_secret_access_key) |
392 | | - role = get_role_name(account_id, cfg.get('role', 'lambda_basic_execution')) |
| 397 | + role = get_role_name(cfg.get('region'), account_id, cfg.get('role', 'lambda_basic_execution')) |
393 | 398 |
|
394 | 399 | client = get_client( |
395 | 400 | 'lambda', aws_access_key_id, aws_secret_access_key, |
@@ -436,7 +441,7 @@ def update_function(cfg, path_to_zip_file): |
436 | 441 | aws_secret_access_key = cfg.get('aws_secret_access_key') |
437 | 442 |
|
438 | 443 | account_id = get_account_id(aws_access_key_id, aws_secret_access_key) |
439 | | - role = get_role_name(account_id, cfg.get('role', 'lambda_basic_execution')) |
| 444 | + role = get_role_name(cfg.get('region'), account_id, cfg.get('role', 'lambda_basic_execution')) |
440 | 445 |
|
441 | 446 | client = get_client( |
442 | 447 | 'lambda', aws_access_key_id, aws_secret_access_key, |
|
0 commit comments