From 682e39fa322641588d0fcd372222655b7d92ae87 Mon Sep 17 00:00:00 2001 From: Clark Schneider Date: Tue, 3 May 2022 21:17:40 +0000 Subject: [PATCH] add . --- stacks/control_broker_stack.py | 41 ++++++++++--------- .../pac_evaluation_router/lambda_function.py | 17 ++++---- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/stacks/control_broker_stack.py b/stacks/control_broker_stack.py index bcffa06e..ec354f72 100644 --- a/stacks/control_broker_stack.py +++ b/stacks/control_broker_stack.py @@ -436,7 +436,7 @@ def deploy_inner_sfn(self): "Default": "NoValidRoute", "Choices": [ { - "Variable": "$.PaCEvaluationRouter.Routing", + "Variable": "$.PaCEvaluationRouter.Routing.InvokingSfnNextState", "StringEquals": "EvaluateCloudFormationTemplateByOPA", "Next": "EvaluateCloudFormationTemplateByOPA", } @@ -446,26 +446,27 @@ def deploy_inner_sfn(self): "Type": "Fail", }, "EvaluateCloudFormationTemplateByOPA": { - "Type": "Succeed", + "Type": "Task", + # "Next": "GatherInfractions", + "End": True, + "ResultPath": "$.EvaluateCloudFormationTemplateByOPA", + "Resource": "arn:aws:states:::lambda:invoke", + "Parameters": { + "FunctionName": self.lambda_evaluate_cloudformation_by_opa.function_name, + "Payload": { + "JsonInput": { + "Bucket.$":"$.PaCEvaluationRouter.Routing.ModifiedInput.Bucket", + "Key.$":"$.PaCEvaluationRouter.Routing.ModifiedInput.Key", + }, + "OpaPolicies": { + "Bucket.$": "$.PaCEvaluationRouter.Routing.PaC.Bucket" + }, + }, + }, + "ResultSelector": { + "Results.$": "$.Payload.EvaluateCloudFormationTemplateByOPAResults" + }, }, - # "EvaluateCloudFormationTemplateByOPA": { - # "Type": "Task", - # "Next": "GatherInfractions", - # "ResultPath": "$.EvaluateCloudFormationTemplateByOPA", - # "Resource": "arn:aws:states:::lambda:invoke", - # "Parameters": { - # "FunctionName": self.lambda_evaluate_cloudformation_by_opa.function_name, - # "Payload": { - # "JsonInput.$": "$.JsonInput", - # "OpaPolicies": { - # "Bucket": self.bucket_opa_policies.bucket_name - # }, - # }, - # }, - # "ResultSelector": { - # "Results.$": "$.Payload.EvaluateCloudFormationTemplateByOPAResults" - # }, - # }, # "GatherInfractions": { # "Type": "Task", # "Next": "ChoiceInfractionsExist", diff --git a/supplementary_files/lambdas/pac_evaluation_router/lambda_function.py b/supplementary_files/lambdas/pac_evaluation_router/lambda_function.py index 4673219f..059f6058 100644 --- a/supplementary_files/lambdas/pac_evaluation_router/lambda_function.py +++ b/supplementary_files/lambdas/pac_evaluation_router/lambda_function.py @@ -157,9 +157,14 @@ def get_converted_cloudformation(self): def put_converted_cloudformation(self): + self.converted_s3_path = { + 'Bucket' : os.environ['ConvertedInputsBucket'], + 'Key' : self.config_event_s3_path['Key'], + } + put_object( - bucket = os.environ['ConvertedInputsBucket'], - key = self.config_event_s3_path['Key'], + bucket = self.converted_s3_path['Bucket'], + key = self.converted_s3_path['Key'], object_ = self.cfn ) @@ -167,13 +172,9 @@ def get_converted_s3_path(self): self.parse_config_event() self.get_converted_cloudformation() + self.put_converted_cloudformation() - - - return { - "Bucket":"CONVERTED-BUCKET", - "Key":"CONVERTED-KEY", - } + return self.converted_s3_path class PacEvaluationRouter(): def __init__(