Skip to content

Commit 2e48252

Browse files
committed
fixing flake8 issues
1 parent 3b35473 commit 2e48252

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

aws_sra_examples/solutions/genai/bedrock_org/lambda/src/app.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,8 +1060,9 @@ def deploy_metric_filters_and_alarms(region: str, accounts: list, resource_prope
10601060
LOGGER.info(f"Filter deploy parameter is 'true'; deploying {filter_name} CloudWatch metric filter...")
10611061
search_log_group, log_group_arn = cloudwatch.find_log_group(filter_params["log_group_name"])
10621062
if search_log_group is False:
1063-
LOGGER.info(f"Log group {filter_params['log_group_name']} not found! Skipping {filter_name} filter deployment...")
1064-
LIVE_RUN_DATA[f"{filter_name}_CloudWatch"] = f"Log group {filter_params['log_group_name']} not found! Skipped {filter_name} filter deployment."
1063+
search_message = f"Log group {filter_params['log_group_name']} not found! Skiped {filter_name} filter deployment..."
1064+
LOGGER.info(search_message)
1065+
LIVE_RUN_DATA[f"{filter_name}_CloudWatch"] = search_message
10651066
continue
10661067
deploy_metric_filter(
10671068
region, acct, filter_params["log_group_name"], filter_name, filter_pattern, f"{filter_name}-metric", "sra-bedrock", "1"
@@ -2299,6 +2300,8 @@ def lambda_handler(event: dict, context: Any) -> dict: # noqa: CCR001
22992300
global LAMBDA_START
23002301
global LAMBDA_FINISH
23012302
global LAMBDA_RECORD_ID
2303+
global DRY_RUN
2304+
23022305
LAMBDA_START = dynamodb.get_date_time()
23032306
LOGGER.info(event)
23042307
LOGGER.info({"boto3 version": boto3.__version__})
@@ -2328,7 +2331,6 @@ def lambda_handler(event: dict, context: Any) -> dict: # noqa: CCR001
23282331
LOGGER.info("DELETE EVENT!!")
23292332
# Set DRY_RUN to False if we are deleting via CloudFormation (should do this with Terraform as well); stack will be gone.
23302333
if RESOURCE_TYPE != "Other":
2331-
global DRY_RUN
23322334
DRY_RUN = False
23332335
delete_event(event, context)
23342336

@@ -2353,20 +2355,20 @@ def lambda_handler(event: dict, context: Any) -> dict: # noqa: CCR001
23532355
"end_time": LAMBDA_FINISH,
23542356
"lambda_result": "SUCCESS",
23552357
}
2358+
if DRY_RUN is False:
2359+
item_found, find_result = dynamodb.find_item(
2360+
STATE_TABLE,
2361+
SOLUTION_NAME,
2362+
{
2363+
"arn": context.invoked_function_arn,
2364+
},
2365+
)
23562366

2357-
item_found, find_result = dynamodb.find_item(
2358-
STATE_TABLE,
2359-
SOLUTION_NAME,
2360-
{
2361-
"arn": context.invoked_function_arn,
2362-
},
2363-
)
2364-
2365-
if item_found is True:
2366-
sra_resource_record_id = find_result["record_id"]
2367-
update_state_table_record(sra_resource_record_id, lambda_data)
2368-
else:
2369-
LOGGER.info(f"Lambda record not found in {STATE_TABLE} table so unable to update it.")
2367+
if item_found is True:
2368+
sra_resource_record_id = find_result["record_id"]
2369+
update_state_table_record(sra_resource_record_id, lambda_data)
2370+
else:
2371+
LOGGER.info(f"Lambda record not found in {STATE_TABLE} table so unable to update it.")
23702372

23712373
return {
23722374
"statusCode": 200,

aws_sra_examples/solutions/genai/bedrock_org/lambda/src/sra_cloudwatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,4 +594,4 @@ def find_log_group(self, log_group_name: str) -> tuple[bool, str]:
594594
self.LOGGER.info(f"CloudWatch log group {log_group_name} not found. Error code: {error.response['Error']['Code']}")
595595
return False, ""
596596
self.LOGGER.info(self.UNEXPECTED)
597-
raise ValueError(f"Unexpected error executing Lambda function. {error}") from None
597+
raise ValueError(f"Unexpected error executing Lambda function. {error}") from None

0 commit comments

Comments
 (0)