Bootstrap FreeKB - Ansible - Create an Amazon Web Services (AWS) Elastic Load Balancer (ELB) Target Group
Ansible - Create an Amazon Web Services (AWS) Elastic Load Balancer (ELB) Target Group

Updated:   |  Ansible articles

An Elastic Load Balancer (ELB) is typically used to load balance requests across two (or more) different EC2 instances. 

 

If you are not familiar with modules, check out Ansible - Getting Started with Modules.

Prerequisites

elb_target_group can be used to create or delete your Amazon Web Services (AWS) Elastic Load Balancer (ELB) Target Groups.

---
- name: main play
  hosts: localhost
  tasks:
  - name: Create a Target Group listening on HTTP port 80
    community.aws.elb_target_group:
      name: mytargetgroup
      protocol: http
      port: 80
      vpc_id: vpc-014d21234335abcd
      state: present
    register: out

  - debug:
      var: out
...

 

Something like this should be returned.

ok: [localhost] => {
    "out": {
        "changed": true,
        "deregistration_delay_timeout_seconds": "300",
        "failed": false,
        "health_check_enabled": true,
        "health_check_interval_seconds": 30,
        "health_check_path": "/",
        "health_check_port": "traffic-port",
        "health_check_protocol": "HTTP",
        "health_check_timeout_seconds": 5,
        "healthy_threshold_count": 5,
        "ip_address_type": "ipv4",
        "load_balancer_arns": [],
        "load_balancing_algorithm_type": "round_robin",
        "load_balancing_cross_zone_enabled": "use_load_balancer_configuration",
        "matcher": {
            "http_code": "200"
        },
        "port": 80,
        "protocol": "HTTP",
        "protocol_version": "HTTP1",
        "slow_start_duration_seconds": "0",
        "stickiness_app_cookie_cookie_name": "",
        "stickiness_app_cookie_duration_seconds": "86400",
        "stickiness_enabled": "false",
        "stickiness_lb_cookie_duration_seconds": "86400",
        "stickiness_type": "lb_cookie",
        "tags": {},
        "target_group_arn": "arn:aws:elasticloadbalancing:us-east-1:713542074252:targetgroup/my-target-group/756218c1d7813c2a",
        "target_group_health_dns_failover_minimum_healthy_targets_count": "1",
        "target_group_health_dns_failover_minimum_healthy_targets_percentage": "off",
        "target_group_health_unhealthy_state_routing_minimum_healthy_targets_count": "1",
        "target_group_health_unhealthy_state_routing_minimum_healthy_targets_percentage": "off",
        "target_group_name": "mytargetgroup",
        "target_type": "instance",
        "unhealthy_threshold_count": 2,
        "vpc_id": "vpc-014d2fcfa335d3c01"
    }
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 4fa604 in the box below so that we can be sure you are a human.