Google Cloud Classic v8.9.3 published on Monday, Nov 18, 2024 by Pulumi
gcp.compute.getLBIPRanges
Explore with Pulumi AI
Use this data source to access IP ranges in your firewall rules.
https://cloud.google.com/compute/docs/load-balancing/health-checks#health_check_source_ips_and_firewall_rules
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const ranges = gcp.compute.getLBIPRanges({});
const lb = new gcp.compute.Firewall("lb", {
name: "lb-firewall",
network: main.name,
allows: [{
protocol: "tcp",
ports: ["80"],
}],
sourceRanges: ranges.then(ranges => ranges.networks),
targetTags: ["InstanceBehindLoadBalancer"],
});
import pulumi
import pulumi_gcp as gcp
ranges = gcp.compute.get_lbip_ranges()
lb = gcp.compute.Firewall("lb",
name="lb-firewall",
network=main["name"],
allows=[{
"protocol": "tcp",
"ports": ["80"],
}],
source_ranges=ranges.networks,
target_tags=["InstanceBehindLoadBalancer"])
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/compute"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
ranges, err := compute.GetLBIPRanges(ctx, map[string]interface{}{}, nil)
if err != nil {
return err
}
_, err = compute.NewFirewall(ctx, "lb", &compute.FirewallArgs{
Name: pulumi.String("lb-firewall"),
Network: pulumi.Any(main.Name),
Allows: compute.FirewallAllowArray{
&compute.FirewallAllowArgs{
Protocol: pulumi.String("tcp"),
Ports: pulumi.StringArray{
pulumi.String("80"),
},
},
},
SourceRanges: interface{}(ranges.Networks),
TargetTags: pulumi.StringArray{
pulumi.String("InstanceBehindLoadBalancer"),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var ranges = Gcp.Compute.GetLBIPRanges.Invoke();
var lb = new Gcp.Compute.Firewall("lb", new()
{
Name = "lb-firewall",
Network = main.Name,
Allows = new[]
{
new Gcp.Compute.Inputs.FirewallAllowArgs
{
Protocol = "tcp",
Ports = new[]
{
"80",
},
},
},
SourceRanges = ranges.Apply(getLBIPRangesResult => getLBIPRangesResult.Networks),
TargetTags = new[]
{
"InstanceBehindLoadBalancer",
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.ComputeFunctions;
import com.pulumi.gcp.compute.Firewall;
import com.pulumi.gcp.compute.FirewallArgs;
import com.pulumi.gcp.compute.inputs.FirewallAllowArgs;
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 ranges = ComputeFunctions.getLBIPRanges();
var lb = new Firewall("lb", FirewallArgs.builder()
.name("lb-firewall")
.network(main.name())
.allows(FirewallAllowArgs.builder()
.protocol("tcp")
.ports("80")
.build())
.sourceRanges(ranges.applyValue(getLBIPRangesResult -> getLBIPRangesResult.networks()))
.targetTags("InstanceBehindLoadBalancer")
.build());
}
}
resources:
lb:
type: gcp:compute:Firewall
properties:
name: lb-firewall
network: ${main.name}
allows:
- protocol: tcp
ports:
- '80'
sourceRanges: ${ranges.networks}
targetTags:
- InstanceBehindLoadBalancer
variables:
ranges:
fn::invoke:
Function: gcp:compute:getLBIPRanges
Arguments: {}
Using getLBIPRanges
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 getLBIPRanges(opts?: InvokeOptions): Promise<GetLBIPRangesResult>
function getLBIPRangesOutput(opts?: InvokeOptions): Output<GetLBIPRangesResult>
def get_lbip_ranges(opts: Optional[InvokeOptions] = None) -> GetLBIPRangesResult
def get_lbip_ranges_output(opts: Optional[InvokeOptions] = None) -> Output[GetLBIPRangesResult]
func GetLBIPRanges(ctx *Context, opts ...InvokeOption) (*GetLBIPRangesResult, error)
func GetLBIPRangesOutput(ctx *Context, opts ...InvokeOption) GetLBIPRangesResultOutput
> Note: This function is named GetLBIPRanges
in the Go SDK.
public static class GetLBIPRanges
{
public static Task<GetLBIPRangesResult> InvokeAsync(InvokeOptions? opts = null)
public static Output<GetLBIPRangesResult> Invoke(InvokeOptions? opts = null)
}
public static CompletableFuture<GetLBIPRangesResult> getLBIPRanges(InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: gcp:compute/getLBIPRanges:getLBIPRanges
arguments:
# arguments dictionary
getLBIPRanges Result
The following output properties are available:
- Http
Ssl List<string>Tcp Internals - The IP ranges used for health checks when HTTP(S), SSL proxy, TCP proxy, and Internal load balancing is used
- Id string
- The provider-assigned unique ID for this managed resource.
- Networks List<string>
- The IP ranges used for health checks when Network load balancing is used
- Http
Ssl []stringTcp Internals - The IP ranges used for health checks when HTTP(S), SSL proxy, TCP proxy, and Internal load balancing is used
- Id string
- The provider-assigned unique ID for this managed resource.
- Networks []string
- The IP ranges used for health checks when Network load balancing is used
- http
Ssl List<String>Tcp Internals - The IP ranges used for health checks when HTTP(S), SSL proxy, TCP proxy, and Internal load balancing is used
- id String
- The provider-assigned unique ID for this managed resource.
- networks List<String>
- The IP ranges used for health checks when Network load balancing is used
- http
Ssl string[]Tcp Internals - The IP ranges used for health checks when HTTP(S), SSL proxy, TCP proxy, and Internal load balancing is used
- id string
- The provider-assigned unique ID for this managed resource.
- networks string[]
- The IP ranges used for health checks when Network load balancing is used
- http_
ssl_ Sequence[str]tcp_ internals - The IP ranges used for health checks when HTTP(S), SSL proxy, TCP proxy, and Internal load balancing is used
- id str
- The provider-assigned unique ID for this managed resource.
- networks Sequence[str]
- The IP ranges used for health checks when Network load balancing is used
- http
Ssl List<String>Tcp Internals - The IP ranges used for health checks when HTTP(S), SSL proxy, TCP proxy, and Internal load balancing is used
- id String
- The provider-assigned unique ID for this managed resource.
- networks List<String>
- The IP ranges used for health checks when Network load balancing is used
Package Details
- Repository
- Google Cloud (GCP) Classic pulumi/pulumi-gcp
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
google-beta
Terraform Provider.