Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Blog
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
Yandex project
© 2023 Intertech Services AG
Yandex Application Load Balancer
  • Getting started
  • Step-by-step guides
    • All guides
    • Target groups
      • Creating target group
      • Editing target group
      • Deleting target group
    • Backend groups
    • HTTP routers
    • L7 load balancers
    • Tools for Managed Service for Kubernetes
  • Tutorials
  • Concepts
  • Tools for Managed Service for Kubernetes
  • Access management
  • Pricing policy
  • API reference
  • Managed Service for Kubernetes tool references
  • Log reference
  1. Step-by-step guides
  2. Target groups
  3. Creating target group

Create a target group Application Load Balancer

Written by
Yandex Cloud

Create VMs in the working folder by following the instructions.

To create a target group:

Management console
CLI
Terraform
API
  1. In the management console, select the folder to create your target group in.
  2. In the list of services, select Application Load Balancer.
  3. On the left-hand panel, select Target groups.
  4. Click Create target group.
  5. Enter a name for the target group: test-target-group.
  6. Select the VMs.
  7. Click Create.

If you don't have the Yandex Cloud command line interface yet, install and initialize it.

The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name or --folder-id parameter.

  1. See the description of the CLI's create target group command:

    yc alb target-group create --help
    
  2. Run the command, specifying the subnet name and the internal IP addresses of the VMs in the parameters:

    yc alb target-group create <target group name> \
      --target subnet-name=<subnet name>,ip-address=<internal IP address of VM 1> \
      --target subnet-name=<subnet name>,ip-address=<internal IP address of VM 2> \
      --target subnet-name=<subnet name>,ip-address=<internal IP address of VM 3>
    

    Result:

    id: a5d751meibht4ev264pp
    name: test-target-group
    folder_id: aoerb349v3h4bupphtaf
    targets:
    - ip_address: 10.0.0.36
      subnet_id: bucp2nunecvqgobf7cve
    - ip_address: 10.1.0.8
      subnet_id: bltca464785h2eon18r9
    - ip_address: 10.2.0.12
      subnet_id: fo2tgfikh3hergif27iu
    

With Terraform, you can quickly create a cloud infrastructure in Yandex Cloud and manage it by configuration files. They store the infrastructure description in HashiCorp Configuration Language (HCL). Terraform and its providers are distributed under the Mozilla Public License.

For more information about the provider resources, see the documentation on the Terraform site or mirror site.

If you change the configuration files, Terraform automatically determines which part of your configuration is already deployed and what should be added or removed.

For more information about the Terraform, see our documentation.

  1. In the Terraform configuration file, describe the parameters of the resource to create:

    resource "yandex_alb_target_group" "foo" {
      name           = "<target group name>"
    
      target {
        subnet_id    = "<subnet ID>"
        ip_address   = "<internal IP address of VM 1>"
      }
    
      target {
        subnet_id    = "<subnet ID>"
        ip_address   = "<internal IP address of VM 2>"
      }
    
      target {
        subnet_id    = "<subnet ID>"
        ip_address   = "<internal IP address of VM 3>"
      }
    }
    

    Where:

    • yandex_alb_target_group specifies the target group parameters:
      • name: Target group name.
      • target: Target parameters:
        • subnet_id: ID of the subnet hosting the VM. You can get a list of available subnets using the CLI command: yc vpc subnet list.
        • ip_address: VM's internal IP. You can get a list of internal IP addresses using the CLI command: yc vpc subnet list-used-addresses --id <subnet ID>.

    For more information about the yandex_alb_target_group resource parameters, see the Terraform provider documentation.

  2. Create resources:

    1. In the terminal, change to the folder where you edited the configuration file.

    2. Make sure the configuration file is correct using the command:

      terraform validate
      

      If the configuration is correct, the following message is returned:

      Success! The configuration is valid.
      
    3. Run the command:

      terraform plan
      

      The terminal will display a list of resources with parameters. No changes are made at this step. If the configuration contains errors, Terraform will point them out.

    4. Apply the configuration changes:

      terraform apply
      
    5. Confirm the changes: type yes in the terminal and press Enter.

    Terraform will create all the required resources. You can check that the resources are there using the management console or the CLI command below:

    yc alb target-group list
    

Use the create REST API method for the TargetGroup resource or the TargetGroupService/Create gRPC API call.

Was the article helpful?

Language / Region
Yandex project
© 2023 Intertech Services AG