Module dns

@pulumi/gcp > dns

class ManagedZone

extends CustomResource

A zone is a subtree of the DNS namespace under one administrative responsibility. A ManagedZone is a resource that represents a DNS zone hosted by the Cloud DNS service.

To get more information about ManagedZone, see:

Example Usage - Dns Managed Zone Basic

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
import * as random from "@pulumi/random";

const rnd = new random.RandomId("rnd", {
    byteLength: 4,
});
const example_zone = new gcp.dns.ManagedZone("example-zone", {
    description: "Example DNS zone",
    dnsName: pulumi.interpolate`example-${rnd.hex}.com.`,
    labels: {
        foo: "bar",
    },
});

Example Usage - Dns Managed Zone Private

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const network_1 = new gcp.compute.Network("network-1", {
    autoCreateSubnetworks: false,
});
const network_2 = new gcp.compute.Network("network-2", {
    autoCreateSubnetworks: false,
});
const private_zone = new gcp.dns.ManagedZone("private-zone", {
    description: "Example private DNS zone",
    dnsName: "private.example.com.",
    labels: {
        foo: "bar",
    },
    privateVisibilityConfig: {
        networks: [
            {
                networkUrl: network_1.selfLink,
            },
            {
                networkUrl: network_2.selfLink,
            },
        ],
    },
    visibility: "private",
});

constructor

new ManagedZone(name: string, args: ManagedZoneArgs, opts?: pulumi.CustomResourceOptions)

Create a ManagedZone resource with the given unique name, arguments, and options.

  • name The unique name of the resource.
  • args The arguments to use to populate this resource's properties.
  • opts A bag of options that control this resource's behavior.

method get

public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: ManagedZoneState, opts?: pulumi.CustomResourceOptions): ManagedZone

Get an existing ManagedZone resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

method getProvider

getProvider(moduleMember: string): ProviderResource | undefined

method isInstance

static isInstance(obj: any): boolean

Returns true if the given object is an instance of CustomResource. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.

property description

public description: pulumi.Output<string>;

property dnsName

public dnsName: pulumi.Output<string>;

property forwardingConfig

public forwardingConfig: pulumi.Output<{
    targetNameServers: {
        ipv4Address: undefined | string;
    }[];
} | undefined>;

property id

id: Output<ID>;

id is the provider-assigned unique ID for this managed resource. It is set during deployments and may be missing (undefined) during planning phases.

property labels

public labels: pulumi.Output<{[key: string]: string} | undefined>;

property name

public name: pulumi.Output<string>;

property nameServers

public nameServers: pulumi.Output<string[]>;

property peeringConfig

public peeringConfig: pulumi.Output<{
    targetNetwork: undefined | {
        networkUrl: undefined | string;
    };
} | undefined>;

property privateVisibilityConfig

public privateVisibilityConfig: pulumi.Output<{
    networks: {
        networkUrl: undefined | string;
    }[];
} | undefined>;

property project

public project: pulumi.Output<string>;

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

property urn

urn: Output<URN>;

urn is the stable logical URN used to distinctly address a resource, both before and after deployments.

property visibility

public visibility: pulumi.Output<string | undefined>;

class Policy

extends CustomResource

A policy is a collection of DNS rules applied to one or more Virtual Private Cloud resources.

Warning: This resource is in beta, and should be used with the terraform-provider-google-beta provider. See Provider Versions for more details on beta resources.

To get more information about Policy, see:

constructor

new Policy(name: string, args?: PolicyArgs, opts?: pulumi.CustomResourceOptions)

Create a Policy resource with the given unique name, arguments, and options.

  • name The unique name of the resource.
  • args The arguments to use to populate this resource's properties.
  • opts A bag of options that control this resource's behavior.

method get

public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: PolicyState, opts?: pulumi.CustomResourceOptions): Policy

Get an existing Policy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

method getProvider

getProvider(moduleMember: string): ProviderResource | undefined

method isInstance

static isInstance(obj: any): boolean

Returns true if the given object is an instance of CustomResource. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.

property alternativeNameServerConfig

