|
2 | 2 | import base64 |
3 | 3 | import botocore |
4 | 4 | import os |
5 | | -import yaml |
6 | 5 | import json |
7 | 6 | import logging |
8 | 7 | import time |
9 | | -from requests_toolbelt import MultipartDecoder |
10 | 8 | import zipfile |
| 9 | +from botocore.config import Config |
11 | 10 | from chalice import Chalice, Response, ChaliceViewError, BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, ConflictError, TooManyRequestsError, IAMAuthorizer |
12 | 11 |
|
13 | 12 |
|
14 | 13 | # Misc global variables |
15 | 14 |
|
16 | | - |
17 | 15 | app = Chalice(app_name='api') |
18 | 16 | app.log.setLevel(logging.DEBUG) |
19 | 17 | efs_lambda = os.path.join( |
20 | 18 | os.path.dirname(__file__), 'chalicelib', 'efs_lambda.py') |
21 | 19 |
|
| 20 | +sfm_config = json.loads(os.environ['botoConfig']) |
| 21 | +config = Config(**sfm_config) |
| 22 | + |
22 | 23 | # Cognito resources |
23 | 24 | # From cloudformation stack |
24 | | -authorizer = IAMAuthorizer() |
25 | 25 |
|
| 26 | +authorizer = IAMAuthorizer() |
26 | 27 |
|
27 | 28 | # AWS Clients |
28 | 29 |
|
29 | | -efs = boto3.client('efs') |
30 | | -serverless = boto3.client('lambda') |
31 | | -iam = boto3.client('iam') |
| 30 | +efs = boto3.client('efs', config=config) |
| 31 | +serverless = boto3.client('lambda', config=config) |
| 32 | +iam = boto3.client('iam', config=config) |
32 | 33 |
|
33 | 34 |
|
34 | 35 | # Helper functions |
@@ -139,7 +140,6 @@ def create_function_role(filesystem_name): |
139 | 140 | ] |
140 | 141 | } |
141 | 142 |
|
142 | | - # TODO: Prepend this role name with the stack name |
143 | 143 | role_name = f'{filesystem_name}-manager-role' |
144 | 144 | path = '/' |
145 | 145 | description = f'IAM Role for filesystem {filesystem_name} manager lambda' |
@@ -172,7 +172,6 @@ def create_function_role(filesystem_name): |
172 | 172 |
|
173 | 173 |
|
174 | 174 | def create_function(filesystem_id, access_point_arn, vpc): |
175 | | - # TODO: Add lambda resource policy to prevent this function from being invoked by anything other than this API handler |
176 | 175 | code = create_function_zip() |
177 | 176 | role = create_function_role(filesystem_id) |
178 | 177 | # TODO: Add retry logic instead of relying on sleep |
@@ -254,7 +253,6 @@ def list_filesystems(): |
254 | 253 | raise ChaliceViewError("Check API logs") |
255 | 254 | else: |
256 | 255 | filesystems = response['FileSystems'] |
257 | | - #app.log.debug(filesystems) |
258 | 256 | formatted_filesystems = [] |
259 | 257 | for filesystem in filesystems: |
260 | 258 | formatted = format_filesystem_response(filesystem) |
|
0 commit comments