Skip to content

Commit 79a0c29

Browse files
committed
fixing mypy errors
1 parent 2fb9933 commit 79a0c29

File tree

14 files changed

+21
-17
lines changed
  • aws_sra_examples/solutions

14 files changed

+21
-17
lines changed

aws_sra_examples/solutions/ami_bakery/ami_bakery_org/lambda/src/codepipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def create_codepipeline(
9090
"roleArn": "arn:" + aws_partition + ":iam::" + account_id + ":role/" + codepipeline_role_name,
9191
"artifactStore": {"type": "S3", "location": bucket_name},
9292
"stages": [
93-
{ # type: ignore
93+
{
9494
"name": pipeline_name + "-CodeCommitSource",
9595
"actions": [
9696
{
@@ -104,7 +104,7 @@ def create_codepipeline(
104104
}
105105
],
106106
},
107-
{ # type: ignore
107+
{
108108
"name": pipeline_name + "-DeployEC2ImageBuilder",
109109
"actions": [
110110
{

aws_sra_examples/solutions/config/config_org/lambda/src/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def set_config_in_org(
9292
configuration_recorder: ConfigurationRecorderTypeDef = {
9393
"name": recorder_name,
9494
"roleARN": role_arn,
95-
"recordingGroup": { # type: ignore
95+
"recordingGroup": {
9696
"allSupported": all_supported,
9797
"includeGlobalResourceTypes": include_global_resource_types,
9898
"resourceTypes": resource_types,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,6 @@ def lambda_handler(event: dict, context: Any) -> None: # noqa: U100
104104

105105
# Submit compliance evaluations
106106
if evaluations:
107-
config_client.put_evaluations(Evaluations=evaluations, ResultToken=event["resultToken"])
107+
config_client.put_evaluations(Evaluations=evaluations, ResultToken=event["resultToken"]) # type: ignore
108108

109109
LOGGER.info(f"Compliance evaluation complete. Processed {len(evaluations)} evaluations.")

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def evaluate_compliance(rule_parameters: dict) -> tuple[str, str]: # noqa: CFQ0
6161

6262
except ClientError as e:
6363
if e.response['Error']['Code'] == 'AccessDeniedException':
64-
LOGGER.info(f"Access denied. If guardrail uses KMS encryption, ensure Lambda's IAM role has permissions to the KMS key.")
64+
LOGGER.info("Access denied. If guardrail uses KMS encryption, ensure Lambda's IAM role has permissions to the KMS key.")
6565
return "NON_COMPLIANT", (
6666
"Access denied. If guardrail uses KMS encryption, ensure Lambda's IAM role has permissions to the KMS key."
6767
)
@@ -95,6 +95,6 @@ def lambda_handler(event: dict, context: Any) -> None: # noqa: U100
9595
LOGGER.info(f"Compliance evaluation result: {compliance_type}")
9696
LOGGER.info(f"Annotation: {annotation}")
9797

98-
config_client.put_evaluations(Evaluations=[evaluation], ResultToken=event["resultToken"])
98+
config_client.put_evaluations(Evaluations=[evaluation], ResultToken=event["resultToken"]) # type: ignore
9999

100100
LOGGER.info("Compliance evaluation complete.")

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
@@ -130,7 +130,7 @@ def lambda_handler(event: dict, context: Any) -> dict: # noqa: CCR001, C901, U1
130130
config = boto3.client("config")
131131

132132
try:
133-
response = config.put_evaluations(Evaluations=[evaluation], ResultToken=event["resultToken"])
133+
response = config.put_evaluations(Evaluations=[evaluation], ResultToken=event["resultToken"]) # type: ignore
134134
LOGGER.info(f"Evaluation sent successfully: {response}")
135135
except Exception as e:
136136
LOGGER.error(f"Error sending evaluation: {str(e)}")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def lambda_handler(event: dict, context: Any) -> dict:
161161
"OrderingTimestamp": invoking_event["notificationCreationTime"],
162162
}
163163
],
164-
ResultToken=result_token,
164+
ResultToken=result_token, # type: ignore
165165
)
166166

167167
# Return the evaluation result

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,6 @@ def lambda_handler(event: dict, context: Any) -> None: # noqa: U100
103103
LOGGER.info(f"Compliance evaluation result: {compliance_type}")
104104
LOGGER.info(f"Annotation: {annotation}")
105105

106-
config_client.put_evaluations(Evaluations=[evaluation], ResultToken=event["resultToken"])
106+
config_client.put_evaluations(Evaluations=[evaluation], ResultToken=event["resultToken"]) # type: ignore
107107

108108
LOGGER.info("Compliance evaluation complete.")

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
# Global variables
3434
BUCKET_NAME = ""
3535

36+
3637
def evaluate_compliance(rule_parameters: dict) -> tuple[str, str]: # noqa: CFQ004, CCR001, C901
3738
"""Evaluate if Bedrock Model Invocation Logging is properly configured for S3.
3839
@@ -139,6 +140,6 @@ def lambda_handler(event: dict, context: Any) -> None: # noqa: U100
139140
LOGGER.info(f"Compliance evaluation result: {compliance_type}")
140141
LOGGER.info(f"Annotation: {annotation}")
141142

142-
config_client.put_evaluations(Evaluations=[evaluation], ResultToken=event["resultToken"])
143+
config_client.put_evaluations(Evaluations=[evaluation], ResultToken=event["resultToken"]) # type: ignore
143144

144145
LOGGER.info("Compliance evaluation complete.")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,6 @@ def lambda_handler(event: dict, context: Any) -> None: # noqa: U100
108108

109109
# Submit compliance evaluations
110110
if evaluations:
111-
config_client.put_evaluations(Evaluations=evaluations, ResultToken=event["resultToken"])
111+
config_client.put_evaluations(Evaluations=evaluations, ResultToken=event["resultToken"]) # type: ignore
112112

113113
LOGGER.info(f"Compliance evaluation complete. Processed {len(evaluations)} evaluations.")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,6 @@ def lambda_handler(event: dict, context: Any) -> None: # noqa: U100
120120

121121
# Submit compliance evaluations
122122
if evaluations:
123-
config_client.put_evaluations(Evaluations=evaluations, ResultToken=event["resultToken"])
123+
config_client.put_evaluations(Evaluations=evaluations, ResultToken=event["resultToken"]) # type: ignore
124124

125125
LOGGER.info(f"Compliance evaluation complete. Processed {len(evaluations)} evaluations.")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def create_lambda_function( # noqa: CFQ002, CCR001
9696
try:
9797
create_response = self.LAMBDA_CLIENT.create_function(
9898
FunctionName=function_name,
99-
Runtime=runtime,
99+
Runtime=runtime, # type: ignore
100100
Handler=handler,
101101
Role=role_arn,
102102
Code={"ZipFile": open(code_zip_file, "rb").read()}, # noqa: SIM115

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ def create_s3_bucket(self, bucket: str) -> None:
8989
"""
9090
if self.REGION != "us-east-1":
9191
create_bucket = self.S3_CLIENT.create_bucket(
92-
ACL="private", Bucket=bucket, CreateBucketConfiguration={"LocationConstraint": self.REGION}, ObjectOwnership="BucketOwnerPreferred"
92+
ACL="private",
93+
Bucket=bucket,
94+
CreateBucketConfiguration={"LocationConstraint": self.REGION}, # type: ignore
95+
ObjectOwnership="BucketOwnerPreferred"
9396
)
9497
else:
9598
create_bucket = self.S3_CLIENT.create_bucket(ACL="private", Bucket=bucket, ObjectOwnership="BucketOwnerPreferred")

aws_sra_examples/solutions/patch_mgmt/patch_mgmt_org/lambda/src/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def manage_task_params(
369369
"""
370370
if task_operation is None and task_reboot_option is None:
371371
no_param_response: MaintenanceWindowTaskInvocationParametersTypeDef = {
372-
"RunCommand": { # type: ignore
372+
"RunCommand": {
373373
"Parameters": {},
374374
"DocumentVersion": "$DEFAULT",
375375
"TimeoutSeconds": 3600,
@@ -382,7 +382,7 @@ def manage_task_params(
382382
task_operation_final: str = "INVALID_TASK_OPERATION_PROVIDED" if task_operation is None else task_operation
383383
task_reboot_option_final: str = "INVALID_TASK_REBOOT_OPTION_PROVIDED" if task_reboot_option is None else task_reboot_option
384384
with_params_response: MaintenanceWindowTaskInvocationParametersTypeDef = {
385-
"RunCommand": { # type: ignore
385+
"RunCommand": {
386386
"Parameters": {
387387
"Operation": [task_operation_final],
388388
"RebootOption": [task_reboot_option_final],

aws_sra_examples/solutions/security_lake/security_lake_org/lambda/src/security_lake.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ def set_lake_formation_permissions(lf_client: LakeFormationClient, account: str,
913913
try:
914914
resource: Union[ResourceTypeDef] = {
915915
"Database": {"CatalogId": account, "Name": db_name + "_subscriber"},
916-
"Table": {"CatalogId": account, "DatabaseName": db_name + "_subscriber", "Name": "rl_*"}, # type: ignore
916+
"Table": {"CatalogId": account, "DatabaseName": db_name + "_subscriber", "Name": "rl_*"},
917917
}
918918
lf_client.grant_permissions(
919919
CatalogId=account,

0 commit comments

Comments
 (0)