public alternativeNameServerConfig: pulumi.Output<{
    targetNameServers: {
        ipv4Address: undefined | string;
    }[];
} | undefined>;

property description

public description: pulumi.Output<string | undefined>;

property enableInboundForwarding

public enableInboundForwarding: pulumi.Output<boolean | undefined>;

property enableLogging

public enableLogging: pulumi.Output<boolean | undefined>;

property id

id: Output<ID>;

id is the provider-assigned unique ID for this managed resource. It is set during deployments and may be missing (undefined) during planning phases.

property name

public name: pulumi.Output<string>;

property networks

public networks: pulumi.Output<{
    networkUrl: undefined | string;
}[] | undefined>;

property project

public project: pulumi.Output<string>;

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

property urn

urn: Output<URN>;

urn is the stable logical URN used to distinctly address a resource, both before and after deployments.

class RecordSet

extends CustomResource

Manages a set of DNS records within Google Cloud DNS. For more information see the official documentation and API.

Note: The Google Cloud DNS API requires NS records be present at all times. To accommodate this, when creating NS records, the default records Google automatically creates will be silently overwritten. Also, when destroying NS records, Terraform will not actually remove NS records, but will report that it did.

Example Usage

Binding a DNS name to the ephemeral IP of a new instance:

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const frontendInstance = new gcp.compute.Instance("frontend", {
    bootDisk: {
        initializeParams: {
            image: "debian-cloud/debian-9",
        },
    },
    machineType: "g1-small",
    networkInterfaces: [{
        accessConfigs: [{}],
        network: "default",
    }],
    zone: "us-central1-b",
});
const prod = new gcp.dns.ManagedZone("prod", {
    dnsName: "prod.mydomain.com.",
});
const frontendRecordSet = new gcp.dns.RecordSet("frontend", {
    managedZone: prod.name,
    rrdatas: [frontendInstance.networkInterfaces[0].accessConfig.0.natIp],
    ttl: 300,
    type: "A",
});

Adding an A record

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const prod = new gcp.dns.ManagedZone("prod", {
    dnsName: "prod.mydomain.com.",
});
const recordSet = new gcp.dns.RecordSet("a", {
    managedZone: prod.name,
    rrdatas: ["8.8.8.8"],
    ttl: 300,
    type: "A",
});

Adding an MX record

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const prod = new gcp.dns.ManagedZone("prod", {
    dnsName: "prod.mydomain.com.",
});
const mx = new gcp.dns.RecordSet("mx", {
    managedZone: prod.name,
    rrdatas: [
        "1 aspmx.l.google.com.",
        "5 alt1.aspmx.l.google.com.",
        "5 alt2.aspmx.l.google.com.",
        "10 alt3.aspmx.l.google.com.",
        "10 alt4.aspmx.l.google.com.",
    ],
    ttl: 3600,
    type: "MX",
});

Adding an SPF record

Quotes ("") must be added around your rrdatas for a SPF record. Otherwise rrdatas string gets split on spaces.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const prod = new gcp.dns.ManagedZone("prod", {
    dnsName: "prod.mydomain.com.",
});
const spf = new gcp.dns.RecordSet("spf", {
    managedZone: prod.name,
    rrdatas: ["\"v=spf1 ip4:111.111.111.111 include:backoff.email-example.com -all\""],
    ttl: 300,
    type: "TXT",
});

Adding a CNAME record

The list of rrdatas should only contain a single string corresponding to the Canonical Name intended.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const prod = new gcp.dns.ManagedZone("prod", {
    dnsName: "prod.mydomain.com.",
});
const cname = new gcp.dns.RecordSet("cname", {
    managedZone: prod.name,
    rrdatas: ["frontend.mydomain.com."],
    ttl: 300,
    type: "CNAME",
});

constructor

new RecordSet(name: string, args: RecordSetArgs, opts?: pulumi.CustomResourceOptions)

Create a RecordSet resource with the given unique name, arguments, and options.

  • name The unique name of the resource.
  • args The arguments to use to populate this resource's properties.
  • opts A bag of options that control this resource's behavior.

