com.pulumi.alicloud.slb.MasterSlaveServerGroup Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of alicloud Show documentation
Show all versions of alicloud Show documentation
A Pulumi package for creating and managing AliCloud resources.
// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package com.pulumi.alicloud.slb;
import com.pulumi.alicloud.Utilities;
import com.pulumi.alicloud.slb.MasterSlaveServerGroupArgs;
import com.pulumi.alicloud.slb.inputs.MasterSlaveServerGroupState;
import com.pulumi.alicloud.slb.outputs.MasterSlaveServerGroupServer;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import java.lang.Boolean;
import java.lang.String;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
/**
* A master slave server group contains two ECS instances. The master slave server group can help you to define multiple listening dimension.
*
* > **NOTE:** One ECS instance can be added into multiple master slave server groups.
*
* > **NOTE:** One master slave server group can only add two ECS instances, which are master server and slave server.
*
* > **NOTE:** One master slave server group can be attached with tcp/udp listeners in one load balancer.
*
* > **NOTE:** One Classic and Internet load balancer, its master slave server group can add Classic and VPC ECS instances.
*
* > **NOTE:** One Classic and Intranet load balancer, its master slave server group can only add Classic ECS instances.
*
* > **NOTE:** One VPC load balancer, its master slave server group can only add the same VPC ECS instances.
*
* > **NOTE:** Available in 1.54.0+
*
* ## Example Usage
*
* <!--Start PulumiCodeChooser -->
*
* {@code
* 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.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.slb.ApplicationLoadBalancer;
* import com.pulumi.alicloud.slb.ApplicationLoadBalancerArgs;
* import com.pulumi.alicloud.ecs.EcsNetworkInterface;
* import com.pulumi.alicloud.ecs.EcsNetworkInterfaceArgs;
* import com.pulumi.alicloud.ecs.EcsNetworkInterfaceAttachment;
* import com.pulumi.alicloud.ecs.EcsNetworkInterfaceAttachmentArgs;
* import com.pulumi.alicloud.slb.MasterSlaveServerGroup;
* import com.pulumi.alicloud.slb.MasterSlaveServerGroupArgs;
* import com.pulumi.alicloud.slb.inputs.MasterSlaveServerGroupServerArgs;
* import com.pulumi.alicloud.slb.Listener;
* import com.pulumi.alicloud.slb.ListenerArgs;
* import com.pulumi.codegen.internal.KeyedValue;
* 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 msServerGroup = AlicloudFunctions.getZones(GetZonesArgs.builder()
* .availableDiskCategory("cloud_efficiency")
* .availableResourceCreation("VSwitch")
* .build());
*
* final var msServerGroupGetInstanceTypes = EcsFunctions.getInstanceTypes(GetInstanceTypesArgs.builder()
* .availabilityZone(msServerGroup.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
* .eniAmount(2)
* .build());
*
* final var image = EcsFunctions.getImages(GetImagesArgs.builder()
* .nameRegex("^ubuntu_18.*64")
* .mostRecent(true)
* .owners("system")
* .build());
*
* final var slbMasterSlaveServerGroup = config.get("slbMasterSlaveServerGroup").orElse("forSlbMasterSlaveServerGroup");
* var main = new Network("main", NetworkArgs.builder()
* .vpcName(slbMasterSlaveServerGroup)
* .cidrBlock("172.16.0.0/16")
* .build());
*
* var mainSwitch = new Switch("mainSwitch", SwitchArgs.builder()
* .vpcId(main.id())
* .cidrBlock("172.16.0.0/16")
* .zoneId(msServerGroup.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
* .vswitchName(slbMasterSlaveServerGroup)
* .build());
*
* var group = new SecurityGroup("group", SecurityGroupArgs.builder()
* .name(slbMasterSlaveServerGroup)
* .vpcId(main.id())
* .build());
*
* for (var i = 0; i < 2; i++) {
* new Instance("msServerGroupInstance-" + i, InstanceArgs.builder()
* .imageId(image.applyValue(getImagesResult -> getImagesResult.images()[0].id()))
* .instanceType(msServerGroupGetInstanceTypes.applyValue(getInstanceTypesResult -> getInstanceTypesResult.instanceTypes()[0].id()))
* .instanceName(slbMasterSlaveServerGroup)
* .securityGroups(group.id())
* .internetChargeType("PayByTraffic")
* .internetMaxBandwidthOut("10")
* .availabilityZone(msServerGroup.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
* .instanceChargeType("PostPaid")
* .systemDiskCategory("cloud_efficiency")
* .vswitchId(mainSwitch.id())
* .build());
*
*
* }
* var msServerGroupApplicationLoadBalancer = new ApplicationLoadBalancer("msServerGroupApplicationLoadBalancer", ApplicationLoadBalancerArgs.builder()
* .loadBalancerName(slbMasterSlaveServerGroup)
* .vswitchId(mainSwitch.id())
* .loadBalancerSpec("slb.s2.small")
* .build());
*
* var msServerGroupEcsNetworkInterface = new EcsNetworkInterface("msServerGroupEcsNetworkInterface", EcsNetworkInterfaceArgs.builder()
* .networkInterfaceName(slbMasterSlaveServerGroup)
* .vswitchId(mainSwitch.id())
* .securityGroupIds(group.id())
* .build());
*
* var msServerGroupEcsNetworkInterfaceAttachment = new EcsNetworkInterfaceAttachment("msServerGroupEcsNetworkInterfaceAttachment", EcsNetworkInterfaceAttachmentArgs.builder()
* .instanceId(msServerGroupInstance[0].id())
* .networkInterfaceId(msServerGroupEcsNetworkInterface.id())
* .build());
*
* var groupMasterSlaveServerGroup = new MasterSlaveServerGroup("groupMasterSlaveServerGroup", MasterSlaveServerGroupArgs.builder()
* .loadBalancerId(msServerGroupApplicationLoadBalancer.id())
* .name(slbMasterSlaveServerGroup)
* .servers(
* MasterSlaveServerGroupServerArgs.builder()
* .serverId(msServerGroupInstance[0].id())
* .port(100)
* .weight(100)
* .serverType("Master")
* .build(),
* MasterSlaveServerGroupServerArgs.builder()
* .serverId(msServerGroupInstance[1].id())
* .port(100)
* .weight(100)
* .serverType("Slave")
* .build())
* .build());
*
* var tcp = new Listener("tcp", ListenerArgs.builder()
* .loadBalancerId(msServerGroupApplicationLoadBalancer.id())
* .masterSlaveServerGroupId(groupMasterSlaveServerGroup.id())
* .frontendPort("22")
* .protocol("tcp")
* .bandwidth("10")
* .healthCheckType("tcp")
* .persistenceTimeout(3600)
* .healthyThreshold(8)
* .unhealthyThreshold(8)
* .healthCheckTimeout(8)
* .healthCheckInterval(5)
* .healthCheckHttpCode("http_2xx")
* .healthCheckConnectPort(20)
* .healthCheckUri("/console")
* .establishedTimeout(600)
* .build());
*
* }
* }
* }
*
* <!--End PulumiCodeChooser -->
*
* ## Block servers
*
* The servers mapping supports the following:
*
* * `server_ids` - (Required) A list backend server ID (ECS instance ID).
* * `port` - (Required) The port used by the backend server. Valid value range: [1-65535].
* * `weight` - (Optional) Weight of the backend server. Valid value range: [0-100]. Default to 100.
* * `type` - (Optional, Available in 1.51.0+) Type of the backend server. Valid value ecs, eni. Default to eni.
* * `server_type` - (Optional) The server type of the backend server. Valid value Master, Slave.
* * `is_backup` - (Removed from v1.63.0) Determine if the server is executing. Valid value 0, 1.
*
* ## Import
*
* Load balancer master slave server group can be imported using the id, e.g.
*
* ```sh
* $ pulumi import alicloud:slb/masterSlaveServerGroup:MasterSlaveServerGroup example abc123456
* ```
*
*/
@ResourceType(type="alicloud:slb/masterSlaveServerGroup:MasterSlaveServerGroup")
public class MasterSlaveServerGroup extends com.pulumi.resources.CustomResource {
/**
* Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.
*
*/
@Export(name="deleteProtectionValidation", refs={Boolean.class}, tree="[0]")
private Output deleteProtectionValidation;
/**
* @return Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.
*
*/
public Output> deleteProtectionValidation() {
return Codegen.optional(this.deleteProtectionValidation);
}
/**
* The Load Balancer ID which is used to launch a new master slave server group.
*
*/
@Export(name="loadBalancerId", refs={String.class}, tree="[0]")
private Output loadBalancerId;
/**
* @return The Load Balancer ID which is used to launch a new master slave server group.
*
*/
public Output loadBalancerId() {
return this.loadBalancerId;
}
/**
* Name of the master slave server group.
*
*/
@Export(name="name", refs={String.class}, tree="[0]")
private Output name;
/**
* @return Name of the master slave server group.
*
*/
public Output name() {
return this.name;
}
/**
* A list of ECS instances to be added. Only two ECS instances can be supported in one resource. It contains six sub-fields as `Block server` follows.
*
*/
@Export(name="servers", refs={List.class,MasterSlaveServerGroupServer.class}, tree="[0,1]")
private Output> servers;
/**
* @return A list of ECS instances to be added. Only two ECS instances can be supported in one resource. It contains six sub-fields as `Block server` follows.
*
*/
public Output>> servers() {
return Codegen.optional(this.servers);
}
/**
*
* @param name The _unique_ name of the resulting resource.
*/
public MasterSlaveServerGroup(java.lang.String name) {
this(name, MasterSlaveServerGroupArgs.Empty);
}
/**
*
* @param name The _unique_ name of the resulting resource.
* @param args The arguments to use to populate this resource's properties.
*/
public MasterSlaveServerGroup(java.lang.String name, MasterSlaveServerGroupArgs args) {
this(name, args, null);
}
/**
*
* @param name The _unique_ name of the resulting resource.
* @param args The arguments to use to populate this resource's properties.
* @param options A bag of options that control this resource's behavior.
*/
public MasterSlaveServerGroup(java.lang.String name, MasterSlaveServerGroupArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("alicloud:slb/masterSlaveServerGroup:MasterSlaveServerGroup", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false);
}
private MasterSlaveServerGroup(java.lang.String name, Output id, @Nullable MasterSlaveServerGroupState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("alicloud:slb/masterSlaveServerGroup:MasterSlaveServerGroup", name, state, makeResourceOptions(options, id), false);
}
private static MasterSlaveServerGroupArgs makeArgs(MasterSlaveServerGroupArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
if (options != null && options.getUrn().isPresent()) {
return null;
}
return args == null ? MasterSlaveServerGroupArgs.Empty : args;
}
private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) {
var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder()
.version(Utilities.getVersion())
.build();
return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id);
}
/**
* Get an existing Host resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state
* @param options Optional settings to control the behavior of the CustomResource.
*/
public static MasterSlaveServerGroup get(java.lang.String name, Output id, @Nullable MasterSlaveServerGroupState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
return new MasterSlaveServerGroup(name, id, state, options);
}
}