diff --git a/.~c9_invoke_uZbt5X.py b/.~c9_invoke_uZbt5X.py new file mode 100644 index 00000000..45992f42 --- /dev/null +++ b/.~c9_invoke_uZbt5X.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 +import os +from pathlib import Path +from typing import List + +import aws_cdk as cdk +from aws_cdk import aws_config, aws_stepfunctions + +from stacks.control_broker_stack import ( + ControlBrokerStack, +) +from stacks.pipeline_stack import GitHubCDKPipelineStack +from stacks.test_stack import TestStack +from stacks.client_stack import ClientStack + +STACK_VERSION = "V0x6x3" + +app = cdk.App() +continuously_deployed = app.node.try_get_context( + "control-broker/continuous-deployment/enabled" +) +deploy_stage = None +if continuously_deployed: + deploy_stage = cdk.Stage(app, "Deploy") + +env = cdk.Environment( + account=os.getenv("CDK_DEFAULT_ACCOUNT"), region=os.getenv("CDK_DEFAULT_REGION") +) + +control_broker_stack = ControlBrokerStack( + deploy_stage or app, + f"ControlBrokerEvalEngineCdkStack{STACK_VERSION}", + env=env, +) + +if app.node.try_get_context("control-broker/post-deployment-testing/enabled"): + TestStack( + deploy_stage or app, + f"ControlBrokerTestStack{STACK_VERSION}", + control_broker_outer_state_machine=control_broker_stack.outer_eval_engine_state_machine, + control_broker_roles=control_broker_stack.Input_reader_roles, + env=env + ) +if app.node.try_get_context("control-broker/client/enabled"): + ClientStack( + deploy_stage or app, + f"ControlBrokerClientStack{STACK_VERSION}", + control_broker_outer_state_machine=control_broker_stack.outer_eval_engine_state_machine, + control_broker_roles=control_broker_stack.Input_reader_roles, + control_broker_eval_results_bucket=control_broker_stack.eval_results_reports_bucket, + env=env + ) + +if continuously_deployed: + pipeline_stack = GitHubCDKPipelineStack( + app, + "ControlBrokerCICDDeployment", + env=env, + **app.node.try_get_context( + "control-broker/continuous-deployment/github-config" + ), + ) + pipeline_stack.pipeline.add_stage(deploy_stage) +app.synth() diff --git a/app.py b/app.py index 44c9811d..45992f42 100644 --- a/app.py +++ b/app.py @@ -31,11 +31,6 @@ deploy_stage or app, f"ControlBrokerEvalEngineCdkStack{STACK_VERSION}", env=env, - config_rule_enabled=app.node.try_get_context("control-broker/config-rule/enabled"), - organization_id_parameter=app.node.try_get_context("control-broker/organization-id-ssm-parameter"), - config_rule_scope=aws_config.RuleScope.from_resources( - resource_types=[aws_config.ResourceType.SQS_QUEUE] - ), ) if app.node.try_get_context("control-broker/post-deployment-testing/enabled"): diff --git a/components/config_rules.py b/components/config_rules.py deleted file mode 100644 index 61368719..00000000 --- a/components/config_rules.py +++ /dev/null @@ -1,43 +0,0 @@ -import builtins -from typing import Dict -from aws_cdk import aws_config, aws_lambda, Duration, aws_stepfunctions -from constructs import Construct -from utils import paths - -class ControlBrokerConfigRule(Construct): - """L3 construct Config rule that calls the Control Broker on resource changes.""" - - def __init__( - self, - scope: Construct, - id: builtins.str, - control_broker_statemachine: aws_stepfunctions.StateMachine, - rule_scope: aws_config.RuleScope, - lambda_function_kwargs: Dict = dict( - memory_size=512, - timeout=Duration.seconds(60), - ), - ): - super().__init__(scope, id) - self.custom_config_lambda_fn = aws_lambda.Function( - self, - f"{id}CustomLambdaFn", - code=aws_lambda.Code.from_asset(str(paths.LAMBDA_FUNCTIONS / 'custom_config')), - handler='lambda_function.lambda_handler', - runtime=aws_lambda.Runtime.PYTHON_3_9, - environment=dict( - ProcessingSfnArn=control_broker_statemachine.state_machine_arn - ), - **lambda_function_kwargs - ) - control_broker_statemachine.grant_start_execution(self.custom_config_lambda_fn) - control_broker_statemachine.grant_start_sync_execution(self.custom_config_lambda_fn) - - self.custom_config_rule = aws_config.CustomRule( - self, - f"{id}CustomConfigRule", - rule_scope=rule_scope, - lambda_function=self.custom_config_lambda_fn, - configuration_changes=True, - ) - diff --git a/stacks/control_broker_stack.py b/stacks/control_broker_stack.py index 85d4e338..67e51a81 100644 --- a/stacks/control_broker_stack.py +++ b/stacks/control_broker_stack.py @@ -29,7 +29,6 @@ def __init__( self, scope: Construct, construct_id: str, - organization_id_parameter: str, **kwargs, ) -> None: """A full Control Broker installation. @@ -52,8 +51,6 @@ def __init__( """ super().__init__(scope, construct_id, **kwargs) - self.organization_id_parameter = organization_id_parameter - self.deploy_utils() self.s3_deploy_local_assets() self.deploy_inner_sfn_lambdas() @@ -129,7 +126,7 @@ def deploy_utils(self): ], ) - # result reports + # results reports self.bucket_eval_results_reports = aws_s3.Bucket( self,