Class ServerGroup


  • public class ServerGroup
    extends com.pulumi.resources.CustomResource
    Provides a ALB Server Group resource. For information about ALB Server Group and how to use it, see [What is Server Group](https://www.alibabacloud.com/help/en/slb/application-load-balancer/developer-reference/api-alb-2020-06-16-createservergroup). > **NOTE:** Available since v1.131.0. ## Example Usage Basic Usage ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.alicloud.AlicloudFunctions; import com.pulumi.alicloud.inputs.GetZonesArgs; import com.pulumi.alicloud.ecs.EcsFunctions; import com.pulumi.alicloud.ecs.inputs.GetInstanceTypesArgs; import com.pulumi.alicloud.ecs.inputs.GetImagesArgs; import com.pulumi.alicloud.resourcemanager.ResourcemanagerFunctions; import com.pulumi.alicloud.resourcemanager.inputs.GetResourceGroupsArgs; import com.pulumi.alicloud.vpc.Network; import com.pulumi.alicloud.vpc.NetworkArgs; import com.pulumi.alicloud.vpc.Switch; import com.pulumi.alicloud.vpc.SwitchArgs; import com.pulumi.alicloud.ecs.SecurityGroup; import com.pulumi.alicloud.ecs.SecurityGroupArgs; import com.pulumi.alicloud.ecs.Instance; import com.pulumi.alicloud.ecs.InstanceArgs; import com.pulumi.alicloud.alb.ServerGroup; import com.pulumi.alicloud.alb.ServerGroupArgs; import com.pulumi.alicloud.alb.inputs.ServerGroupHealthCheckConfigArgs; import com.pulumi.alicloud.alb.inputs.ServerGroupStickySessionConfigArgs; import com.pulumi.alicloud.alb.inputs.ServerGroupServerArgs; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { final var config = ctx.config(); final var name = config.get("name").orElse("terraform-example"); final var exampleZones = AlicloudFunctions.getZones(GetZonesArgs.builder() .availableResourceCreation("Instance") .build()); final var exampleInstanceTypes = EcsFunctions.getInstanceTypes(GetInstanceTypesArgs.builder() .availabilityZone(exampleZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id())) .cpuCoreCount(1) .memorySize(2) .build()); final var exampleImages = EcsFunctions.getImages(GetImagesArgs.builder() .nameRegex("^ubuntu_[0-9]+_[0-9]+_x64*") .owners("system") .build()); final var exampleResourceGroups = ResourcemanagerFunctions.getResourceGroups(); var exampleNetwork = new Network("exampleNetwork", NetworkArgs.builder() .vpcName(name) .cidrBlock("10.4.0.0/16") .build()); var exampleSwitch = new Switch("exampleSwitch", SwitchArgs.builder() .vswitchName(name) .cidrBlock("10.4.0.0/16") .vpcId(exampleNetwork.id()) .zoneId(exampleZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id())) .build()); var exampleSecurityGroup = new SecurityGroup("exampleSecurityGroup", SecurityGroupArgs.builder() .description(name) .vpcId(exampleNetwork.id()) .build()); var exampleInstance = new Instance("exampleInstance", InstanceArgs.builder() .availabilityZone(exampleZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id())) .instanceName(name) .imageId(exampleImages.applyValue(getImagesResult -> getImagesResult.images()[0].id())) .instanceType(exampleInstanceTypes.applyValue(getInstanceTypesResult -> getInstanceTypesResult.instanceTypes()[0].id())) .securityGroups(exampleSecurityGroup.id()) .vswitchId(exampleSwitch.id()) .build()); var exampleServerGroup = new ServerGroup("exampleServerGroup", ServerGroupArgs.builder() .protocol("HTTP") .vpcId(exampleNetwork.id()) .serverGroupName(name) .resourceGroupId(exampleResourceGroups.applyValue(getResourceGroupsResult -> getResourceGroupsResult.groups()[0].id())) .healthCheckConfig(ServerGroupHealthCheckConfigArgs.builder() .healthCheckConnectPort("46325") .healthCheckEnabled(true) .healthCheckHost("tf-example.com") .healthCheckCodes( "http_2xx", "http_3xx", "http_4xx") .healthCheckHttpVersion("HTTP1.1") .healthCheckInterval("2") .healthCheckMethod("HEAD") .healthCheckPath("/tf-example") .healthCheckProtocol("HTTP") .healthCheckTimeout(5) .healthyThreshold(3) .unhealthyThreshold(3) .build()) .stickySessionConfig(ServerGroupStickySessionConfigArgs.builder() .stickySessionEnabled(true) .cookie("tf-example") .stickySessionType("Server") .build()) .tags(Map.of("Created", "TF")) .servers(ServerGroupServerArgs.builder() .description(name) .port(80) .serverId(exampleInstance.id()) .serverIp(exampleInstance.privateIp()) .serverType("Ecs") .weight(10) .build()) .build()); } } ``` ## Import ALB Server Group can be imported using the id, e.g. ```sh $ pulumi import alicloud:alb/serverGroup:ServerGroup example <id> ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> dryRun()  
      static ServerGroup get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, ServerGroupState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.util.Optional<ServerGroupHealthCheckConfig>> healthCheckConfig()  
      com.pulumi.core.Output<java.lang.String> protocol()  
      com.pulumi.core.Output<java.lang.String> resourceGroupId()  
      com.pulumi.core.Output<java.lang.String> scheduler()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> serverGroupName()  
      com.pulumi.core.Output<java.lang.String> serverGroupType()  
      com.pulumi.core.Output<java.util.Optional<java.util.List<ServerGroupServer>>> servers()  
      com.pulumi.core.Output<java.lang.String> status()  
      com.pulumi.core.Output<java.util.Optional<ServerGroupStickySessionConfig>> stickySessionConfig()  
      com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.Object>>> tags()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> vpcId()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ServerGroup

        public ServerGroup​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • ServerGroup

        public ServerGroup​(java.lang.String name,
                           @Nullable
                           ServerGroupArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • ServerGroup

        public ServerGroup​(java.lang.String name,
                           @Nullable
                           ServerGroupArgs args,
                           @Nullable
                           com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • dryRun

        public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> dryRun()
        Returns:
        The dry run.
      • healthCheckConfig

        public com.pulumi.core.Output<java.util.Optional<ServerGroupHealthCheckConfig>> healthCheckConfig()
        Returns:
        The configuration of health checks. See `health_check_config` below for details.
      • protocol

        public com.pulumi.core.Output<java.lang.String> protocol()
        Returns:
        The server protocol. Valid values: ` HTTPS `, `HTTP`.
      • resourceGroupId

        public com.pulumi.core.Output<java.lang.String> resourceGroupId()
        Returns:
        The ID of the resource group.
      • scheduler

        public com.pulumi.core.Output<java.lang.String> scheduler()
        Returns:
        The scheduling algorithm. Valid values: ` Sch `, ` Wlc `, `Wrr`.
      • serverGroupName

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> serverGroupName()
        Returns:
        The name of the resource.
      • serverGroupType

        public com.pulumi.core.Output<java.lang.String> serverGroupType()
        Returns:
        The type of the server group. Valid values:
      • servers

        public com.pulumi.core.Output<java.util.Optional<java.util.List<ServerGroupServer>>> servers()
        Returns:
        The backend server. See `servers` below for details.
      • status

        public com.pulumi.core.Output<java.lang.String> status()
        Returns:
        The status of the backend server. Valid values:
      • stickySessionConfig

        public com.pulumi.core.Output<java.util.Optional<ServerGroupStickySessionConfig>> stickySessionConfig()
        Returns:
        The configuration of the sticky session. See `sticky_session_config` below for details.
      • tags

        public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.Object>>> tags()
        Returns:
        A mapping of tags to assign to the resource.
      • vpcId

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> vpcId()
        Returns:
        The ID of the VPC that you want to access.
      • get

        public static ServerGroup get​(java.lang.String name,
                                      com.pulumi.core.Output<java.lang.String> id,
                                      @Nullable
                                      ServerGroupState state,
                                      @Nullable
                                      com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.