We would like to know if we are still being billed for ALBs with no current target instance.

0

We would like to know if we are still being billed for ALBs with no current target instance.

For example, when I create an ElasticBeanstalk instance it will create a dedicated ALB, but if I terminate that ElasticBeanstalk instance, I can see that the ALB was not terminated.

Thanks!

kat
asked 3 months ago177 views
3 Answers
5

Hello,

you will incur charges for ALBs as long as they are active, even if they do not have any target instances. To avoid these charges, ensure you delete the ALB when it is no longer needed.

For additional information, you can check the AWS Elastic Load Balancing pricing page. https://aws.amazon.com/elasticloadbalancing/pricing/

profile picture
EXPERT
answered 3 months ago
profile pictureAWS
EXPERT
reviewed 3 months ago
  • thank you! Appreciate it

3
Accepted Answer

Hi kat,

Check for Unused ALBs:

AWS Management Console:

Go to the EC2 Dashboard. Click on "Load Balancers" under "Load Balancing." Look for ALBs with no instances attached.

AWS CLI:

aws elbv2 describe-load-balancers --query 'LoadBalancers[*].[LoadBalancerName, LoadBalancerArn, State.Code]'
aws elbv2 describe-target-groups --load-balancer-arn <your-load-balancer-arn> --query 'TargetGroups[*].TargetGroupArn'
aws elbv2 describe-target-health --target-group-arn <your-target-group-arn> --query 'TargetHealthDescriptions[*].Target'


Delete Unused ALBs:

AWS Management Console:

In the EC2 Dashboard, select the ALB. Click "Actions" and select "Delete."

aws elbv2 delete-load-balancer --load-balancer-arn <your-load-balancer-arn>

Automate Cleanup (Optional):

  • AWS Config Rules: Set up rules to detect and notify you about unused ALBs.
  • **Lambda Function: **Use a Lambda function to periodically check and delete unused ALBs.

Example Lambda function:

import boto3

client = boto3.client('elbv2')

def lambda_handler(event, context):
    load_balancers = client.describe_load_balancers()
    for lb in load_balancers['LoadBalancers']:
        lb_arn = lb['LoadBalancerArn']
        target_groups = client.describe_target_groups(LoadBalancerArn=lb_arn)
        for tg in target_groups['TargetGroups']:
            tg_arn = tg['TargetGroupArn']
            targets = client.describe_target_health(TargetGroupArn=tg_arn)
            if not targets['TargetHealthDescriptions']:
                print(f"Deleting ALB: {lb['LoadBalancerName']} with no targets")
                client.delete_load_balancer(LoadBalancerArn=lb_arn)
    return {'statusCode': 200, 'body': 'Checked and deleted unused ALBs'}


EXPERT
answered 3 months ago
profile picture
EXPERT
Sandeep
reviewed 3 months ago
profile picture
EXPERT
reviewed 3 months ago
EXPERT
reviewed 3 months ago
  • thank you! Appreciate it

  • Note that this post doesn't answer the question about whether billing will happen or not - that is covered in the other posts.

1

Yes, you'll be charged for ALBs for as long as they exist, regardless of whether they have listeners or if the listeners are pointing to any target groups or if the target groups contain any targets.

EXPERT
Leo K
answered 3 months ago
profile pictureAWS
EXPERT
iBehr
reviewed 3 months ago
  • thank you! Appreciate it

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions