Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.

Commit 688b226

Browse files
authored
update user agent string with solution id / little code cleanup (#53)
1 parent 42cc59b commit 688b226

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

deployment/efs-file-manager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Resources:
9393
]
9494
Parameters:
9595
ApiHandlerIamRole: !GetAtt EFSFileManagerIamRole.Arn
96-
botoConfig: '{"user_agent_extra": "AwsSolution/XXX/%%VERSION%%"}'
96+
botoConfig: '{"user_agent_extra": "AwsSolution/SO0145/%%VERSION%%"}'
9797
DeploymentPackageBucket:
9898
!Join ["-", [!FindInMap ["SourceCode", "General", "RegionalS3Bucket"], Ref: "AWS::Region"]]
9999
DeploymentPackageKey:

source/api/.chalice/config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"version": "2.0",
33
"app_name": "api",
4+
"environment_variables": {
5+
"botoConfig": "{}"
6+
},
47
"stages": {
58
"dev": {
69
"manage_iam_role": false,

source/api/app.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,34 @@
22
import base64
33
import botocore
44
import os
5-
import yaml
65
import json
76
import logging
87
import time
9-
from requests_toolbelt import MultipartDecoder
108
import zipfile
9+
from botocore.config import Config
1110
from chalice import Chalice, Response, ChaliceViewError, BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, ConflictError, TooManyRequestsError, IAMAuthorizer
1211

1312

1413
# Misc global variables
1514

16-
1715
app = Chalice(app_name='api')
1816
app.log.setLevel(logging.DEBUG)
1917
efs_lambda = os.path.join(
2018
os.path.dirname(__file__), 'chalicelib', 'efs_lambda.py')
2119

20+
sfm_config = json.loads(os.environ['botoConfig'])
21+
config = Config(**sfm_config)
22+
2223
# Cognito resources
2324
# From cloudformation stack
24-
authorizer = IAMAuthorizer()
2525

26+
authorizer = IAMAuthorizer()
2627

2728
# AWS Clients
2829

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)
3233

3334

3435
# Helper functions
@@ -139,7 +140,6 @@ def create_function_role(filesystem_name):
139140
]
140141
}
141142

142-
# TODO: Prepend this role name with the stack name
143143
role_name = f'{filesystem_name}-manager-role'
144144
path = '/'
145145
description = f'IAM Role for filesystem {filesystem_name} manager lambda'
@@ -172,7 +172,6 @@ def create_function_role(filesystem_name):
172172

173173

174174
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
176175
code = create_function_zip()
177176
role = create_function_role(filesystem_id)
178177
# TODO: Add retry logic instead of relying on sleep
@@ -254,7 +253,6 @@ def list_filesystems():
254253
raise ChaliceViewError("Check API logs")
255254
else:
256255
filesystems = response['FileSystems']
257-
#app.log.debug(filesystems)
258256
formatted_filesystems = []
259257
for filesystem in filesystems:
260258
formatted = format_filesystem_response(filesystem)

0 commit comments

Comments
 (0)