Skip to content

Commit

Permalink
FOrce redeploy ALB
Browse files Browse the repository at this point in the history
  • Loading branch information
amarouane-ABDELHAK committed May 31, 2024
1 parent e483536 commit c6a1930
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions stacks/grafana.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Optional, Sequence, List, Union
from typing import Dict, Optional, Sequence, Union

from constructs import Construct
from aws_cdk import (
Expand Down Expand Up @@ -54,7 +54,8 @@ def __init__(
service = self.build_service(
vpc=vpc,
container_name=container_name,
cluster_name=settings.grafana_stack_name
cluster_name=settings.grafana_stack_name,
stage=settings.stage
)

container = service.task_definition.find_container(container_name)
Expand Down Expand Up @@ -106,15 +107,16 @@ def build_service(
self,
vpc: ec2.Vpc,
cluster_name: str,
container_name: str
container_name: str,
stage: str = "dev"
):
# Production has a public NAT Gateway subnet, which causes the
# default load balancer creation to fail with too many subnets
# being selected per AZ. We create our own load balancer to
# allow us to select subnets and avoid the issue.
load_balancer: elbv2.ApplicationLoadBalancer = elbv2.ApplicationLoadBalancer(
self,
"load-balancer",
f"{stage}-load-balancer",
vpc=vpc,
internet_facing=True,
vpc_subnets=ec2.SubnetSelection(
Expand All @@ -127,7 +129,7 @@ def build_service(
"Service",
cluster=ecs.Cluster(
self,
"cluster",
f"{stage}-cluster",
cluster_name=cluster_name,
vpc=vpc,
),
Expand All @@ -136,7 +138,7 @@ def build_service(
one_per_az=True,
subnet_type=ec2.SubnetType.PRIVATE_ISOLATED,
),
service_name="grafana",
service_name=f"{stage}-grafana",
desired_count=1,
task_image_options=ecs_patterns.ApplicationLoadBalancedTaskImageOptions(
image=ecs.ContainerImage.from_asset("grafana"),
Expand Down

0 comments on commit c6a1930

Please sign in to comment.