ansible / autoscaling-blog

Companion playbooks to an article at http://www.ansible.com/blog/autoscaling-infrastructures
55 stars 46 forks source link

autoscaling group not able find and/or attach to elb #8

Open babatundebusari opened 7 years ago

babatundebusari commented 7 years ago

I am getting the following errors when trying to attach autoscaling group to elb just following same example as the one you have did you guys test this code?

the error is below

"msg": "Failed to create Autoscaling Group: BotoServerError: 400 Bad Request\n<ErrorResponse xmlns=\"http://autoscaling.amazonaws.com/doc/2011-01-01/\">\n <Error>\n <Type>Sender</Type>\n <Code>ValidationError</Code>\n <Message>Provided Load Balancers may not be valid. Please ensure they exist and try again.</Message>\n </Error>\n <RequestId>bc6fc38e-8dfe-11e7-bbae-d56fd34454</RequestId>\n</ErrorResponse>\n"

checked and the loadbalancer were created and exist and they are fine but i have no idea why the autoscaling group is not able to find them

babatundebusari commented 7 years ago

I think this is an issue with internal ELB

- name: launch visualizer load balancer
  ec2_elb_lb:
    name: "{{ vpc }}-{{ region }}-{{ env }}-a"
    scheme: internal
    state: present
    subnets: "{{ subnets | join(',') }}"
    security_group_ids: "{{ security_groups }}"
    connection_draining_timeout: 60
    cross_az_load_balancing: yes
    listeners:
      - protocol: https
        load_balancer_port: 443
        instance_port: 9999
        ssl_certificate_id: "{{ elb_acm_certificate }}"
    health_check:
        ping_protocol: http
        ping_port: 9009
        ping_path: "/status"
        response_timeout: 5
        interval: 30
        unhealthy_threshold: 2
        healthy_threshold: 10

- name: launch microservice load balancer
  ec2_elb_lb:
    name: "{{ vpc }}-{{ region }}-{{ env }}-bi"
    scheme: internal
    state: present
    subnets: "{{ subnets | join(',') }}"
    security_group_ids: "{{ security_groups }}"
    connection_draining_timeout: 60
    cross_az_load_balancing: yes
    listeners:
      - protocol: https
        load_balancer_port: 443
        instance_port: 9000
        ssl_certificate_id: "{{ elb_acm_certificate }}"
    health_check:
        ping_protocol: http
        ping_port: 9009
        ping_path: "/status"
        response_timeout: 5
        interval: 30
        unhealthy_threshold: 2
        healthy_threshold: 10
- name: create conductr-haproxy Autoscaling Group
  ec2_asg:
    name: "{{ cluster_name }}"
    availability_zones: "{{ availability_zones }}"
    load_balancers: '{{ vpc }}-{{ region }}-{{ env }}-a, {{ vpc }}-{{ region }}-{{ env }}-b'
    launch_config_name: "{{ lc_name }}"
    min_size: "{{ asg_min_size }}"
    max_size: "{{ asg_max_size }}"
    desired_capacity: "{{ asg_desired_size }}"
    vpc_zone_identifier: "{{ subnets }}"
    tags: "{{ tags }}"
    state: present

ERROR

"msg": "Failed to create Autoscaling Group: BotoServerError: 400 Bad Request\n<ErrorResponse xmlns=\"http://autoscaling.amazonaws.com/doc/2011-01-01/\">\n <Error>\n <Type>Sender</Type>\n <Code>ValidationError</Code>\n <Message>Provided Load Balancers may not be valid. Please ensure they exist and try again.</Message>\n </Error>\n <RequestId>bc6fc38e-8dfe-11e7-bbae-d56fd34454</RequestId>\n</ErrorResponse>\n"

So since am using internal ELB, is there anything else i need to do?

nsharma070980 commented 6 years ago

If you are using an ELB, try attaching the Target-Group associated with the ELB, using "target_group_arns" tag

matrinox commented 6 years ago

@nsharma070980 I thought with classic load balancers you have to use LoadBalancerNames key: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-group.html#cfn-as-group-loadbalancernames