Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi
alicloud.slb.getRules
Explore with Pulumi AI
This data source provides the rules associated with a server load balancer listener.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
const name = config.get("name") || "slbrulebasicconfig";
const default = alicloud.getZones({
availableDiskCategory: "cloud_efficiency",
availableResourceCreation: "VSwitch",
});
const defaultNetwork = new alicloud.vpc.Network("default", {
name: name,
cidrBlock: "172.16.0.0/16",
});
const defaultSwitch = new alicloud.vpc.Switch("default", {
vpcId: defaultNetwork.id,
cidrBlock: "172.16.0.0/16",
zoneId: _default.then(_default => _default.zones?.[0]?.id),
vswitchName: name,
});
const defaultApplicationLoadBalancer = new alicloud.slb.ApplicationLoadBalancer("default", {
loadBalancerName: name,
vswitchId: defaultSwitch.id,
});
const defaultListener = new alicloud.slb.Listener("default", {
loadBalancerId: defaultApplicationLoadBalancer.id,
backendPort: 22,
frontendPort: 22,
protocol: "http",
bandwidth: 5,
healthCheckConnectPort: 20,
});
const defaultServerGroup = new alicloud.slb.ServerGroup("default", {loadBalancerId: defaultApplicationLoadBalancer.id});
const defaultRule = new alicloud.slb.Rule("default", {
loadBalancerId: defaultApplicationLoadBalancer.id,
frontendPort: defaultListener.frontendPort,
name: name,
domain: "*.aliyun.com",
url: "/image",
serverGroupId: defaultServerGroup.id,
});
const sampleDs = defaultApplicationLoadBalancer.id.apply(id => alicloud.slb.getRulesOutput({
loadBalancerId: id,
frontendPort: 22,
}));
export const firstSlbRuleId = sampleDs.apply(sampleDs => sampleDs.slbRules?.[0]?.id);
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "slbrulebasicconfig"
default = alicloud.get_zones(available_disk_category="cloud_efficiency",
available_resource_creation="VSwitch")
default_network = alicloud.vpc.Network("default",
name=name,
cidr_block="172.16.0.0/16")
default_switch = alicloud.vpc.Switch("default",
vpc_id=default_network.id,
cidr_block="172.16.0.0/16",
zone_id=default.zones[0].id,
vswitch_name=name)
default_application_load_balancer = alicloud.slb.ApplicationLoadBalancer("default",
load_balancer_name=name,
vswitch_id=default_switch.id)
default_listener = alicloud.slb.Listener("default",
load_balancer_id=default_application_load_balancer.id,
backend_port=22,
frontend_port=22,
protocol="http",
bandwidth=5,
health_check_connect_port=20)
default_server_group = alicloud.slb.ServerGroup("default", load_balancer_id=default_application_load_balancer.id)
default_rule = alicloud.slb.Rule("default",
load_balancer_id=default_application_load_balancer.id,
frontend_port=default_listener.frontend_port,
name=name,
domain="*.aliyun.com",
url="/image",
server_group_id=default_server_group.id)
sample_ds = default_application_load_balancer.id.apply(lambda id: alicloud.slb.get_rules_output(load_balancer_id=id,
frontend_port=22))
pulumi.export("firstSlbRuleId", sample_ds.slb_rules[0].id)
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/slb"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
name := "slbrulebasicconfig"
if param := cfg.Get("name"); param != "" {
name = param
}
_default, err := alicloud.GetZones(ctx, &alicloud.GetZonesArgs{
AvailableDiskCategory: pulumi.StringRef("cloud_efficiency"),
AvailableResourceCreation: pulumi.StringRef("VSwitch"),
}, nil)
if err != nil {
return err
}
defaultNetwork, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
Name: pulumi.String(name),
CidrBlock: pulumi.String("172.16.0.0/16"),
})
if err != nil {
return err
}
defaultSwitch, err := vpc.NewSwitch(ctx, "default", &vpc.SwitchArgs{
VpcId: defaultNetwork.ID(),
CidrBlock: pulumi.String("172.16.0.0/16"),
ZoneId: pulumi.String(_default.Zones[0].Id),
VswitchName: pulumi.String(name),
})
if err != nil {
return err
}
defaultApplicationLoadBalancer, err := slb.NewApplicationLoadBalancer(ctx, "default", &slb.ApplicationLoadBalancerArgs{
LoadBalancerName: pulumi.String(name),
VswitchId: defaultSwitch.ID(),
})
if err != nil {
return err
}
defaultListener, err := slb.NewListener(ctx, "default", &slb.ListenerArgs{
LoadBalancerId: defaultApplicationLoadBalancer.ID(),
BackendPort: pulumi.Int(22),
FrontendPort: pulumi.Int(22),
Protocol: pulumi.String("http"),
Bandwidth: pulumi.Int(5),
HealthCheckConnectPort: pulumi.Int(20),
})
if err != nil {
return err
}
defaultServerGroup, err := slb.NewServerGroup(ctx, "default", &slb.ServerGroupArgs{
LoadBalancerId: defaultApplicationLoadBalancer.ID(),
})
if err != nil {
return err
}
_, err = slb.NewRule(ctx, "default", &slb.RuleArgs{
LoadBalancerId: defaultApplicationLoadBalancer.ID(),
FrontendPort: defaultListener.FrontendPort,
Name: pulumi.String(name),
Domain: pulumi.String("*.aliyun.com"),
Url: pulumi.String("/image"),
ServerGroupId: defaultServerGroup.ID(),
})
if err != nil {
return err
}
sampleDs := defaultApplicationLoadBalancer.ID().ApplyT(func(id string) (slb.GetRulesResult, error) {
return slb.GetRulesOutput(ctx, slb.GetRulesOutputArgs{
LoadBalancerId: id,
FrontendPort: 22,
}, nil), nil
}).(slb.GetRulesResultOutput)
ctx.Export("firstSlbRuleId", sampleDs.ApplyT(func(sampleDs slb.GetRulesResult) (*string, error) {
return &sampleDs.SlbRules[0].Id, nil
}).(pulumi.StringPtrOutput))
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "slbrulebasicconfig";
var @default = AliCloud.GetZones.Invoke(new()
{
AvailableDiskCategory = "cloud_efficiency",
AvailableResourceCreation = "VSwitch",
});
var defaultNetwork = new AliCloud.Vpc.Network("default", new()
{
Name = name,
CidrBlock = "172.16.0.0/16",
});
var defaultSwitch = new AliCloud.Vpc.Switch("default", new()
{
VpcId = defaultNetwork.Id,
CidrBlock = "172.16.0.0/16",
ZoneId = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones[0]?.Id)),
VswitchName = name,
});
var defaultApplicationLoadBalancer = new AliCloud.Slb.ApplicationLoadBalancer("default", new()
{
LoadBalancerName = name,
VswitchId = defaultSwitch.Id,
});
var defaultListener = new AliCloud.Slb.Listener("default", new()
{
LoadBalancerId = defaultApplicationLoadBalancer.Id,
BackendPort = 22,
FrontendPort = 22,
Protocol = "http",
Bandwidth = 5,
HealthCheckConnectPort = 20,
});
var defaultServerGroup = new AliCloud.Slb.ServerGroup("default", new()
{
LoadBalancerId = defaultApplicationLoadBalancer.Id,
});
var defaultRule = new AliCloud.Slb.Rule("default", new()
{
LoadBalancerId = defaultApplicationLoadBalancer.Id,
FrontendPort = defaultListener.FrontendPort,
Name = name,
Domain = "*.aliyun.com",
Url = "/image",
ServerGroupId = defaultServerGroup.Id,
});
var sampleDs = AliCloud.Slb.GetRules.Invoke(new()
{
LoadBalancerId = defaultApplicationLoadBalancer.Id,
FrontendPort = 22,
});
return new Dictionary<string, object?>
{
["firstSlbRuleId"] = sampleDs.Apply(getRulesResult => getRulesResult.SlbRules[0]?.Id),
};
});
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.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.vpc.Switch;
import com.pulumi.alicloud.vpc.SwitchArgs;
import com.pulumi.alicloud.slb.ApplicationLoadBalancer;
import com.pulumi.alicloud.slb.ApplicationLoadBalancerArgs;
import com.pulumi.alicloud.slb.Listener;
import com.pulumi.alicloud.slb.ListenerArgs;
import com.pulumi.alicloud.slb.ServerGroup;
import com.pulumi.alicloud.slb.ServerGroupArgs;
import com.pulumi.alicloud.slb.Rule;
import com.pulumi.alicloud.slb.RuleArgs;
import com.pulumi.alicloud.slb.SlbFunctions;
import com.pulumi.alicloud.slb.inputs.GetRulesArgs;
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("slbrulebasicconfig");
final var default = AlicloudFunctions.getZones(GetZonesArgs.builder()
.availableDiskCategory("cloud_efficiency")
.availableResourceCreation("VSwitch")
.build());
var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
.name(name)
.cidrBlock("172.16.0.0/16")
.build());
var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()
.vpcId(defaultNetwork.id())
.cidrBlock("172.16.0.0/16")
.zoneId(default_.zones()[0].id())
.vswitchName(name)
.build());
var defaultApplicationLoadBalancer = new ApplicationLoadBalancer("defaultApplicationLoadBalancer", ApplicationLoadBalancerArgs.builder()
.loadBalancerName(name)
.vswitchId(defaultSwitch.id())
.build());
var defaultListener = new Listener("defaultListener", ListenerArgs.builder()
.loadBalancerId(defaultApplicationLoadBalancer.id())
.backendPort(22)
.frontendPort(22)
.protocol("http")
.bandwidth(5)
.healthCheckConnectPort("20")
.build());
var defaultServerGroup = new ServerGroup("defaultServerGroup", ServerGroupArgs.builder()
.loadBalancerId(defaultApplicationLoadBalancer.id())
.build());
var defaultRule = new Rule("defaultRule", RuleArgs.builder()
.loadBalancerId(defaultApplicationLoadBalancer.id())
.frontendPort(defaultListener.frontendPort())
.name(name)
.domain("*.aliyun.com")
.url("/image")
.serverGroupId(defaultServerGroup.id())
.build());
final var sampleDs = SlbFunctions.getRules(GetRulesArgs.builder()
.loadBalancerId(defaultApplicationLoadBalancer.id())
.frontendPort(22)
.build());
ctx.export("firstSlbRuleId", sampleDs.applyValue(getRulesResult -> getRulesResult).applyValue(sampleDs -> sampleDs.applyValue(getRulesResult -> getRulesResult.slbRules()[0].id())));
}
}
configuration:
name:
type: string
default: slbrulebasicconfig
resources:
defaultNetwork:
type: alicloud:vpc:Network
name: default
properties:
name: ${name}
cidrBlock: 172.16.0.0/16
defaultSwitch:
type: alicloud:vpc:Switch
name: default
properties:
vpcId: ${defaultNetwork.id}
cidrBlock: 172.16.0.0/16
zoneId: ${default.zones[0].id}
vswitchName: ${name}
defaultApplicationLoadBalancer:
type: alicloud:slb:ApplicationLoadBalancer
name: default
properties:
loadBalancerName: ${name}
vswitchId: ${defaultSwitch.id}
defaultListener:
type: alicloud:slb:Listener
name: default
properties:
loadBalancerId: ${defaultApplicationLoadBalancer.id}
backendPort: 22
frontendPort: 22
protocol: http
bandwidth: 5
healthCheckConnectPort: '20'
defaultServerGroup:
type: alicloud:slb:ServerGroup
name: default
properties:
loadBalancerId: ${defaultApplicationLoadBalancer.id}
defaultRule:
type: alicloud:slb:Rule
name: default
properties:
loadBalancerId: ${defaultApplicationLoadBalancer.id}
frontendPort: ${defaultListener.frontendPort}
name: ${name}
domain: '*.aliyun.com'
url: /image
serverGroupId: ${defaultServerGroup.id}
variables:
default:
fn::invoke:
Function: alicloud:getZones
Arguments:
availableDiskCategory: cloud_efficiency
availableResourceCreation: VSwitch
sampleDs:
fn::invoke:
Function: alicloud:slb:getRules
Arguments:
loadBalancerId: ${defaultApplicationLoadBalancer.id}
frontendPort: 22
outputs:
firstSlbRuleId: ${sampleDs.slbRules[0].id}
Using getRules
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getRules(args: GetRulesArgs, opts?: InvokeOptions): Promise<GetRulesResult>
function getRulesOutput(args: GetRulesOutputArgs, opts?: InvokeOptions): Output<GetRulesResult>
def get_rules(frontend_port: Optional[int] = None,
ids: Optional[Sequence[str]] = None,
load_balancer_id: Optional[str] = None,
name_regex: Optional[str] = None,
output_file: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetRulesResult
def get_rules_output(frontend_port: Optional[pulumi.Input[int]] = None,
ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
load_balancer_id: Optional[pulumi.Input[str]] = None,
name_regex: Optional[pulumi.Input[str]] = None,
output_file: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetRulesResult]
func GetRules(ctx *Context, args *GetRulesArgs, opts ...InvokeOption) (*GetRulesResult, error)
func GetRulesOutput(ctx *Context, args *GetRulesOutputArgs, opts ...InvokeOption) GetRulesResultOutput
> Note: This function is named GetRules
in the Go SDK.
public static class GetRules
{
public static Task<GetRulesResult> InvokeAsync(GetRulesArgs args, InvokeOptions? opts = null)
public static Output<GetRulesResult> Invoke(GetRulesInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetRulesResult> getRules(GetRulesArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: alicloud:slb/getRules:getRules
arguments:
# arguments dictionary
The following arguments are supported:
- Frontend
Port int - SLB listener port.
- Load
Balancer stringId - ID of the SLB with listener rules.
- Ids List<string>
- A list of rules IDs to filter results.
- Name
Regex string - A regex string to filter results by rule name.
- Output
File string - File name where to save data source results (after running
pulumi preview
).
- Frontend
Port int - SLB listener port.
- Load
Balancer stringId - ID of the SLB with listener rules.
- Ids []string
- A list of rules IDs to filter results.
- Name
Regex string - A regex string to filter results by rule name.
- Output
File string - File name where to save data source results (after running
pulumi preview
).
- frontend
Port Integer - SLB listener port.
- load
Balancer StringId - ID of the SLB with listener rules.
- ids List<String>
- A list of rules IDs to filter results.
- name
Regex String - A regex string to filter results by rule name.
- output
File String - File name where to save data source results (after running
pulumi preview
).
- frontend
Port number - SLB listener port.
- load
Balancer stringId - ID of the SLB with listener rules.
- ids string[]
- A list of rules IDs to filter results.
- name
Regex string - A regex string to filter results by rule name.
- output
File string - File name where to save data source results (after running
pulumi preview
).
- frontend_
port int - SLB listener port.
- load_
balancer_ strid - ID of the SLB with listener rules.
- ids Sequence[str]
- A list of rules IDs to filter results.
- name_
regex str - A regex string to filter results by rule name.
- output_
file str - File name where to save data source results (after running
pulumi preview
).
- frontend
Port Number - SLB listener port.
- load
Balancer StringId - ID of the SLB with listener rules.
- ids List<String>
- A list of rules IDs to filter results.
- name
Regex String - A regex string to filter results by rule name.
- output
File String - File name where to save data source results (after running
pulumi preview
).
getRules Result
The following output properties are available:
- Frontend
Port int - Id string
- The provider-assigned unique ID for this managed resource.
- Ids List<string>
- A list of SLB listener rules IDs.
- Load
Balancer stringId - Names List<string>
- A list of SLB listener rules names.
- Slb
Rules List<Pulumi.Ali Cloud. Slb. Outputs. Get Rules Slb Rule> - A list of SLB listener rules. Each element contains the following attributes:
- Name
Regex string - Output
File string
- Frontend
Port int - Id string
- The provider-assigned unique ID for this managed resource.
- Ids []string
- A list of SLB listener rules IDs.
- Load
Balancer stringId - Names []string
- A list of SLB listener rules names.
- Slb
Rules []GetRules Slb Rule - A list of SLB listener rules. Each element contains the following attributes:
- Name
Regex string - Output
File string
- frontend
Port Integer - id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- A list of SLB listener rules IDs.
- load
Balancer StringId - names List<String>
- A list of SLB listener rules names.
- slb
Rules List<GetRules Slb Rule> - A list of SLB listener rules. Each element contains the following attributes:
- name
Regex String - output
File String
- frontend
Port number - id string
- The provider-assigned unique ID for this managed resource.
- ids string[]
- A list of SLB listener rules IDs.
- load
Balancer stringId - names string[]
- A list of SLB listener rules names.
- slb
Rules GetRules Slb Rule[] - A list of SLB listener rules. Each element contains the following attributes:
- name
Regex string - output
File string
- frontend_
port int - id str
- The provider-assigned unique ID for this managed resource.
- ids Sequence[str]
- A list of SLB listener rules IDs.
- load_
balancer_ strid - names Sequence[str]
- A list of SLB listener rules names.
- slb_
rules Sequence[GetRules Slb Rule] - A list of SLB listener rules. Each element contains the following attributes:
- name_
regex str - output_
file str
- frontend
Port Number - id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- A list of SLB listener rules IDs.
- load
Balancer StringId - names List<String>
- A list of SLB listener rules names.
- slb
Rules List<Property Map> - A list of SLB listener rules. Each element contains the following attributes:
- name
Regex String - output
File String
Supporting Types
GetRulesSlbRule
- Domain string
- Domain name in the HTTP request where the rule applies (e.g. "*.aliyun.com").
- Id string
- Rule ID.
- Name string
- Rule name.
- Server
Group stringId - ID of the linked VServer group.
- Url string
- Path in the HTTP request where the rule applies (e.g. "/image").
- Domain string
- Domain name in the HTTP request where the rule applies (e.g. "*.aliyun.com").
- Id string
- Rule ID.
- Name string
- Rule name.
- Server
Group stringId - ID of the linked VServer group.
- Url string
- Path in the HTTP request where the rule applies (e.g. "/image").
- domain String
- Domain name in the HTTP request where the rule applies (e.g. "*.aliyun.com").
- id String
- Rule ID.
- name String
- Rule name.
- server
Group StringId - ID of the linked VServer group.
- url String
- Path in the HTTP request where the rule applies (e.g. "/image").
- domain string
- Domain name in the HTTP request where the rule applies (e.g. "*.aliyun.com").
- id string
- Rule ID.
- name string
- Rule name.
- server
Group stringId - ID of the linked VServer group.
- url string
- Path in the HTTP request where the rule applies (e.g. "/image").
- domain str
- Domain name in the HTTP request where the rule applies (e.g. "*.aliyun.com").
- id str
- Rule ID.
- name str
- Rule name.
- server_
group_ strid - ID of the linked VServer group.
- url str
- Path in the HTTP request where the rule applies (e.g. "/image").
- domain String
- Domain name in the HTTP request where the rule applies (e.g. "*.aliyun.com").
- id String
- Rule ID.
- name String
- Rule name.
- server
Group StringId - ID of the linked VServer group.
- url String
- Path in the HTTP request where the rule applies (e.g. "/image").
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloud
Terraform Provider.