method get

public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: RecordSetState, opts?: pulumi.CustomResourceOptions): RecordSet

Get an existing RecordSet resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

method getProvider

getProvider(moduleMember: string): ProviderResource | undefined

method isInstance

static isInstance(obj: any): boolean

Returns true if the given object is an instance of CustomResource. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.

property id

id: Output<ID>;

id is the provider-assigned unique ID for this managed resource. It is set during deployments and may be missing (undefined) during planning phases.

property managedZone

public managedZone: pulumi.Output<string>;

The name of the zone in which this record set will reside.

property name

public name: pulumi.Output<string>;

The DNS name this record set will apply to.

property project

public project: pulumi.Output<string>;

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

property rrdatas

public rrdatas: pulumi.Output<string[]>;

The string data for the records in this record set whose meaning depends on the DNS type. For TXT record, if the string data contains spaces, add surrounding \" if you don’t want your string to get split on spaces. To specify a single record value longer than 255 characters such as a TXT record for DKIM, add \"\" inside the Terraform configuration string (e.g. "first255characters\"\"morecharacters").

property ttl

public ttl: pulumi.Output<number>;

The time-to-live of this record set (seconds).

property type

public type: pulumi.Output<string>;

The DNS record set type.

property urn

urn: Output<URN>;

urn is the stable logical URN used to distinctly address a resource, both before and after deployments.

function getManagedZone

getManagedZone(args: GetManagedZoneArgs, opts?: pulumi.InvokeOptions): Promise<GetManagedZoneResult>

Provides access to a zone’s attributes within Google Cloud DNS. For more information see the official documentation and API.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const envDnsZone = pulumi.output(gcp.dns.getManagedZone({
    name: "qa-zone",
}));
const dns = new gcp.dns.RecordSet("dns", {
    managedZone: envDnsZone.name,
    rrdatas: ["test"],
    ttl: 300,
    type: "TXT",
});

interface GetManagedZoneArgs

A collection of arguments for invoking getManagedZone.

property name

name: string;

A unique name for the resource.

property project

project?: undefined | string;

The ID of the project for the Google Cloud DNS zone.

interface GetManagedZoneResult

A collection of values returned by getManagedZone.

property description

description: string;

A textual description field.

property dnsName

dnsName: string;

The fully qualified DNS name of this zone, e.g. terraform.io..

property id

id: string;

id is the provider-assigned unique ID for this managed resource.

property name

name: string;

property nameServers

nameServers: string[];

The list of nameservers that will be authoritative for this domain. Use NS records to redirect from your DNS provider to these names, thus making Google Cloud DNS authoritative for this zone.

property project

project?: undefined | string;

interface ManagedZoneArgs

The set of arguments for constructing a ManagedZone resource.

property description

description?: pulumi.Input<string>;

property dnsName

dnsName: pulumi.Input<string>;

property forwardingConfig

forwardingConfig?: pulumi.Input<{
    targetNameServers: pulumi.Input<pulumi.Input<{
        ipv4Address: pulumi.Input<string>;
    }>[]>;
}>;

property labels

labels?: pulumi.Input<{[key: string]: pulumi.Input<string>}>;

property name

name?: pulumi.Input<string>;

property peeringConfig

peeringConfig?: pulumi.Input<{
    targetNetwork: pulumi.Input<{
        networkUrl: pulumi.Input<string>;
    }>;
}>;

property privateVisibilityConfig

privateVisibilityConfig?: pulumi.Input<{
    networks: pulumi.Input<pulumi.Input<{
        networkUrl: pulumi.Input<string>;
    }>[]>;
}>;

property project

project?: pulumi.Input<string>;

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

property visibility

visibility?: pulumi.Input<string>;

interface ManagedZoneState

Input properties used for looking up and filtering ManagedZone resources.

property description

description?: pulumi.Input<string>;

property dnsName

dnsName?: pulumi.Input<string>;

property forwardingConfig

forwardingConfig?: pulumi.Input<{
    targetNameServers: pulumi.Input<pulumi.Input<{
        ipv4Address: pulumi.Input<string>;
    }>[]>;
}>;

