com.pulumi.alicloud.nlb.LoadBalancer 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.nlb;
import com.pulumi.alicloud.Utilities;
import com.pulumi.alicloud.nlb.LoadBalancerArgs;
import com.pulumi.alicloud.nlb.inputs.LoadBalancerState;
import com.pulumi.alicloud.nlb.outputs.LoadBalancerDeletionProtectionConfig;
import com.pulumi.alicloud.nlb.outputs.LoadBalancerModificationProtectionConfig;
import com.pulumi.alicloud.nlb.outputs.LoadBalancerZoneMapping;
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.Map;
import java.util.Optional;
import javax.annotation.Nullable;
/**
* Provides a NLB Load Balancer resource.
*
* For information about NLB Load Balancer and how to use it, see [What is Load Balancer](https://www.alibabacloud.com/help/en/server-load-balancer/latest/api-nlb-2022-04-30-createloadbalancer).
*
* > **NOTE:** Available since v1.191.0.
*
* ## Example Usage
*
* Basic Usage
*
* <!--Start PulumiCodeChooser -->
*
* {@code
* package generated_program;
*
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.alicloud.resourcemanager.ResourcemanagerFunctions;
* import com.pulumi.alicloud.resourcemanager.inputs.GetResourceGroupsArgs;
* import com.pulumi.alicloud.nlb.NlbFunctions;
* import com.pulumi.alicloud.nlb.inputs.GetZonesArgs;
* 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.nlb.LoadBalancer;
* import com.pulumi.alicloud.nlb.LoadBalancerArgs;
* import com.pulumi.alicloud.nlb.inputs.LoadBalancerZoneMappingArgs;
* 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("tf-example");
* final var default = ResourcemanagerFunctions.getResourceGroups();
*
* final var defaultGetZones = NlbFunctions.getZones();
*
* var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
* .vpcName(name)
* .cidrBlock("10.4.0.0/16")
* .build());
*
* var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()
* .vswitchName(name)
* .cidrBlock("10.4.0.0/24")
* .vpcId(defaultNetwork.id())
* .zoneId(defaultGetZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
* .build());
*
* var default1 = new Switch("default1", SwitchArgs.builder()
* .vswitchName(name)
* .cidrBlock("10.4.1.0/24")
* .vpcId(defaultNetwork.id())
* .zoneId(defaultGetZones.applyValue(getZonesResult -> getZonesResult.zones()[1].id()))
* .build());
*
* var defaultLoadBalancer = new LoadBalancer("defaultLoadBalancer", LoadBalancerArgs.builder()
* .loadBalancerName(name)
* .resourceGroupId(default_.ids()[0])
* .loadBalancerType("Network")
* .addressType("Internet")
* .addressIpVersion("Ipv4")
* .vpcId(defaultNetwork.id())
* .tags(Map.ofEntries(
* Map.entry("Created", "TF"),
* Map.entry("For", "example")
* ))
* .zoneMappings(
* LoadBalancerZoneMappingArgs.builder()
* .vswitchId(defaultSwitch.id())
* .zoneId(defaultGetZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
* .build(),
* LoadBalancerZoneMappingArgs.builder()
* .vswitchId(default1.id())
* .zoneId(defaultGetZones.applyValue(getZonesResult -> getZonesResult.zones()[1].id()))
* .build())
* .build());
*
* }
* }
* }
*
* <!--End PulumiCodeChooser -->
*
* DualStack Usage
*
* <!--Start PulumiCodeChooser -->
*
* {@code
* package generated_program;
*
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* 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.vpc.Ipv6Gateway;
* import com.pulumi.alicloud.vpc.Ipv6GatewayArgs;
* import com.pulumi.alicloud.nlb.LoadBalancer;
* import com.pulumi.alicloud.nlb.LoadBalancerArgs;
* import com.pulumi.alicloud.nlb.inputs.LoadBalancerZoneMappingArgs;
* import com.pulumi.codegen.internal.KeyedValue;
* import com.pulumi.resources.CustomResourceOptions;
* 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("tf-example");
* final var zone = config.get("zone").orElse(
* "cn-beijing-i",
* "cn-beijing-k",
* "cn-beijing-l");
* var vpc = new Network("vpc", NetworkArgs.builder()
* .vpcName(name)
* .cidrBlock("10.2.0.0/16")
* .enableIpv6(true)
* .build());
*
* for (var i = 0; i < 2; i++) {
* new Switch("vsw-" + i, SwitchArgs.builder()
* .enableIpv6(true)
* .ipv6CidrBlockMask(String.format("1%s", range.value()))
* .vswitchName(String.format("vsw-%s-for-nlb", range.value()))
* .vpcId(vpc.id())
* .cidrBlock(String.format("10.2.1%s.0/24", range.value()))
* .zoneId(zone[range.value()])
* .build());
*
*
* }
* var default_ = new Ipv6Gateway("default", Ipv6GatewayArgs.builder()
* .ipv6GatewayName(name)
* .vpcId(vpc.id())
* .build());
*
* var nlb = new LoadBalancer("nlb", LoadBalancerArgs.builder()
* .loadBalancerName(name)
* .loadBalancerType("Network")
* .addressType("Intranet")
* .addressIpVersion("DualStack")
* .ipv6AddressType("Internet")
* .vpcId(vpc.id())
* .crossZoneEnabled(false)
* .tags(Map.ofEntries(
* Map.entry("Created", "TF"),
* Map.entry("For", "example")
* ))
* .zoneMappings(
* LoadBalancerZoneMappingArgs.builder()
* .vswitchId(vsw[0].id())
* .zoneId(zone[0])
* .build(),
* LoadBalancerZoneMappingArgs.builder()
* .vswitchId(vsw[1].id())
* .zoneId(zone[1])
* .build())
* .build(), CustomResourceOptions.builder()
* .dependsOn(default_)
* .build());
*
* }
* }
* }
*
* <!--End PulumiCodeChooser -->
*
* ## Import
*
* NLB Load Balancer can be imported using the id, e.g.
*
* ```sh
* $ pulumi import alicloud:nlb/loadBalancer:LoadBalancer example <id>
* ```
*
*/
@ResourceType(type="alicloud:nlb/loadBalancer:LoadBalancer")
public class LoadBalancer extends com.pulumi.resources.CustomResource {
/**
* The protocol version. Valid values:
*
* - **ipv4:** IPv4. This is the default value.
* - **DualStack:** dual stack.
*
*/
@Export(name="addressIpVersion", refs={String.class}, tree="[0]")
private Output addressIpVersion;
/**
* @return The protocol version. Valid values:
*
* - **ipv4:** IPv4. This is the default value.
* - **DualStack:** dual stack.
*
*/
public Output addressIpVersion() {
return this.addressIpVersion;
}
/**
* The type of IPv4 address used by the NLB instance. Valid values:
* - `Internet`: The NLB instance uses a public IP address. The domain name of the NLB instance is resolved to the public IP address. Therefore, the NLB instance can be accessed over the Internet.
* - `Intranet`: The NLB instance uses a private IP address. The domain name of the NLB instance is resolved to the private IP address. Therefore, the NLB instance can be accessed over the virtual private cloud (VPC) where the NLB instance is deployed.
*
* > **NOTE:** To enable a public IPv6 address for an NLB instance, call the [EnableLoadBalancerIpv6Internet](https://www.alibabacloud.com/help/en/doc-detail/445878.html) operation.
*
*/
@Export(name="addressType", refs={String.class}, tree="[0]")
private Output addressType;
/**
* @return The type of IPv4 address used by the NLB instance. Valid values:
* - `Internet`: The NLB instance uses a public IP address. The domain name of the NLB instance is resolved to the public IP address. Therefore, the NLB instance can be accessed over the Internet.
* - `Intranet`: The NLB instance uses a private IP address. The domain name of the NLB instance is resolved to the private IP address. Therefore, the NLB instance can be accessed over the virtual private cloud (VPC) where the NLB instance is deployed.
*
* > **NOTE:** To enable a public IPv6 address for an NLB instance, call the [EnableLoadBalancerIpv6Internet](https://www.alibabacloud.com/help/en/doc-detail/445878.html) operation.
*
*/
public Output addressType() {
return this.addressType;
}
/**
* The ID of the EIP bandwidth plan that is associated with the Internet-facing NLB instance.
*
*/
@Export(name="bandwidthPackageId", refs={String.class}, tree="[0]")
private Output bandwidthPackageId;
/**
* @return The ID of the EIP bandwidth plan that is associated with the Internet-facing NLB instance.
*
*/
public Output bandwidthPackageId() {
return this.bandwidthPackageId;
}
/**
* Resource creation time, using Greenwich Mean Time, formating' yyyy-MM-ddTHH:mm:ssZ '.
*
*/
@Export(name="createTime", refs={String.class}, tree="[0]")
private Output createTime;
/**
* @return Resource creation time, using Greenwich Mean Time, formating' yyyy-MM-ddTHH:mm:ssZ '.
*
*/
public Output createTime() {
return this.createTime;
}
/**
* Specifies whether to enable cross-zone load balancing for the NLB instance. Valid values:
*
*/
@Export(name="crossZoneEnabled", refs={Boolean.class}, tree="[0]")
private Output crossZoneEnabled;
/**
* @return Specifies whether to enable cross-zone load balancing for the NLB instance. Valid values:
*
*/
public Output crossZoneEnabled() {
return this.crossZoneEnabled;
}
/**
* Specifies whether to enable deletion protection. Default value: `false`. See `deletion_protection_config` below.
*
*/
@Export(name="deletionProtectionConfig", refs={LoadBalancerDeletionProtectionConfig.class}, tree="[0]")
private Output deletionProtectionConfig;
/**
* @return Specifies whether to enable deletion protection. Default value: `false`. See `deletion_protection_config` below.
*
*/
public Output deletionProtectionConfig() {
return this.deletionProtectionConfig;
}
@Export(name="deletionProtectionEnabled", refs={Boolean.class}, tree="[0]")
private Output deletionProtectionEnabled;
public Output deletionProtectionEnabled() {
return this.deletionProtectionEnabled;
}
@Export(name="deletionProtectionReason", refs={String.class}, tree="[0]")
private Output deletionProtectionReason;
public Output deletionProtectionReason() {
return this.deletionProtectionReason;
}
/**
* The domain name of the NLB instance.
*
*/
@Export(name="dnsName", refs={String.class}, tree="[0]")
private Output dnsName;
/**
* @return The domain name of the NLB instance.
*
*/
public Output dnsName() {
return this.dnsName;
}
/**
* The type of IPv6 address used by the NLB instance. Valid values:
* - `Internet`: a public IP address. The domain name of the NLB instance is resolved to the public IP address. Therefore, the NLB instance can be accessed over the Internet.
* - `Intranet`: a private IP address. The domain name of the NLB instance is resolved to the private IP address. Therefore, the NLB instance can be accessed over the VPC where the NLB instance is deployed.
*
*/
@Export(name="ipv6AddressType", refs={String.class}, tree="[0]")
private Output ipv6AddressType;
/**
* @return The type of IPv6 address used by the NLB instance. Valid values:
* - `Internet`: a public IP address. The domain name of the NLB instance is resolved to the public IP address. Therefore, the NLB instance can be accessed over the Internet.
* - `Intranet`: a private IP address. The domain name of the NLB instance is resolved to the private IP address. Therefore, the NLB instance can be accessed over the VPC where the NLB instance is deployed.
*
*/
public Output ipv6AddressType() {
return this.ipv6AddressType;
}
/**
* The business status of the NLB instance.
*
*/
@Export(name="loadBalancerBusinessStatus", refs={String.class}, tree="[0]")
private Output loadBalancerBusinessStatus;
/**
* @return The business status of the NLB instance.
*
*/
public Output loadBalancerBusinessStatus() {
return this.loadBalancerBusinessStatus;
}
/**
* The name of the NLB instance.
*
* The value must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (\_), and hyphens (-). The value must start with a letter.
*
*/
@Export(name="loadBalancerName", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> loadBalancerName;
/**
* @return The name of the NLB instance.
*
* The value must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (\_), and hyphens (-). The value must start with a letter.
*
*/
public Output> loadBalancerName() {
return Codegen.optional(this.loadBalancerName);
}
/**
* The type of the Server Load Balancer (SLB) instance. Set the value to `network`, which specifies NLB.
*
*/
@Export(name="loadBalancerType", refs={String.class}, tree="[0]")
private Output loadBalancerType;
/**
* @return The type of the Server Load Balancer (SLB) instance. Set the value to `network`, which specifies NLB.
*
*/
public Output loadBalancerType() {
return this.loadBalancerType;
}
/**
* Specifies whether to enable the configuration read-only mode. Default value: `NonProtection`. See `modification_protection_config` below.
*
*/
@Export(name="modificationProtectionConfig", refs={LoadBalancerModificationProtectionConfig.class}, tree="[0]")
private Output modificationProtectionConfig;
/**
* @return Specifies whether to enable the configuration read-only mode. Default value: `NonProtection`. See `modification_protection_config` below.
*
*/
public Output modificationProtectionConfig() {
return this.modificationProtectionConfig;
}
@Export(name="modificationProtectionReason", refs={String.class}, tree="[0]")
private Output modificationProtectionReason;
public Output modificationProtectionReason() {
return this.modificationProtectionReason;
}
@Export(name="modificationProtectionStatus", refs={String.class}, tree="[0]")
private Output modificationProtectionStatus;
public Output modificationProtectionStatus() {
return this.modificationProtectionStatus;
}
/**
* The ID of the new resource group.
*
* You can log on to the [Resource Management console](https://resourcemanager.console.aliyun.com/resource-groups) to view resource group IDs.
*
*/
@Export(name="resourceGroupId", refs={String.class}, tree="[0]")
private Output resourceGroupId;
/**
* @return The ID of the new resource group.
*
* You can log on to the [Resource Management console](https://resourcemanager.console.aliyun.com/resource-groups) to view resource group IDs.
*
*/
public Output resourceGroupId() {
return this.resourceGroupId;
}
/**
* The security group to which the network-based SLB instance belongs.
*
*/
@Export(name="securityGroupIds", refs={List.class,String.class}, tree="[0,1]")
private Output> securityGroupIds;
/**
* @return The security group to which the network-based SLB instance belongs.
*
*/
public Output> securityGroupIds() {
return this.securityGroupIds;
}
/**
* The status of the NLB instance.
*
*/
@Export(name="status", refs={String.class}, tree="[0]")
private Output status;
/**
* @return The status of the NLB instance.
*
*/
public Output status() {
return this.status;
}
/**
* List of labels.
*
*/
@Export(name="tags", refs={Map.class,String.class}, tree="[0,1,1]")
private Output* @Nullable */ Map> tags;
/**
* @return List of labels.
*
*/
public Output>> tags() {
return Codegen.optional(this.tags);
}
/**
* The ID of the VPC where the NLB instance is deployed.
*
*/
@Export(name="vpcId", refs={String.class}, tree="[0]")
private Output vpcId;
/**
* @return The ID of the VPC where the NLB instance is deployed.
*
*/
public Output vpcId() {
return this.vpcId;
}
/**
* Available Area Configuration List. You must add at least two zones. You can add a maximum of 10 zones. See `zone_mappings` below.
*
*/
@Export(name="zoneMappings", refs={List.class,LoadBalancerZoneMapping.class}, tree="[0,1]")
private Output> zoneMappings;
/**
* @return Available Area Configuration List. You must add at least two zones. You can add a maximum of 10 zones. See `zone_mappings` below.
*
*/
public Output> zoneMappings() {
return this.zoneMappings;
}
/**
*
* @param name The _unique_ name of the resulting resource.
*/
public LoadBalancer(java.lang.String name) {
this(name, LoadBalancerArgs.Empty);
}
/**
*
* @param name The _unique_ name of the resulting resource.
* @param args The arguments to use to populate this resource's properties.
*/
public LoadBalancer(java.lang.String name, LoadBalancerArgs 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 LoadBalancer(java.lang.String name, LoadBalancerArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("alicloud:nlb/loadBalancer:LoadBalancer", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false);
}
private LoadBalancer(java.lang.String name, Output id, @Nullable LoadBalancerState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("alicloud:nlb/loadBalancer:LoadBalancer", name, state, makeResourceOptions(options, id), false);
}
private static LoadBalancerArgs makeArgs(LoadBalancerArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
if (options != null && options.getUrn().isPresent()) {
return null;
}
return args == null ? LoadBalancerArgs.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 LoadBalancer get(java.lang.String name, Output id, @Nullable LoadBalancerState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
return new LoadBalancer(name, id, state, options);
}
}