Skip to content

Commit

Permalink
Issue #3 write_results determine_compliance requires no InfractionIte…
Browse files Browse the repository at this point in the history
…ms from query and not not SUCCEEDED in nestedSfns

Former-commit-id: eebae9f
  • Loading branch information
cschneider-vertical-relevance committed Apr 29, 2022
1 parent cca4745 commit a0d1d3d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
29 changes: 28 additions & 1 deletion stacks/control_broker_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,32 @@ def deploy_outer_sfn(self):
},
},
},
# "WriteDefaultDenyTemplateProcessingCompleteStatus": {
# "Type" : "Task",
# "Next" : "ForEachEvalResult",
# "ResultPath" : "$.SetMaxIndexZero",
# "Resource" : "arn:aws:states:::dynamodb:updateItem",
# "ResultSelector" : {
# "HttpStatusCode.$" : "$.SdkHttpMetadata.HttpStatusCode"
# },
# "Parameters" : {
# "TableName" : self.table_eval_results.table_name,
# "Key" : {
# "pk" : {
# "S.$" : "$.OuterEvalEngineSfnExecutionId"
# },
# "sk" : {
# "S.$" : "$$.Execution.Id"
# }
# },
# "ExpressionAttributeValues" : {
# ":true" : {
# "BOOL" : True
# },
# },
# "UpdateExpression" : "SET DefaultDenyTemplateProcessingCompleteStatus = :true",
# }
# },
"WriteResultsReport": {
"Type": "Task",
"End": True,
Expand All @@ -748,7 +774,8 @@ def deploy_outer_sfn(self):
"FunctionName": self.lambda_write_results_report.function_name,
"Payload": {
"OuterEvalEngineSfnExecutionId.$": "$$.Execution.Id",
"ResultsReportS3Uri.$":"$.ResultsReportS3Uri"
"ResultsReportS3Uri.$":"$.ResultsReportS3Uri",
"ForEachInput.$":"$.ForEachInput",
}
},
"ResultSelector": {"Payload.$": "$.Payload"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,23 @@ def simple_pk_query(*,

return items

def determine_compliance(*,InfractionItems):
return not bool(InfractionItems)
def determine_compliance(*,InfractionItems,AllNestedSfnsSucceeded):
no_infractions = not bool(InfractionItems)

return no_infractions and AllNestedSfnsSucceeded

def determine_if_all_nested_sfns_succeeded(*,NestedSfns):
return not bool([i for i in NestedSfns if i['InvokeInnerEvalEngineSfn']['Status']!='SUCCEEDED'])


def lambda_handler(event, context):

print(event)

invoking_sfn_for_each_input = event['ForEachInput']

all_nested_sfns_succeeded = determine_if_all_nested_sfns_succeeded(NestedSfns=invoking_sfn_for_each_input)

sfn_exec_id = event['OuterEvalEngineSfnExecutionId']

print(f'sfn_exec_id:\n{sfn_exec_id}')
Expand All @@ -78,6 +88,11 @@ def lambda_handler(event, context):
Pk = sfn_exec_id
)

compliance = determine_compliance(
InfractionItems = infraction_items,
AllNestedSfnsSucceeded = all_nested_sfns_succeeded
),

eval_results_report = {
"ControlBrokerResultsReport": {
"Metadata": {
Expand All @@ -90,17 +105,17 @@ def lambda_handler(event, context):
}
},
"Evaluation": {
"IsCompliant" : determine_compliance(InfractionItems=infraction_items),
"IsCompliant" : compliance,
"InfractionItems" : infraction_items
}
}
}

print(f'eval_results_report:\n{eval_results_report}')

put_object(
S3Uri = event['ResultsReportS3Uri'],
Dict = eval_results_report
)



return True

0 comments on commit a0d1d3d

Please sign in to comment.