property labels

labels?: pulumi.Input<{[key: string]: pulumi.Input<string>}>;

property name

name?: pulumi.Input<string>;

property nameServers

nameServers?: pulumi.Input<pulumi.Input<string>[]>;

property peeringConfig

peeringConfig?: pulumi.Input<{
    targetNetwork: pulumi.Input<{
        networkUrl: pulumi.Input<string>;
    }>;
}>;

property privateVisibilityConfig

privateVisibilityConfig?: pulumi.Input<{
    networks: pulumi.Input<pulumi.Input<{
        networkUrl: pulumi.Input<string>;
    }>[]>;
}>;

property project

project?: pulumi.Input<string>;

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

property visibility

visibility?: pulumi.Input<string>;

interface PolicyArgs

The set of arguments for constructing a Policy resource.

property alternativeNameServerConfig

alternativeNameServerConfig?: pulumi.Input<{
    targetNameServers: pulumi.Input<pulumi.Input<{
        ipv4Address: pulumi.Input<string>;
    }>[]>;
}>;

property description

description?: pulumi.Input<string>;

property enableInboundForwarding

enableInboundForwarding?: pulumi.Input<boolean>;

property enableLogging

enableLogging?: pulumi.Input<boolean>;

property name

name?: pulumi.Input<string>;

property networks

networks?: pulumi.Input<pulumi.Input<{
    networkUrl: pulumi.Input<string>;
}>[]>;

property project

project?: pulumi.Input<string>;

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

interface PolicyState

Input properties used for looking up and filtering Policy resources.

property alternativeNameServerConfig

alternativeNameServerConfig?: pulumi.Input<{
    targetNameServers: pulumi.Input<pulumi.Input<{
        ipv4Address: pulumi.Input<string>;
    }>[]>;
}>;

property description

description?: pulumi.Input<string>;

property enableInboundForwarding

enableInboundForwarding?: pulumi.Input<boolean>;

property enableLogging

enableLogging?: pulumi.Input<boolean>;

property name

name?: pulumi.Input<string>;

property networks

networks?: pulumi.Input<pulumi.Input<{
    networkUrl: pulumi.Input<string>;
}>[]>;

property project

project?: pulumi.Input<string>;

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

interface RecordSetArgs

The set of arguments for constructing a RecordSet resource.

property managedZone

managedZone: pulumi.Input<string>;

The name of the zone in which this record set will reside.

property name

name?: pulumi.Input<string>;

The DNS name this record set will apply to.

property project

project?: pulumi.Input<string>;

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

property rrdatas

rrdatas: pulumi.Input<pulumi.Input<string>[]>;

The string data for the records in this record set whose meaning depends on the DNS type. For TXT record, if the string data contains spaces, add surrounding \" if you don’t want your string to get split on spaces. To specify a single record value longer than 255 characters such as a TXT record for DKIM, add \"\" inside the Terraform configuration string (e.g. "first255characters\"\"morecharacters").

property ttl

ttl: pulumi.Input<number>;

The time-to-live of this record set (seconds).

property type

type: pulumi.Input<string>;

The DNS record set type.

interface RecordSetState

Input properties used for looking up and filtering RecordSet resources.

property managedZone

managedZone?: pulumi.Input<string>;

The name of the zone in which this record set will reside.

property name

name?: pulumi.Input<string>;

The DNS name this record set will apply to.

property project

project?: pulumi.Input<string>;

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

property rrdatas

rrdatas?: pulumi.Input<pulumi.Input<string>[]>;

The string data for the records in this record set whose meaning depends on the DNS type. For TXT record, if the string data contains spaces, add surrounding \" if you don’t want your string to get split on spaces. To specify a single record value longer than 255 characters such as a TXT record for DKIM, add \"\" inside the Terraform configuration string (e.g. "first255characters\"\"morecharacters").

property ttl

ttl?: pulumi.Input<number>;

The time-to-live of this record set (seconds).

property type

type?: pulumi.Input<string>;

The DNS record set type.