From 56e127886e368b4309d0a84fe45ce4f845dde988 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Wed, 4 Dec 2024 11:10:49 -0800 Subject: [PATCH] removed duplicate container defintion from neuron.yaml --- neuron-problem-detector/ecs-npd-cdk/.gitignore | 1 + neuron-problem-detector/ecs-npd-cdk/README.md | 17 ++++++++++++++++- neuron-problem-detector/ecs-npd-cdk/neuron.yaml | 3 --- .../ecs_task_definition.json | 15 ++------------- .../neuron_problem_detector_stack.py | 4 ++-- .../ecs-npd-cdk/requirements.txt | 2 +- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/neuron-problem-detector/ecs-npd-cdk/.gitignore b/neuron-problem-detector/ecs-npd-cdk/.gitignore index c18dd8d..7039d49 100644 --- a/neuron-problem-detector/ecs-npd-cdk/.gitignore +++ b/neuron-problem-detector/ecs-npd-cdk/.gitignore @@ -1 +1,2 @@ __pycache__/ +cdk.out/ diff --git a/neuron-problem-detector/ecs-npd-cdk/README.md b/neuron-problem-detector/ecs-npd-cdk/README.md index d13019e..3d9ca66 100644 --- a/neuron-problem-detector/ecs-npd-cdk/README.md +++ b/neuron-problem-detector/ecs-npd-cdk/README.md @@ -52,12 +52,12 @@ $ pip install -r requirements.txt ``` ## Synthesize CloudFormation template +It is assumed that you have authenticated successfully to connect to your AWS environment. At this point you can now synthesize the CloudFormation template for this code. ``` $ cdk synth ``` -It is assumed that you have authenticated successfully to connect to your AWS environment. Perform bootstrap function with the following command. ``` @@ -69,6 +69,21 @@ Deploy the stack in your AWS environment cdk deploy [--profile ] ``` +## Cleanup Instructions + +Destroy the stack in your AWS environment + +``` +cdk destroy [--profile ] +``` + +Delete the following log groups in cloudwatch + +``` +/ecs/recovery +/ecs/npd +``` + ## Optional To add additional dependencies, for example other CDK libraries, just add them to your `setup.py` file and rerun the `pip install -r requirements.txt` diff --git a/neuron-problem-detector/ecs-npd-cdk/neuron.yaml b/neuron-problem-detector/ecs-npd-cdk/neuron.yaml index 29b92a6..75fd7c0 100644 --- a/neuron-problem-detector/ecs-npd-cdk/neuron.yaml +++ b/neuron-problem-detector/ecs-npd-cdk/neuron.yaml @@ -875,7 +875,6 @@ Resources: - Ref: NeuronProblemDetectorTaskRole673752FB Metadata: aws:cdk:path: NeuronProblemDetectorStack/NeuronProblemDetectorTaskRole/DefaultPolicy/Resource - NeuronNpdAndRecoveryTaskDef7591F251: Type: AWS::ECS::TaskDefinition Properties: ContainerDefinitions: @@ -986,8 +985,6 @@ Resources: - Ref: NeuronProblemDetectorVPCPrivateSubnet1Subnet708A0901 - Ref: NeuronProblemDetectorVPCPrivateSubnet2Subnet3B7C3437 SchedulingStrategy: DAEMON - TaskDefinition: - Ref: NeuronNpdAndRecoveryTaskDef7591F251 DependsOn: - NeuronProblemDetectorTaskRoleDefaultPolicyCFCDEF04 - NeuronProblemDetectorTaskRole673752FB diff --git a/neuron-problem-detector/ecs-npd-cdk/neuron_problem_detector/ecs_task_definition.json b/neuron-problem-detector/ecs-npd-cdk/neuron_problem_detector/ecs_task_definition.json index c6175da..a6a52cc 100644 --- a/neuron-problem-detector/ecs-npd-cdk/neuron_problem_detector/ecs_task_definition.json +++ b/neuron-problem-detector/ecs-npd-cdk/neuron_problem_detector/ecs_task_definition.json @@ -9,9 +9,7 @@ { "name": "npd-80-tcp", "containerPort": 80, - "hostPort": 80, - "protocol": "tcp", - "appProtocol": "http" + "hostPort": 80 } ], "essential": true, @@ -43,7 +41,6 @@ "options": { "awslogs-group": "/ecs/npd", "awslogs-create-group": "true", - "awslogs-region": "us-west-2", "awslogs-stream-prefix": "ecs" }, "secretOptions": [] @@ -77,20 +74,12 @@ "options": { "awslogs-create-group": "true", "awslogs-group": "/ecs/recovery", - "awslogs-region": "us-west-2", "awslogs-stream-prefix": "ecs" } }, "systemControls": [] } ], - "requiresCompatibilities": [ - "EC2" - ], "cpu": "1024", - "memory": "3072", - "runtimePlatform": { - "cpuArchitecture": "X86_64", - "operatingSystemFamily": "LINUX" - } + "memory": "3072" } diff --git a/neuron-problem-detector/ecs-npd-cdk/neuron_problem_detector/neuron_problem_detector_stack.py b/neuron-problem-detector/ecs-npd-cdk/neuron_problem_detector/neuron_problem_detector_stack.py index 1b3bd77..09a1995 100644 --- a/neuron-problem-detector/ecs-npd-cdk/neuron_problem_detector/neuron_problem_detector_stack.py +++ b/neuron-problem-detector/ecs-npd-cdk/neuron_problem_detector/neuron_problem_detector_stack.py @@ -17,7 +17,7 @@ class NeuronProblemDetectorStack(Stack): def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: super().__init__(scope, construct_id, **kwargs) - with open('ecs_task_definition.json', 'r') as f: + with open('neuron_problem_detector/ecs_task_definition.json', 'r') as f: ecs_task_definition = json.load(f) vpc = ec2.Vpc(self, "NeuronProblemDetectorVPC", max_azs=2) @@ -121,7 +121,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: image=ecs.ContainerImage.from_registry( ecs_task_definition["containerDefinitions"][0]["image"] ), - entry_point=ecs_task_definition["containerDefinitions"][0]["entrypoint"], + entry_point=ecs_task_definition["containerDefinitions"][0]["entryPoint"], command=ecs_task_definition["containerDefinitions"][0]["command"], privileged=True, logging=ecs.AwsLogDriver( diff --git a/neuron-problem-detector/ecs-npd-cdk/requirements.txt b/neuron-problem-detector/ecs-npd-cdk/requirements.txt index d5307a6..54af265 100644 --- a/neuron-problem-detector/ecs-npd-cdk/requirements.txt +++ b/neuron-problem-detector/ecs-npd-cdk/requirements.txt @@ -1,2 +1,2 @@ -aws-cdk-lib==2.152.0 +aws-cdk-lib>=2.152.0 constructs>=10.0.0,<11.0.0