Skip to content

Commit

Permalink
Made the dashboard grab the instance type from the config direclty, s…
Browse files Browse the repository at this point in the history
…o it doesn't depend on a variable inside teh Container stack
  • Loading branch information
Cameronsplaze committed Oct 13, 2024
1 parent 7071148 commit 8f1bd4b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
14 changes: 8 additions & 6 deletions ContainerManager/leaf_stack/NestedStacks/Dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(
scope: Construct,
application_id: str,
container_id: str,
volume_config: dict,
main_config: dict,

domain_stack: DomainStack,
container_nested_stack: Container,
Expand All @@ -41,6 +41,8 @@ def __init__(
#######################
### Dashboard stuff ###
#######################
# Config options for specifically this stack:
dashboard_config = main_config["Dashboard"]

############
### Metrics used in the Widgets below:
Expand Down Expand Up @@ -130,7 +132,7 @@ def __init__(
cloudwatch.GraphWidget(
title="(Lambda) ASG State Change Invocations",
# Only show up to an hour ago:
start=f"-PT{volume_config["IntervalMinutes"].to_minutes()}M",
start=f"-PT{dashboard_config["IntervalMinutes"].to_minutes()}M",
height=6,
width=12,
right=[metric_asg_lambda_invocation_count],
Expand Down Expand Up @@ -175,7 +177,7 @@ def __init__(
cloudwatch.GraphWidget(
title="(ASG) All Network Traffic",
# Only show up to an hour ago:
start=f"-PT{volume_config["IntervalMinutes"].to_minutes()}M",
start=f"-PT{dashboard_config["IntervalMinutes"].to_minutes()}M",
height=6,
width=12,
left=[traffic_packets_in_metric, traffic_packets_out_metric, total_packets_metric],
Expand Down Expand Up @@ -222,9 +224,9 @@ def __init__(
## ECS Container Utilization:
# https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.GraphWidget.html
cloudwatch.GraphWidget(
title=f"(ECS) Container Utilization - {ecs_asg_nested_stack.instance_type}",
title=f"(ECS) Container Utilization - {main_config["Ec2"]["InstanceType"]}",
# Only show up to an hour ago:
start=f"-PT{volume_config["IntervalMinutes"].to_minutes()}M",
start=f"-PT{dashboard_config["IntervalMinutes"].to_minutes()}M",
height=6,
width=12,
right=[cpu_utilization_metric, memory_utilization_metric],
Expand All @@ -244,6 +246,6 @@ def __init__(
"CloudwatchDashboard",
dashboard_name=f"{application_id}-{container_id}-Dashboard",
period_override=cloudwatch.PeriodOverride.AUTO,
default_interval=volume_config["IntervalMinutes"],
default_interval=dashboard_config["IntervalMinutes"],
widgets=[dashboard_widgets],
)
5 changes: 1 addition & 4 deletions ContainerManager/leaf_stack/NestedStacks/EcsAsg.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ def __init__(
) -> None:
super().__init__(scope, "EcsAsgNestedStack", **kwargs)

## The instance type to use for the container:
self.instance_type = ec2_config["InstanceType"]

## Cluster for the the container
# This has to stay in this stack. A cluster represents a single "instance type"
# sort of. This is the only way to tie the ASG to the ECS Service, one-to-one.
Expand Down Expand Up @@ -109,7 +106,7 @@ def __init__(
self.launch_template = ec2.LaunchTemplate(
self,
"LaunchTemplate",
instance_type=ec2.InstanceType(self.instance_type),
instance_type=ec2.InstanceType(ec2_config["InstanceType"]),
## Needs to be an "EcsOptimized" image to register to the cluster
# https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.EcsOptimizedImage.html
machine_image=ecs.EcsOptimizedImage.amazon_linux2023(),
Expand Down
2 changes: 1 addition & 1 deletion ContainerManager/leaf_stack/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def __init__(
description=f"Dashboard Logic for {construct_id}",
application_id=application_id,
container_id=container_id,
volume_config=config["Dashboard"],
main_config=config,

domain_stack=domain_stack,
container_nested_stack=self.container_nested_stack,
Expand Down

0 comments on commit 8f1bd4b

Please sign in to comment.