Skip to content

Commit 4f67dc0

Browse files
committed
Merge pull request #15 from calebgroom/profile
Add support for --profile
2 parents 3f92b79 + 2165ac3 commit 4f67dc0

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ with the directory as an option.
4141
lambda-uploader ./myfunc
4242
```
4343

44+
To specify an alternative profile that has been defined in `~/.aws/credentials` use the
45+
`--profile` parameter.
46+
```shell
47+
lambda-uploader --profile=alternative-profile
48+
```
49+
4450
If you would prefer to upload another way you can tell the uploader to ignore the upload.
4551
This will create a package and leave it in the project directory.
4652
```shell

lambda_uploader/shell.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def _execute(args):
6060

6161
if not args.no_upload:
6262
_print('Uploading Package')
63-
uploader.upload_package(pkg, cfg)
63+
uploader.upload_package(pkg, cfg, args.profile)
6464
pkg.clean_zipfile()
6565

6666
_print('Fin')
@@ -86,6 +86,8 @@ def main(arv=None):
8686
action='store_const',
8787
help='publish an upload to an immutable version',
8888
const=True)
89+
parser.add_argument('--profile', dest='profile',
90+
help='specify AWS cli profile')
8991
parser.add_argument('function_dir', default=getcwd(), nargs='?',
9092
help='lambda function directory')
9193

lambda_uploader/uploader.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
LOG = logging.getLogger(__name__)
1919

2020

21-
def upload_package(pkg, config):
21+
def upload_package(pkg, config, profile_name):
2222
with open(pkg.zip_file, "rb") as fil:
2323
zip_file = fil.read()
2424

25-
client = boto3.client('lambda', region_name=config.region)
25+
session = boto3.session.Session(region_name=config.region,
26+
profile_name=profile_name)
27+
client = session.client('lambda')
2628
# Assume the function already exists in AWS
2729
existing_function = True
2830

0 commit comments

Comments
 (0)