Hey @Neha, you can create NLB using boto itself. Follow these steps:
import boto3
client = boto3.client('elbv2')
client.create_load_balancer(Name='my-load-balancer', Type='network')
Provision the LB
CloudFormation Template - my-nlb-stack.yml
Resources:
NetworkLoadBalancer:
Type: "AWS::ElasticLoadBalancingV2::LoadBalancer"
Properties:
Name: my-network-lb
Type: network
Subnets:
- subnet-aabbccdd
- subnet-ddeeff11
- subnet-22334455
Outputs:
MyNLB:
Description: The ARN of the newly provisioned NLB
Value: !Ref NetworkLoadBalancer
playbook.yml
---
- hosts: all
tasks:
- name: launch ansible network lb stack with cloudformation
cloudformation:
stack_name: MyNetworkLBStack
state: present
region: eu-west-1
template: my-lb-stack.yml
register: nlbstack
- name: check the facts of the load balancer
elb_application_lb_facts:
load_balancer_arns:
- "{{ nlbstack.stack_outputs.MyNLB }}"