Skip to content

Commit 70931cd

Browse files
committed
Merge pull request nficano#4 from carhartl/add-support-for-custom-roles
Add support for custom roles in config
2 parents 4f44148 + 17da39f commit 70931cd

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

aws_lambda/aws_lambda.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ def pip_install_to_target(path):
203203
pip.main(['install', r, '-t', path, '--ignore-installed'])
204204

205205

206-
def get_role_name(account_id):
207-
"""Shortcut to insert the `account_id` into the iam string."""
208-
return "arn:aws:iam::{0}:role/lambda_basic_execution".format(account_id)
206+
def get_role_name(account_id, role):
207+
"""Shortcut to insert the `account_id` and `role` into the iam string."""
208+
return "arn:aws:iam::{0}:role/{1}".format(account_id, role)
209209

210210

211211
def get_account_id(aws_access_key_id, aws_secret_access_key):
@@ -234,7 +234,7 @@ def create_function(cfg, path_to_zip_file):
234234
aws_secret_access_key = cfg.get('aws_secret_access_key')
235235

236236
account_id = get_account_id(aws_access_key_id, aws_secret_access_key)
237-
role = get_role_name(account_id)
237+
role = get_role_name(account_id, cfg.get('role', 'lambda_basic_execution'))
238238

239239
client = get_client('lambda', aws_access_key_id, aws_secret_access_key,
240240
cfg.get('region'))

aws_lambda/project_template/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ region: us-east-1
22

33
function_name: my_lambda_function
44
handler: service.handler
5+
# role: lambda_basic_execution
56
description: My first lambda function
67

78
# if access key and secret are left blank, boto will use the credentials

0 commit comments

Comments
 (0)