- block:

  - name: set connection information for all tasks
    set_fact:
      aws_connection_info: &aws_connection_info
        aws_access_key: "{{ aws_access_key }}"
        aws_secret_key: "{{ aws_secret_key }}"
        security_token: "{{ security_token }}"
        region: "{{ aws_region }}"
    no_log: yes

  - name: destroy NLB with listener
    elb_network_lb:
      name: "{{ nlb_name }}"
      subnets: "{{ nlb_subnets }}"
      state: absent
      listeners:
        - Protocol: TCP
          Port: 80
          DefaultActions:
            - Type: forward
              TargetGroupName: "{{ tg_name }}"
      <<: *aws_connection_info
      wait: yes
      wait_timeout: 300
    register: nlb

  - assert:
      that:
        - nlb.changed

  - name: test idempotence
    elb_network_lb:
      name: "{{ nlb_name }}"
      subnets: "{{ nlb_subnets }}"
      state: absent
      listeners:
        - Protocol: TCP
          Port: 80
          DefaultActions:
            - Type: forward
              TargetGroupName: "{{ tg_name }}"
      <<: *aws_connection_info
      wait: yes
      wait_timeout: 300
    register: nlb

  - assert:
      that:
        - not nlb.changed
