IBM Cloud Docs
Updating subnets for existing application load balancers

Updating subnets for existing application load balancers

You can update subnets for an IBM Cloud® Application Load Balancer for VPC (ALB) with the UI, CLI, or API. ETag support is added for the load balancer resource, and is required for any resource that allows arrays to be updated.

Updating subnets for an application load balancer using the UI

To update subnets for an ALB by in the IBM Cloud console, perform the following procedure:

  1. From your browser, open the IBM Cloud console and log in to your account.

  2. Select the Navigation Menu Navigation Menu icon, then click Infrastructure VPC icon > Load balancers.

  3. Select the load balancer whose subnets you want to update.

  4. Select Overview, click the Edit subnets button, then select the subnets you want to attach or detach.

    • Attach: Add a new subnet to the load balancer.
    • Detach: Remove a subnet from the load balancer.

    Load balancers must have at least one subnet. As a result, the Detach will not be available if only one subnet exists.

  5. Select Save to finalize your changes.

Updating subnets for an application load balancer using the CLI

To use the CLI to update subnets for your application load balancer, follow these steps:

  1. Set up your CLI environment.

  2. Log in to your account using the CLI. After you enter the password, the system prompts which account and region that you want to use:

    ibmcloud login --sso
    
  3. Update your ALB's subnets:

    ibmcloud is load-balancer-update LOAD_BALANCER_ID --subnets SUBNET_ID_1, SUBNET_ID_2
    

    Sample output:

    E.g ibmcloud is load-balancer-update r006-a3e1f3db-0e98-47ca-9f24-6e1d06dba086 --subnets 0717-ec96c7cd-46f4-4969-9009-7613f8e9e936
    
    Attach subnet 0717-ec96c7cd-46f4-4969-9009-7613f8e9e936 to application load balancer r006-a3e1f3db-0e98-47ca-9f24-6e1d06dba086 under account IBM Cloud Network Services as user test@ibm.com...
    
    ID              0717-ec96c7cd-46f4-4969-9009-7613f8e9e936
    Name            my-subnet
    Subnet cidr     10.0.0.0/24
    Subnet crn      crn:v1:bluemix:public:is:us-south-1:a123456::subnet:0717-ec96c7cd-46f4-4969-9009-7613f8e9e936
    Zone name       us-south-2
    Created         2020-08-27T14:45:42.038-05:00
    

Updating subnets for an application load balancer using the API

The following example illustrates how to use the API to update subnets for an application load balancer.

To update subnets for an application load balancer with the API, perform the following procedure:

  1. Set up your API environment.

  2. Use the following example to attach a subnet for your application load balancer:

    Save the ID and Etag of the load balancer:

    export lbId="r006-a3e1f3db-0e98-47ca-9f24-6e1d06dba086"
    export Etag="W/cy8hmdd4op0kws5nrta40kmrmnrwodzy4qwwghyuqwq"
    
    curl -H "Authorization: $iam_token" -H "If-Match: $Etag" -X PATCH
    "$vpc_api_endpoint/v1/load_balancers/$lbId?version=$api_version&generation=2" \
       -d '{
                "subnets": [
                       {
                         "id": "0717-ec96c7cd-46f4-4969-9009-7613f8e9e936"
                      }
                ]
          }'
    

    Sample output:

    {
        "created_at": "2020-08-24T23:36:22.990359Z",
        "id": "0717-ec96c7cd-46f4-4969-9009-7613f8e9e936",
        "name": "my-subnet",
        "subnet_cidr": "10.0.0.0/24",
        "subnet_crn": "crn:v1:bluemix:public:is:eu-gb-3:a/a123456::load-balancer:r006-a3e1f3db-0e98-47ca-9f24-6e1d06dba086",
        "zone_name": "us-south-2"
    }