in ec2_ialb_aga_custom_r53/aga_stack.py [0:0]
def __init__(self, scope: core.Construct, construct_id: str, vpc, alb, hosted_zone, subdomain, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
# Create the Accelerator and add two listeners on ports 80 and 443 for http/https respectivley
# The ALB already has a redirect in place to redirect to https.
self.accelerator = ga.Accelerator(self, "Accelerator")
ga_listener = ga.Listener(
self, "Listener",
accelerator=self.accelerator,
port_ranges=[
ga.PortRange(
from_port=443, to_port=443),
ga.PortRange(
from_port=80, to_port=80)]
)
endpoint_group = ga.EndpointGroup(
self, "MainGroup", listener=ga_listener)
endpoint_group.add_endpoint(
ga_eps.ApplicationLoadBalancerEndpoint(alb))
# Add in a CNAME Record to our new LB based on the subdomain we created before.
route53.CnameRecord(self, "AGA Subdomain", domain_name=self.accelerator.dns_name,
zone=hosted_zone, record_name=f"{subdomain}.{hosted_zone.zone_name}")
core.CfnOutput(self, "Output",
value=self.accelerator.accelerator_arn)