{"id":9516,"library":"aws-cdk-aws-elasticloadbalancing","title":"AWS CDK Elastic Load Balancing (V1)","description":"This library provides AWS CDK V1 constructs for provisioning and managing AWS Classic Load Balancers (ELBv1). As part of the AWS CDK v1 ecosystem, it is currently in maintenance mode. The latest version is 1.204.0, with releases typically tied to the overall CDK v1 release cycle.","status":"maintenance","version":"1.204.0","language":"en","source_language":"en","source_url":"https://github.com/aws/aws-cdk.git","tags":["aws-cdk","load-balancer","elb","cloudformation","cdk-v1"],"install":[{"cmd":"pip install aws-cdk.aws-elasticloadbalancing aws-cdk.core aws-cdk.aws-ec2 constructs","lang":"bash","label":"Install core CDK v1, ELB, EC2 and Constructs libraries"}],"dependencies":[{"reason":"Required for all CDK applications, providing core constructs like App and Stack.","package":"aws-cdk.core","optional":false},{"reason":"Needed for provisioning network resources like VPCs and subnets, essential for Classic Load Balancer deployment.","package":"aws-cdk.aws-ec2","optional":false},{"reason":"The low-level building blocks for CDK applications, foundational for all CDK constructs.","package":"constructs","optional":false}],"imports":[{"note":"This library is for Classic Load Balancers (ELBv1). For Application or Network Load Balancers, use `aws_cdk.aws_elasticloadbalancingv2`.","wrong":"from aws_cdk.aws_elasticloadbalancingv2 import ApplicationLoadBalancer","symbol":"CfnLoadBalancer","correct":"from aws_cdk import aws_elasticloadbalancing as elb"}],"quickstart":{"code":"import os\nfrom aws_cdk import (\n    App, Stack, Environment,\n    aws_ec2 as ec2,\n    aws_elasticloadbalancing as elb,\n    CfnOutput\n)\nfrom constructs import Construct\n\nclass ElbV1Stack(Stack):\n    def __init__(self, scope: Construct, id: str, **kwargs) -> None:\n        super().__init__(scope, id, **kwargs)\n\n        # Create a VPC\n        vpc = ec2.Vpc(self, \"MyVpc\",\n            max_azs=2,\n            cidr=\"10.10.0.0/16\",\n            subnet_configuration=[\n                ec2.SubnetConfiguration(\n                    name=\"Public\",\n                    subnet_type=ec2.SubnetType.PUBLIC,\n                    cidr_mask=24\n                ),\n                ec2.SubnetConfiguration(\n                    name=\"Private\",\n                    subnet_type=ec2.SubnetType.PRIVATE_ISOLATED,\n                    cidr_mask=24\n                )\n            ]\n        )\n\n        # Select public subnets for the Classic Load Balancer\n        public_subnets = vpc.select_subnets(subnet_type=ec2.SubnetType.PUBLIC)\n\n        # Create a Classic Load Balancer\n        clb = elb.CfnLoadBalancer(self, \"MyClassicLoadBalancer\",\n            listeners=[\n                elb.CfnLoadBalancer.ListenersProperty(\n                    instance_port=\"80\",\n                    instance_protocol=\"HTTP\",\n                    load_balancer_port=\"80\",\n                    protocol=\"HTTP\"\n                )\n            ],\n            scheme=\"internet-facing\",\n            subnets=[s.subnet_id for s in public_subnets.subnets]\n            # For production, consider adding security_groups and health_check.\n            # The CLB will create a default security group if none is provided.\n        )\n\n        CfnOutput(self, \"LoadBalancerDNS\", value=clb.get_att(\"DNSName\").to_string())\n\napp = App()\nElbV1Stack(app, \"ElbV1ExampleStack\",\n    env=Environment(\n        account=os.environ.get(\"CDK_DEFAULT_ACCOUNT\"),\n        region=os.environ.get(\"CDK_DEFAULT_REGION\")\n    )\n)\napp.synth()","lang":"python","description":"This quickstart deploys a basic AWS Classic Load Balancer (ELBv1) within a new VPC using CDK v1. It creates an internet-facing load balancer with an HTTP listener on port 80, routing traffic to instances (not shown) on port 80. Ensure `CDK_DEFAULT_ACCOUNT` and `CDK_DEFAULT_REGION` environment variables are set."},"warnings":[{"fix":"Migrate your CDK application to v2 and use the equivalent `aws-cdk.aws-elasticloadbalancingv2` or `aws-cdk.aws-ec2` constructs where applicable, following the official AWS CDK migration guide.","message":"AWS CDK v1 to v2 migration involves significant breaking changes across the entire CDK ecosystem. This `aws-cdk.aws-elasticloadbalancing` library is specific to CDK v1 and is not compatible with CDK v2 without a full migration of your CDK application.","severity":"breaking","affected_versions":"All v1.x versions when migrating to v2.x"},{"fix":"For ALB or NLB, ensure you install and import from `aws-cdk.aws-elasticloadbalancingv2`. For Classic Load Balancers, continue using this library.","message":"This library specifically manages *Classic Load Balancers (ELBv1)*. Do not confuse it with Application Load Balancers (ALB) or Network Load Balancers (NLB), which are managed by the `aws-cdk.aws-elasticloadbalancingv2` library.","severity":"gotcha","affected_versions":"All v1.x versions"},{"fix":"Consider using `aws-cdk.aws-elasticloadbalancingv2` for new load balancer deployments, leveraging Application or Network Load Balancers for improved features and performance.","message":"AWS Classic Load Balancers themselves are considered a legacy service by AWS, with Application and Network Load Balancers being the recommended modern alternatives. New deployments should generally prefer ELBv2 constructs.","severity":"deprecated","affected_versions":"All v1.x versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install the correct CDK v2 library: `pip install aws-cdk.aws-elasticloadbalancingv2` or ensure you are using CDK v2.","cause":"Attempting to import v2 load balancer constructs (like ALB/NLB) after installing only the v1 Classic Load Balancer library.","error":"ModuleNotFoundError: No module named 'aws_cdk.aws_elasticloadbalancingv2'"},{"fix":"The `ApplicationLoadBalancer` construct is part of `aws_cdk.aws_elasticloadbalancingv2`. Import it from there: `from aws_cdk import aws_elasticloadbalancingv2 as elbv2`.","cause":"Trying to instantiate an Application Load Balancer using the v1 Classic Load Balancer library.","error":"AttributeError: module 'aws_cdk.aws_elasticloadbalancing' has no attribute 'ApplicationLoadBalancer'"},{"fix":"Ensure all CDK constructs are instantiated with `(self, \"LogicalId\", ...)` within a class extending `Construct` or `Stack`.","cause":"A CDK construct was instantiated without its required `scope` argument, which is typically the parent construct (e.g., `self` within a Stack).","error":"TypeError: __init__() missing 1 required positional argument: 'scope'"}]}