Skip to content

Commit

Permalink
Merge branch 'refactor/account-processing' of github.com:StewartW/aws…
Browse files Browse the repository at this point in the history
…-deployment-framework into refactor/account-processing
  • Loading branch information
StewartW committed Nov 17, 2021
2 parents 7495fd3 + 873b7a7 commit f924ce0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions src/lambda_codebase/account_processing/process_account_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import json
import os
from typing import Tuple
import yaml
from yaml.error import YAMLError

Expand All @@ -35,15 +34,14 @@ def get_details_from_event(event: dict):


def get_file_from_s3(s3_object: dict, s3_client: boto3.resource):
bucket_name, object_key = s3_object
s3_object = s3_client.Object(bucket_name, object_key)
s3_object = s3_client.Object(**s3_object)
try:
s3_object.download_file(f"/tmp/{object_key}")
s3_object.download_file(f"/tmp/{s3_object.get('object_key')}")
except ClientError as e:
LOGGER.error(f"Failed to download {object_key} from {bucket_name}")
LOGGER.error(f"Failed to download {s3_object.get('object_key')} from {s3_object.get('bucket_name')}")
raise e
try:
with open(f"/tmp/{object_key}", encoding="utf-8") as data_stream:
with open(f"/tmp/{s3_object.get('object_key')}", encoding="utf-8") as data_stream:
data = yaml.safe_load(data_stream)
except YAMLError as p_e:
LOGGER.error("Failed to parse YAML file")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_support_level(self) -> SupportLevel:
"""
try:
severity_levels = self.client.describe_severity_levels()["severityLevels"]
available_support_codes = [level["code"] for level in severity_levels]
available_support_codes = list(map(lambda s: s["code"], severity_levels))

# See: https://aws.amazon.com/premiumsupport/plans/ for insights into the interpretation of
# the available support codes.
Expand Down
2 changes: 1 addition & 1 deletion src/lambda_codebase/account_processing/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pyyaml>=5.4.1
wrapt==1.12
wrapt==1.12 # https://github.com/aws/aws-lambda-builders/issues/302
aws-xray-sdk==2.8.0

0 comments on commit f924ce0

Please sign in to comment.