Google Cloud (GCP) Classic

Pulumi Official
Package maintained by Pulumi
v6.32.0 published on Wednesday, Jul 20, 2022 by Pulumi

getLBIPRanges

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

using Pulumi;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
    public MyStack()
    {
        var ranges = Output.Create(Gcp.Compute.GetLBIPRanges.InvokeAsync());
        var lb = new Gcp.Compute.Firewall("lb", new Gcp.Compute.FirewallArgs
        {
            Network = google_compute_network.Main.Name,
            Allows = 
            {
                new Gcp.Compute.Inputs.FirewallAllowArgs
                {
                    Protocol = "tcp",
                    Ports = 
                    {
                        "80",
                    },
                },
            },
            SourceRanges = ranges.Apply(ranges => ranges.Networks),
            TargetTags = 
            {
                "InstanceBehindLoadBalancer",
            },
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v6/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, nil, nil)
		if err != nil {
			return err
		}
		_, err = compute.NewFirewall(ctx, "lb", &compute.FirewallArgs{
			Network: pulumi.Any(google_compute_network.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
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var ranges = Output.of(ComputeFunctions.getLBIPRanges());

        var lb = new Firewall("lb", FirewallArgs.builder()        
            .network(google_compute_network.main().name())
            .allows(FirewallAllowArgs.builder()
                .protocol("tcp")
                .ports("80")
                .build())
            .sourceRanges(ranges.apply(getLBIPRangesResult -> getLBIPRangesResult.networks()))
            .targetTags("InstanceBehindLoadBalancer")
            .build());

    }
}
import pulumi
import pulumi_gcp as gcp

ranges = gcp.compute.get_lbip_ranges()
lb = gcp.compute.Firewall("lb",
    network=google_compute_network["main"]["name"],
    allows=[gcp.compute.FirewallAllowArgs(
        protocol="tcp",
        ports=["80"],
    )],
    source_ranges=ranges.networks,
    target_tags=["InstanceBehindLoadBalancer"])
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const ranges = gcp.compute.getLBIPRanges({});
const lb = new gcp.compute.Firewall("lb", {
    network: google_compute_network.main.name,
    allows: [{
        protocol: "tcp",
        ports: ["80"],
    }],
    sourceRanges: ranges.then(ranges => ranges.networks),
    targetTags: ["InstanceBehindLoadBalancer"],
});
resources:
  lb:
    type: gcp:compute:Firewall
    properties:
      network: ${google_compute_network.main.name}
      allows:
        - protocol: tcp
          ports:
            - 80
      sourceRanges: ${ranges.networks}
      targetTags:
        - InstanceBehindLoadBalancer
variables:
  ranges:
    Fn::Invoke:
      Function: gcp:compute:getLBIPRanges
      Arguments: {}

Using getLBIPRanges

function getLBIPRanges(opts?: InvokeOptions): Promise<GetLBIPRangesResult>
def get_lbip_ranges(opts: Optional[InvokeOptions] = None) -> GetLBIPRangesResult
func GetLBIPRanges(ctx *Context, opts ...InvokeOption) (*GetLBIPRangesResult, error)

> Note: This function is named GetLBIPRanges in the Go SDK.

public static class GetLBIPRanges 
{
    public static Task<GetLBIPRangesResult> InvokeAsync(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:

HttpSslTcpInternals List<string>

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

HttpSslTcpInternals []string

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

httpSslTcpInternals List<String>

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

httpSslTcpInternals string[]

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_tcp_internals Sequence[str]

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

httpSslTcpInternals List<String>

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
https://github.com/pulumi/pulumi-gcp
License
Apache-2.0
Notes

This Pulumi package is based on the google-beta Terraform Provider.