AWS CDK v2: ALB with Targetgroup and ECS for google tagging server (gtm ss) - all traffic encrypted (HTTPS)

Viewed 19

I'm trying to create an ECS Cluster on fargate hosting a google tagging server (i.e. container) and an ALB ahead of it. The entire stack is defined in AWS CDK v2. Everything works as expected but the encryption of the traffic between the ALB and the target group.

Once I uncomment target_protocol=elbv2.ApplicationProtocol.HTTPS (see below) I can reach the application from outside, however, the traffic is not encrypted and a warning indicating the missing encryption is returned when one tries to open the health path on the browser. If I remove or comment target_protocol=elbv2.ApplicationProtocol.HTTPS, I can no longer reach the container on the browser. In both cases hits that I'm trying to send, won't reach the ss gtm.

As far as I know the container and host port need to be set to 8080 and the port of the ALB and the target group to 443 (due to https encryption).

ecs_service = ecs_patterns.ApplicationLoadBalancedFargateService(self, "gtmss-cdk-Fargate-Service",
            cluster=cluster,            # Required
            cpu=512,                    # Default is 256
            desired_count=1,            # Default is 1
            protocol=elbv2.ApplicationProtocol.HTTPS,
            listener_port=443,
            # domain_name='eprimo.de',
            # domain_zone=dns_hosted_zone,
            certificate=domain_cert,
            task_image_options=ecs_patterns.ApplicationLoadBalancedTaskImageOptions(
                    # image=ecs.ContainerImage.from_ecr_repository(repository = ecr_repo, tag = "stable"),
                    image=ecs.ContainerImage.from_registry(name='gcr.io/cloud-tagging-10302018/gtm-cloud-image:stable'),
                    container_port=8080,
                    environment=task_image_env
                    ),
            memory_limit_mib=2048,
            public_load_balancer=True,
            load_balancer_name=load_balancer_name
            , target_protocol=elbv2.ApplicationProtocol.HTTPS
        )

ecs_service.target_group.configure_health_check(path="/healthy", port="8080")

Many thanks in advance and best regards!

0 Answers
Related