1. Packages
  2. Cloudflare
  3. API Docs
  4. getZone
Cloudflare v5.24.0 published on Thursday, Mar 28, 2024 by Pulumi

cloudflare.getZone

Explore with Pulumi AI

cloudflare logo
Cloudflare v5.24.0 published on Thursday, Mar 28, 2024 by Pulumi

    Use this data source to look up zone info. This is the singular alternative to cloudflare.getZones.

    Note Cloudflare zone names are not unique. It is possible for multiple accounts to have the same zone created but in different states. If you are using this setup, it is advised to use the account_id attribute on this resource or swap to cloudflare.getZones to further filter the results.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as cloudflare from "@pulumi/cloudflare";
    
    const exampleZone = cloudflare.getZone({
        name: "example.com",
    });
    const exampleRecord = new cloudflare.Record("exampleRecord", {
        zoneId: exampleZone.then(exampleZone => exampleZone.id),
        name: "www",
        value: "203.0.113.1",
        type: "A",
        proxied: true,
    });
    
    import pulumi
    import pulumi_cloudflare as cloudflare
    
    example_zone = cloudflare.get_zone(name="example.com")
    example_record = cloudflare.Record("exampleRecord",
        zone_id=example_zone.id,
        name="www",
        value="203.0.113.1",
        type="A",
        proxied=True)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleZone, err := cloudflare.LookupZone(ctx, &cloudflare.LookupZoneArgs{
    			Name: pulumi.StringRef("example.com"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = cloudflare.NewRecord(ctx, "exampleRecord", &cloudflare.RecordArgs{
    			ZoneId:  pulumi.String(exampleZone.Id),
    			Name:    pulumi.String("www"),
    			Value:   pulumi.String("203.0.113.1"),
    			Type:    pulumi.String("A"),
    			Proxied: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Cloudflare = Pulumi.Cloudflare;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleZone = Cloudflare.GetZone.Invoke(new()
        {
            Name = "example.com",
        });
    
        var exampleRecord = new Cloudflare.Record("exampleRecord", new()
        {
            ZoneId = exampleZone.Apply(getZoneResult => getZoneResult.Id),
            Name = "www",
            Value = "203.0.113.1",
            Type = "A",
            Proxied = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.cloudflare.CloudflareFunctions;
    import com.pulumi.cloudflare.inputs.GetZoneArgs;
    import com.pulumi.cloudflare.Record;
    import com.pulumi.cloudflare.RecordArgs;
    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 exampleZone = CloudflareFunctions.getZone(GetZoneArgs.builder()
                .name("example.com")
                .build());
    
            var exampleRecord = new Record("exampleRecord", RecordArgs.builder()        
                .zoneId(exampleZone.applyValue(getZoneResult -> getZoneResult.id()))
                .name("www")
                .value("203.0.113.1")
                .type("A")
                .proxied(true)
                .build());
    
        }
    }
    
    resources:
      exampleRecord:
        type: cloudflare:Record
        properties:
          zoneId: ${exampleZone.id}
          name: www
          value: 203.0.113.1
          type: A
          proxied: true
    variables:
      exampleZone:
        fn::invoke:
          Function: cloudflare:getZone
          Arguments:
            name: example.com
    

    Using getZone

    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 getZone(args: GetZoneArgs, opts?: InvokeOptions): Promise<GetZoneResult>
    function getZoneOutput(args: GetZoneOutputArgs, opts?: InvokeOptions): Output<GetZoneResult>
    def get_zone(account_id: Optional[str] = None,
                 name: Optional[str] = None,
                 zone_id: Optional[str] = None,
                 opts: Optional[InvokeOptions] = None) -> GetZoneResult
    def get_zone_output(account_id: Optional[pulumi.Input[str]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 zone_id: Optional[pulumi.Input[str]] = None,
                 opts: Optional[InvokeOptions] = None) -> Output[GetZoneResult]
    func LookupZone(ctx *Context, args *LookupZoneArgs, opts ...InvokeOption) (*LookupZoneResult, error)
    func LookupZoneOutput(ctx *Context, args *LookupZoneOutputArgs, opts ...InvokeOption) LookupZoneResultOutput

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

    public static class GetZone 
    {
        public static Task<GetZoneResult> InvokeAsync(GetZoneArgs args, InvokeOptions? opts = null)
        public static Output<GetZoneResult> Invoke(GetZoneInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetZoneResult> getZone(GetZoneArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: cloudflare:index/getZone:getZone
      arguments:
        # arguments dictionary

    The following arguments are supported:

    AccountId string
    The account identifier to target for the resource.
    Name string
    The name of the zone. Must provide only one of zone_id, name.
    ZoneId string
    The zone identifier to target for the resource. Must provide only one of zone_id, name.
    AccountId string
    The account identifier to target for the resource.
    Name string
    The name of the zone. Must provide only one of zone_id, name.
    ZoneId string
    The zone identifier to target for the resource. Must provide only one of zone_id, name.
    accountId String
    The account identifier to target for the resource.
    name String
    The name of the zone. Must provide only one of zone_id, name.
    zoneId String
    The zone identifier to target for the resource. Must provide only one of zone_id, name.
    accountId string
    The account identifier to target for the resource.
    name string
    The name of the zone. Must provide only one of zone_id, name.
    zoneId string
    The zone identifier to target for the resource. Must provide only one of zone_id, name.
    account_id str
    The account identifier to target for the resource.
    name str
    The name of the zone. Must provide only one of zone_id, name.
    zone_id str
    The zone identifier to target for the resource. Must provide only one of zone_id, name.
    accountId String
    The account identifier to target for the resource.
    name String
    The name of the zone. Must provide only one of zone_id, name.
    zoneId String
    The zone identifier to target for the resource. Must provide only one of zone_id, name.

    getZone Result

    The following output properties are available:

    AccountId string
    The account identifier to target for the resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    The name of the zone. Must provide only one of zone_id, name.
    NameServers List<string>
    Cloudflare assigned name servers. This is only populated for zones that use Cloudflare DNS.
    Paused bool
    Whether the zone is paused on Cloudflare.
    Plan string
    The name of the plan associated with the zone.
    Status string
    Status of the zone.
    VanityNameServers List<string>
    List of Vanity Nameservers (if set).
    ZoneId string
    The zone identifier to target for the resource. Must provide only one of zone_id, name.
    AccountId string
    The account identifier to target for the resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    The name of the zone. Must provide only one of zone_id, name.
    NameServers []string
    Cloudflare assigned name servers. This is only populated for zones that use Cloudflare DNS.
    Paused bool
    Whether the zone is paused on Cloudflare.
    Plan string
    The name of the plan associated with the zone.
    Status string
    Status of the zone.
    VanityNameServers []string
    List of Vanity Nameservers (if set).
    ZoneId string
    The zone identifier to target for the resource. Must provide only one of zone_id, name.
    accountId String
    The account identifier to target for the resource.
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    The name of the zone. Must provide only one of zone_id, name.
    nameServers List<String>
    Cloudflare assigned name servers. This is only populated for zones that use Cloudflare DNS.
    paused Boolean
    Whether the zone is paused on Cloudflare.
    plan String
    The name of the plan associated with the zone.
    status String
    Status of the zone.
    vanityNameServers List<String>
    List of Vanity Nameservers (if set).
    zoneId String
    The zone identifier to target for the resource. Must provide only one of zone_id, name.
    accountId string
    The account identifier to target for the resource.
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    The name of the zone. Must provide only one of zone_id, name.
    nameServers string[]
    Cloudflare assigned name servers. This is only populated for zones that use Cloudflare DNS.
    paused boolean
    Whether the zone is paused on Cloudflare.
    plan string
    The name of the plan associated with the zone.
    status string
    Status of the zone.
    vanityNameServers string[]
    List of Vanity Nameservers (if set).
    zoneId string
    The zone identifier to target for the resource. Must provide only one of zone_id, name.
    account_id str
    The account identifier to target for the resource.
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    The name of the zone. Must provide only one of zone_id, name.
    name_servers Sequence[str]
    Cloudflare assigned name servers. This is only populated for zones that use Cloudflare DNS.
    paused bool
    Whether the zone is paused on Cloudflare.
    plan str
    The name of the plan associated with the zone.
    status str
    Status of the zone.
    vanity_name_servers Sequence[str]
    List of Vanity Nameservers (if set).
    zone_id str
    The zone identifier to target for the resource. Must provide only one of zone_id, name.
    accountId String
    The account identifier to target for the resource.
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    The name of the zone. Must provide only one of zone_id, name.
    nameServers List<String>
    Cloudflare assigned name servers. This is only populated for zones that use Cloudflare DNS.
    paused Boolean
    Whether the zone is paused on Cloudflare.
    plan String
    The name of the plan associated with the zone.
    status String
    Status of the zone.
    vanityNameServers List<String>
    List of Vanity Nameservers (if set).
    zoneId String
    The zone identifier to target for the resource. Must provide only one of zone_id, name.

    Package Details

    Repository
    Cloudflare pulumi/pulumi-cloudflare
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the cloudflare Terraform Provider.
    cloudflare logo
    Cloudflare v5.24.0 published on Thursday, Mar 28, 2024 by Pulumi