<p>Please follow official doc to <a href="https://docs.saltstack.com/en/2017.7/ref/states/all/salt.states.boto_elb.html" rel="nofollow noreferrer">create LB</a> </p>

<p>Please create a IAM role or mentioned secret and access key as below </p>

<pre><code>elb.keyid: HHTYHLSHDJFJFJFJFJFJFFSVJS
elb.key: basjbsdfbdsfdsjfbkgbsfbdsjfbfdgdfgdfs
</code></pre>

<p>Then Create config for ELB </p>

<pre><code>Ensure myelb ELB exists:
    boto_elb.present:
        - name: myelb
        - region: us-east-1
        - availability_zones:
            - us-east-1a
            - us-east-1c
            - us-east-1d
        - keyid: GKTADJGHEIQSXMKKRBJ08H
        - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
        - listeners:
            - elb_port: 443
              instance_port: 80
              elb_protocol: HTTPS
              instance_protocol: HTTP
              certificate: 'arn:aws:iam::1111111:server-certificate/mycert'
              policies:
                  - my-ssl-policy
                  - cookie-policy
            - elb_port: 8210
              instance_port: 8210
              elb_protocol: TCP
        - backends:
            - instance_port: 80
              policies:
                  - enable-proxy-protocol
        - health_check:
            target: 'HTTP:80/'
        - attributes:
            cross_zone_load_balancing:
              enabled: true
            access_log:
              enabled: true
              s3_bucket_name: 'mybucket'
              s3_bucket_prefix: 'my-logs'
              emit_interval: 5
            connecting_settings:
              idle_timeout: 60
        - cnames:
            - name: mycname.example.com.
              zone: example.com.
              ttl: 60
            - name: myothercname.example.com.
              zone: example.com.
        - security_groups:
            - my-security-group
        - policies:
            - policy_name: my-ssl-policy
              policy_type: SSLNegotiationPolicyType
              policy:
                Protocol-TLSv1.2: true
                Protocol-SSLv3: false
                Server-Defined-Cipher-Order: true
                ECDHE-ECDSA-AES128-GCM-SHA256: true
            - policy_name: cookie-policy
              policy_type: LBCookieStickinessPolicyType
              policy: {}  # no policy means this is a session cookie
            - policy_name: enable-proxy-protocol
              policy_type: ProxyProtocolPolicyType
              policy:
                ProxyProtocol: true

# Using a profile from pillars
Ensure myelb ELB exists:
    boto_elb.present:
        - name: myelb
        - region: us-east-1
        - profile: myelbprofile

# Passing in a profile
Ensure myelb ELB exists:
    boto_elb.present:
        - name: myelb
        - region: us-east-1
        - profile:
            keyid: GKTADJGHEIQSXMKKRBJ08H
            key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
</code></pre>

<p>Register instance with ELB. 
<strong>salt.states.boto_elb.register_instances(name, instances, region=None, key=None, keyid=None, profile=None)</strong></p>

<pre><code>add-instances:
  boto_elb.register_instances:
    - name: myloadbalancer
    - instances:
      - instance-id1
      - instance-id2
</code></pre>

<p>You may find <a href="https://www.opcito.com/improve-your-load-balancer-performance-with-saltstack-and-nginx-2/" rel="nofollow noreferrer">this blog post</a> useful also.</p>

CC BY-SA 4.0
2018-07-16T13:56:25.870Z
Thank you. This will create a classic load balancer which I already implemented. I am looking for  creation of the application load balancer and Network load balancer .
user1340004
CC BY-SA 4.0
2018-07-16T08:44:19.543Z
2018-07-16T09:27:27.527Z
2018-07-16T09:27:27.527Z
sanjayparmar
<p>I was trying to create application load balancer with salt stack. I am using salt boto_elbv2 which is having option to create target groups but dont have option to create load balancer, how can i achieve it ?</p>

<amazon-web-services><salt>
How to create AWS application load balancer using saltstack
user1340004
# How to create AWS application load balancer using saltstack

(Asked by: username_0 on 2018-07-15)

I was trying to create application load balancer with salt stack. I am using salt boto\_elbv2 which is having option to create target groups but dont have option to create load balancer, how can i achieve it ?

**Tags:** amazon-web-services, salt


---

## 1 answers

### Answer by username_1 on 2018-07-16. Score: 1

Please follow official doc to create LB 
Please create a IAM role or mentioned secret and access key as below 
elb.keyid: HHTYHLSHDJFJFJFJFJFJFFSVJS
elb.key: basjbsdfbdsfdsjfbkgbsfbdsjfbfdgdfgdfs

Then Create config for ELB 
Ensure myelb ELB exists:
    boto_elb.present:
        - name: myelb
        - region: us-east-1
        - availability_zones:
            - us-east-1a
            - us-east-1c
            - us-east-1d
        - keyid: GKTADJGHEIQSXMKKRBJ08H
        - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
        - listeners:
            - elb_port: 443
              instance_port: 80
              elb_protocol: HTTPS
              instance_protocol: HTTP
              certificate: 'arn:aws:iam::1111111:server-certificate/mycert'
              policies:
                  - my-ssl-policy
                  - cookie-policy
            - elb_port: 8210
              instance_port: 8210
              elb_protocol: TCP
        - backends:
            - instance_port: 80
              policies:
                  - enable-proxy-protocol
        - health_check:
            target: 'HTTP:80/'
        - attributes:
            cross_zone_load_balancing:
              enabled: true
            access_log:
              enabled: true
              s3_bucket_name: 'mybucket'
              s3_bucket_prefix: 'my-logs'
              emit_interval: 5
            connecting_settings:
              idle_timeout: 60
        - cnames:
            - name: mycname.example.com.
              zone: example.com.
              ttl: 60
            - name: myothercname.example.com.
              zone: example.com.
        - security_groups:
            - my-security-group
        - policies:
            - policy_name: my-ssl-policy
              policy_type: SSLNegotiationPolicyType
              policy:
                Protocol-TLSv1.2: true
                Protocol-SSLv3: false
                Server-Defined-Cipher-Order: true
                ECDHE-ECDSA-AES128-GCM-SHA256: true
            - policy_name: cookie-policy
              policy_type: LBCookieStickinessPolicyType
              policy: {}  # no policy means this is a session cookie
            - policy_name: enable-proxy-protocol
              policy_type: ProxyProtocolPolicyType
              policy:
                ProxyProtocol: true

# Using a profile from pillars
Ensure myelb ELB exists:
    boto_elb.present:
        - name: myelb
        - region: us-east-1
        - profile: myelbprofile

# Passing in a profile
Ensure myelb ELB exists:
    boto_elb.present:
        - name: myelb
        - region: us-east-1
        - profile:
            keyid: GKTADJGHEIQSXMKKRBJ08H
            key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

Register instance with ELB. 
salt.states.boto_elb.register_instances(name, instances, region=None, key=None, keyid=None, profile=None)
add-instances:
  boto_elb.register_instances:
    - name: myloadbalancer
    - instances:
      - instance-id1
      - instance-id2

You may find this blog post useful also.

> **Comments:**
> **username_0**: Thank you. This will create a classic load balancer which I already implemented. I am looking for  creation of the application load balancer and Network load balancer .  

---

