Skip to content

Commit a82f99a

Browse files
committed
fixing black formatter issues
1 parent c66b366 commit a82f99a

File tree

6 files changed

+16
-14
lines changed

6 files changed

+16
-14
lines changed

aws_sra_examples/solutions/genai/bedrock_org/lambda/rules/sra_bedrock_check_guardrail_encryption/app.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,9 @@ def evaluate_compliance(rule_parameters: dict) -> tuple[str, str]: # noqa: CFQ0
6060
return "COMPLIANT", "All Bedrock guardrails are encrypted with a KMS key"
6161

6262
except ClientError as e:
63-
if e.response['Error']['Code'] == 'AccessDeniedException':
63+
if e.response["Error"]["Code"] == "AccessDeniedException":
6464
LOGGER.info("Access denied. If guardrail uses KMS encryption, ensure Lambda's IAM role has permissions to the KMS key.")
65-
return "NON_COMPLIANT", (
66-
"Access denied. If guardrail uses KMS encryption, ensure Lambda's IAM role has permissions to the KMS key."
67-
)
65+
return "NON_COMPLIANT", ("Access denied. If guardrail uses KMS encryption, ensure Lambda's IAM role has permissions to the KMS key.")
6866
LOGGER.error(f"Error evaluating Bedrock guardrails encryption: {str(e)}")
6967
return "ERROR", f"Error evaluating compliance: {str(e)}"
7068

aws_sra_examples/solutions/genai/bedrock_org/lambda/rules/sra_bedrock_check_guardrails/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def lambda_handler(event: dict, context: Any) -> dict: # noqa: CCR001, C901, U1
9797
except bedrock.exceptions.ResourceNotFoundException:
9898
LOGGER.warning(f"Guardrail {guardrail_name} (ID: {guardrail_id}) not found")
9999
except ClientError as client_error:
100-
if client_error.response['Error']['Code'] == 'AccessDeniedException':
100+
if client_error.response["Error"]["Code"] == "AccessDeniedException":
101101
LOGGER.info(
102102
f"Access denied to guardrail {guardrail_name} (ID: {guardrail_id}). "
103103
+ "If guardrail uses KMS encryption, ensure Lambda's IAM role has permissions to the KMS key."

aws_sra_examples/solutions/genai/bedrock_org/lambda/rules/sra_bedrock_check_invocation_log_s3/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def evaluate_compliance(rule_parameters: dict) -> tuple[str, str]: # noqa: CFQ0
7474
if not any(rule.get("Expiration") for rule in lifecycle.get("Rules", [])):
7575
issues.append("retention not set")
7676
except botocore.exceptions.ClientError as client_error:
77-
if client_error.response['Error']['Code'] == 'NoSuchLifecycleConfiguration':
77+
if client_error.response["Error"]["Code"] == "NoSuchLifecycleConfiguration":
7878
LOGGER.info(f"No lifecycle configuration found for S3 bucket: {bucket_name}")
7979
issues.append("lifecycle not set")
8080

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def create_table(self, table_name: str) -> None:
9696
TableName=table_name,
9797
KeySchema=key_schema,
9898
AttributeDefinitions=attribute_definitions,
99-
BillingMode='PAY_PER_REQUEST' # on-demand capacity mode
99+
BillingMode="PAY_PER_REQUEST", # on-demand capacity mode
100100
)
101101
self.LOGGER.info(f"{table_name} dynamodb table created successfully.")
102102
except Exception as e:

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ def create_role(self, role_name: str, trust_policy: dict, solution_name: str) ->
105105
"""
106106
self.LOGGER.info("Creating role %s.", role_name)
107107
try:
108-
return dict(self.IAM_CLIENT.create_role(
109-
RoleName=role_name, AssumeRolePolicyDocument=json.dumps(trust_policy), Tags=[{"Key": "sra-solution", "Value": solution_name}]
110-
))
108+
return dict(
109+
self.IAM_CLIENT.create_role(
110+
RoleName=role_name, AssumeRolePolicyDocument=json.dumps(trust_policy), Tags=[{"Key": "sra-solution", "Value": solution_name}]
111+
)
112+
)
111113
except ClientError as error:
112114
if error.response["Error"]["Code"] == "EntityAlreadyExists":
113115
self.LOGGER.info(f"{role_name} role already exists!")
@@ -126,9 +128,11 @@ def create_policy(self, policy_name: str, policy_document: dict, solution_name:
126128
"""
127129
self.LOGGER.info(f"Creating {policy_name} IAM policy")
128130
try:
129-
return dict(self.IAM_CLIENT.create_policy(
130-
PolicyName=policy_name, PolicyDocument=json.dumps(policy_document), Tags=[{"Key": "sra-solution", "Value": solution_name}]
131-
))
131+
return dict(
132+
self.IAM_CLIENT.create_policy(
133+
PolicyName=policy_name, PolicyDocument=json.dumps(policy_document), Tags=[{"Key": "sra-solution", "Value": solution_name}]
134+
)
135+
)
132136
except ClientError as error:
133137
if error.response["Error"]["Code"] == "EntityAlreadyExists":
134138
self.LOGGER.info(f"{policy_name} policy already exists!")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def create_s3_bucket(self, bucket: str) -> None:
9292
ACL="private",
9393
Bucket=bucket,
9494
CreateBucketConfiguration={"LocationConstraint": self.REGION}, # type: ignore
95-
ObjectOwnership="BucketOwnerPreferred"
95+
ObjectOwnership="BucketOwnerPreferred",
9696
)
9797
else:
9898
create_bucket = self.S3_CLIENT.create_bucket(ACL="private", Bucket=bucket, ObjectOwnership="BucketOwnerPreferred")

0 commit comments

Comments
 (0)