Skip to content

Commit

Permalink
Issue #5 HandleInfractions input adjusted to new model
Browse files Browse the repository at this point in the history
  • Loading branch information
cschneider-vertical-relevance committed May 3, 2022
1 parent b886c52 commit 76734ef
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 67 deletions.
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from stacks.test_stack import TestStack
from stacks.endpoint_stack import EndpointStack

STACK_VERSION = "V0x6x3"
STACK_VERSION = "V0x7x0"

app = cdk.App()
continuously_deployed = app.node.try_get_context(
Expand Down
132 changes: 67 additions & 65 deletions stacks/control_broker_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,7 @@ def deploy_inner_sfn(self):
},
"EvaluateCloudFormationTemplateByOPA": {
"Type": "Task",
# "Next": "GatherInfractions",
"End": True,
"Next": "GatherInfractions",
"ResultPath": "$.EvaluateCloudFormationTemplateByOPA",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
Expand All @@ -768,69 +767,72 @@ def deploy_inner_sfn(self):
"Results.$": "$.Payload.EvaluateCloudFormationTemplateByOPAResults"
},
},
# "GatherInfractions": {
# "Type": "Task",
# "Next": "ChoiceInfractionsExist",
# "ResultPath": "$.GatherInfractions",
# "Resource": "arn:aws:states:::lambda:invoke",
# "Parameters": {
# "FunctionName": self.lambda_gather_infractions.function_name,
# "Payload.$": "$.EvaluateCloudFormationTemplateByOPA.Results",
# },
# "ResultSelector": {
# "Infractions.$": "$.Payload.Infractions"
# },
# },
# "ChoiceInfractionsExist": {
# "Type": "Choice",
# "Default": "ForEachInfraction",
# "Choices": [
# {
# "Variable": "$.GatherInfractions.Infractions[0]",
# "IsPresent": False,
# "Next": "NoInfractions",
# }
# ],
# },
# "NoInfractions": {
# "Type": "Succeed",
# },
# "ForEachInfraction": {
# "Type": "Map",
# "Next": "InfractionsExist",
# "ResultPath": "$.ForEachInfraction",
# "ItemsPath": "$.GatherInfractions.Infractions",
# "Parameters": {
# "Infraction.$": "$$.Map.Item.Value",
# "JsonInput.$": "$.JsonInput",
# "OuterEvalEngineSfnExecutionId.$": "$.OuterEvalEngineSfnExecutionId",
# "ConsumerMetadata.$": "$.ConsumerMetadata",
# },
# "Iterator": {
# "StartAt": "HandleInfraction",
# "States": {
# "HandleInfraction": {
# "Type": "Task",
# "End": True,
# "ResultPath": "$.HandleInfraction",
# "Resource": "arn:aws:states:::lambda:invoke",
# "Parameters": {
# "FunctionName": self.lambda_handle_infraction.function_name,
# "Payload": {
# "Infraction.$": "$.Infraction",
# "JsonInput.$": "$.JsonInput",
# "OuterEvalEngineSfnExecutionId.$": "$.OuterEvalEngineSfnExecutionId",
# "ConsumerMetadata.$": "$.ConsumerMetadata",
# }
# },
# "ResultSelector": {"Payload.$": "$.Payload"},
# },
# },
# },
# },
# "InfractionsExist": {
# "Type": "Fail",
# },
"GatherInfractions": {
"Type": "Task",
"Next": "ChoiceInfractionsExist",
"ResultPath": "$.GatherInfractions",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
"FunctionName": self.lambda_gather_infractions.function_name,
"Payload.$": "$.EvaluateCloudFormationTemplateByOPA.Results",
},
"ResultSelector": {
"Infractions.$": "$.Payload.Infractions"
},
},
"ChoiceInfractionsExist": {
"Type": "Choice",
"Default": "ForEachInfraction",
"Choices": [
{
"Variable": "$.GatherInfractions.Infractions[0]",
"IsPresent": False,
"Next": "NoInfractions",
}
],
},
"NoInfractions": {
"Type": "Succeed",
},
"ForEachInfraction": {
"Type": "Map",
"Next": "InfractionsExist",
"ResultPath": "$.ForEachInfraction",
"ItemsPath": "$.GatherInfractions.Infractions",
"Parameters": {
"Infraction.$": "$$.Map.Item.Value",
"JsonInput.$": "$.JsonInput",
"OuterEvalEngineSfnExecutionId.$": "$.OuterEvalEngineSfnExecutionId",
"ConsumerMetadata.$": "$.ConsumerMetadata",
},
"Iterator": {
"StartAt": "HandleInfraction",
"States": {
"HandleInfraction": {
"Type": "Task",
"End": True,
"ResultPath": "$.HandleInfraction",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
"FunctionName": self.lambda_handle_infraction.function_name,
"Payload": {
"Infraction.$": "$.Infraction",
"JsonInput": {
"Bucket.$":"$.PaCEvaluationRouter.Routing.ModifiedInput.Bucket",
"Key.$":"$.PaCEvaluationRouter.Routing.ModifiedInput.Key",
},
"OuterEvalEngineSfnExecutionId.$": "$.OuterEvalEngineSfnExecutionId",
"ConsumerMetadata.$": "$.InvokedByApigw.ControlBrokerConsumerInputs.ConsumerMetadata",
}
},
"ResultSelector": {"Payload.$": "$.Payload"},
},
},
},
},
"InfractionsExist": {
"Type": "Fail",
},
},
}
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,5 @@ def lambda_handler(event, context):
print(f'opa_eval_results:\n{opa_eval_results}\n{type(opa_eval_results)}')

return {
"InputTypeCloudFormationPaCFrameworkOPAResults": opa_eval_results
"EvaluateCloudFormationTemplateByOPAResults": opa_eval_results
}

0 comments on commit 76734ef

Please sign in to comment.