Ready to level-up your engineering skills? Join a Pulumi Workshop. Register Now

getIpRanges

Use this data source to get the IP ranges of Cloudflare edge nodes.

Example Usage

using Pulumi;
using Cloudflare = Pulumi.Cloudflare;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
    public MyStack()
    {
        var cloudflare = Output.Create(Cloudflare.GetIpRanges.InvokeAsync());
        var allowCloudflareIngress = new Gcp.Compute.Firewall("allowCloudflareIngress", new Gcp.Compute.FirewallArgs
        {
            Network = "default",
            SourceRanges = cloudflare.Apply(cloudflare => cloudflare.Ipv4CidrBlocks),
            Allows = 
            {
                new Gcp.Compute.Inputs.FirewallAllowArgs
                {
                    Ports = "443",
                    Protocol = "tcp",
                },
            },
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-cloudflare/sdk/v2/go/cloudflare"
    "github.com/pulumi/pulumi-gcp/sdk/v3/go/gcp/compute"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        cloudflare, err := cloudflare.GetIpRanges(ctx, nil, nil)
        if err != nil {
            return err
        }
        _, err = compute.NewFirewall(ctx, "allowCloudflareIngress", &compute.FirewallArgs{
            Network:      pulumi.String("default"),
            SourceRanges: toPulumiStringArray(cloudflare.Ipv4CidrBlocks),
            Allows: compute.FirewallAllowArray{
                &compute.FirewallAllowArgs{
                    Ports:    "443",
                    Protocol: pulumi.String("tcp"),
                },
            },
        })
        if err != nil {
            return err
        }
        return nil
    })
}
func toPulumiStringArray(arr []string) pulumi.StringArray {
    var pulumiArr pulumi.StringArray
    for _, v := range arr {
        pulumiArr = append(pulumiArr, pulumi.String(v))
    }
    return pulumiArr
}
import pulumi
import pulumi_cloudflare as cloudflare
import pulumi_gcp as gcp

cloudflare = cloudflare.get_ip_ranges()
allow_cloudflare_ingress = gcp.compute.Firewall("allowCloudflareIngress",
    network="default",
    source_ranges=cloudflare.ipv4_cidr_blocks,
    allows=[gcp.compute.FirewallAllowArgs(
        ports="443",
        protocol="tcp",
    )])
import * as pulumi from "@pulumi/pulumi";
import * as cloudflare from "@pulumi/cloudflare";
import * as gcp from "@pulumi/gcp";

const cloudflare = cloudflare.getIpRanges({});
const allowCloudflareIngress = new gcp.compute.Firewall("allowCloudflareIngress", {
    network: "default",
    sourceRanges: cloudflare.then(cloudflare => cloudflare.ipv4CidrBlocks),
    allows: [{
        ports: "443",
        protocol: "tcp",
    }],
});

Using getIpRanges

function getIpRanges(opts?: InvokeOptions): Promise<GetIpRangesResult>
def get_ip_ranges(opts: Optional[InvokeOptions] = None) -> GetIpRangesResult
func GetIpRanges(ctx *Context, opts ...InvokeOption) (*GetIpRangesResult, error)

Note: This function is named GetIpRanges in the Go SDK.

public static class GetIpRanges {
    public static Task<GetIpRangesResult> InvokeAsync(InvokeOptions? opts = null)
}

getIpRanges Result

The following output properties are available:

ChinaIpv4CidrBlocks List<string>

The lexically ordered list of only the IPv4 China CIDR blocks.

ChinaIpv6CidrBlocks List<string>

The lexically ordered list of only the IPv6 China CIDR blocks.

CidrBlocks List<string>

The lexically ordered list of all non-China CIDR blocks.

Id string

The provider-assigned unique ID for this managed resource.

Ipv4CidrBlocks List<string>

The lexically ordered list of only the IPv4 CIDR blocks.

Ipv6CidrBlocks List<string>

The lexically ordered list of only the IPv6 CIDR blocks.

ChinaIpv4CidrBlocks []string

The lexically ordered list of only the IPv4 China CIDR blocks.

ChinaIpv6CidrBlocks []string

The lexically ordered list of only the IPv6 China CIDR blocks.

CidrBlocks []string

The lexically ordered list of all non-China CIDR blocks.

Id string

The provider-assigned unique ID for this managed resource.

Ipv4CidrBlocks []string

The lexically ordered list of only the IPv4 CIDR blocks.

Ipv6CidrBlocks []string

The lexically ordered list of only the IPv6 CIDR blocks.

chinaIpv4CidrBlocks string[]

The lexically ordered list of only the IPv4 China CIDR blocks.

chinaIpv6CidrBlocks string[]

The lexically ordered list of only the IPv6 China CIDR blocks.

cidrBlocks string[]

The lexically ordered list of all non-China CIDR blocks.

id string

The provider-assigned unique ID for this managed resource.

ipv4CidrBlocks string[]

The lexically ordered list of only the IPv4 CIDR blocks.

ipv6CidrBlocks string[]

The lexically ordered list of only the IPv6 CIDR blocks.

china_ipv4_cidr_blocks Sequence[str]

The lexically ordered list of only the IPv4 China CIDR blocks.

china_ipv6_cidr_blocks Sequence[str]

The lexically ordered list of only the IPv6 China CIDR blocks.

cidr_blocks Sequence[str]

The lexically ordered list of all non-China CIDR blocks.

id str

The provider-assigned unique ID for this managed resource.

ipv4_cidr_blocks Sequence[str]

The lexically ordered list of only the IPv4 CIDR blocks.

ipv6_cidr_blocks Sequence[str]

The lexically ordered list of only the IPv6 CIDR blocks.

Package Details

Repository
https://github.com/pulumi/pulumi-cloudflare
License
Apache-2.0
Notes
This Pulumi package is based on the cloudflare Terraform Provider.