ResponsePolicyRule class
A Response Policy Rule is a selector that applies its behavior to queries that match the selector. Selectors are DNS names, which may be wildcards or exact matches. Each DNS query subject to a Response Policy matches at most one ResponsePolicyRule, as identified by the dnsName field with the longest matching suffix.
Example Usage
Dns Response Policy Rule Basic
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const network_1 = new gcp.compute.Network("network-1", {
name: "network-1",
autoCreateSubnetworks: false,
});
const network_2 = new gcp.compute.Network("network-2", {
name: "network-2",
autoCreateSubnetworks: false,
});
const response_policy = new gcp.dns.ResponsePolicy("response-policy", {
responsePolicyName: "example-response-policy",
networks: [
{
networkUrl: network_1.id,
},
{
networkUrl: network_2.id,
},
],
});
const example_response_policy_rule = new gcp.dns.ResponsePolicyRule("example-response-policy-rule", {
responsePolicy: response_policy.responsePolicyName,
ruleName: "example-rule",
dnsName: "dns.example.com.",
localData: {
localDatas: [{
name: "dns.example.com.",
type: "A",
ttl: 300,
rrdatas: ["192.0.2.91"],
}],
},
});
import pulumi
import pulumi_gcp as gcp
network_1 = gcp.compute.Network("network-1",
name="network-1",
auto_create_subnetworks=False)
network_2 = gcp.compute.Network("network-2",
name="network-2",
auto_create_subnetworks=False)
response_policy = gcp.dns.ResponsePolicy("response-policy",
response_policy_name="example-response-policy",
networks=[
{
"network_url": network_1.id,
},
{
"network_url": network_2.id,
},
])
example_response_policy_rule = gcp.dns.ResponsePolicyRule("example-response-policy-rule",
response_policy=response_policy.response_policy_name,
rule_name="example-rule",
dns_name="dns.example.com.",
local_data={
"local_datas": [{
"name": "dns.example.com.",
"type": "A",
"ttl": 300,
"rrdatas": ["192.0.2.91"],
}],
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var network_1 = new Gcp.Compute.Network("network-1", new()
{
Name = "network-1",
AutoCreateSubnetworks = false,
});
var network_2 = new Gcp.Compute.Network("network-2", new()
{
Name = "network-2",
AutoCreateSubnetworks = false,
});
var response_policy = new Gcp.Dns.ResponsePolicy("response-policy", new()
{
ResponsePolicyName = "example-response-policy",
Networks = new[]
{
new Gcp.Dns.Inputs.ResponsePolicyNetworkArgs
{
NetworkUrl = network_1.Id,
},
new Gcp.Dns.Inputs.ResponsePolicyNetworkArgs
{
NetworkUrl = network_2.Id,
},
},
});
var example_response_policy_rule = new Gcp.Dns.ResponsePolicyRule("example-response-policy-rule", new()
{
ResponsePolicy = response_policy.ResponsePolicyName,
RuleName = "example-rule",
DnsName = "dns.example.com.",
LocalData = new Gcp.Dns.Inputs.ResponsePolicyRuleLocalDataArgs
{
LocalDatas = new[]
{
new Gcp.Dns.Inputs.ResponsePolicyRuleLocalDataLocalDataArgs
{
Name = "dns.example.com.",
Type = "A",
Ttl = 300,
Rrdatas = new[]
{
"192.0.2.91",
},
},
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/dns"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
network_1, err := compute.NewNetwork(ctx, "network-1", &compute.NetworkArgs{
Name: pulumi.String("network-1"),
AutoCreateSubnetworks: pulumi.Bool(false),
})
if err != nil {
return err
}
network_2, err := compute.NewNetwork(ctx, "network-2", &compute.NetworkArgs{
Name: pulumi.String("network-2"),
AutoCreateSubnetworks: pulumi.Bool(false),
})
if err != nil {
return err
}
response_policy, err := dns.NewResponsePolicy(ctx, "response-policy", &dns.ResponsePolicyArgs{
ResponsePolicyName: pulumi.String("example-response-policy"),
Networks: dns.ResponsePolicyNetworkArray{
&dns.ResponsePolicyNetworkArgs{
NetworkUrl: network_1.ID().ToIDOutput().ToStringOutput(),
},
&dns.ResponsePolicyNetworkArgs{
NetworkUrl: network_2.ID().ToIDOutput().ToStringOutput(),
},
},
})
if err != nil {
return err
}
_, err = dns.NewResponsePolicyRule(ctx, "example-response-policy-rule", &dns.ResponsePolicyRuleArgs{
ResponsePolicy: response_policy.ResponsePolicyName,
RuleName: pulumi.String("example-rule"),
DnsName: pulumi.String("dns.example.com."),
LocalData: &dns.ResponsePolicyRuleLocalDataArgs{
LocalDatas: dns.ResponsePolicyRuleLocalDataLocalDataArray{
&dns.ResponsePolicyRuleLocalDataLocalDataArgs{
Name: pulumi.String("dns.example.com."),
Type: pulumi.String("A"),
Ttl: pulumi.Int(300),
Rrdatas: pulumi.StringArray{
pulumi.String("192.0.2.91"),
},
},
},
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_compute_network" "network-1" {
name = "network-1"
auto_create_subnetworks = false
}
resource "gcp_compute_network" "network-2" {
name = "network-2"
auto_create_subnetworks = false
}
resource "gcp_dns_responsepolicy" "response-policy" {
response_policy_name = "example-response-policy"
networks {
network_url = gcp_compute_network.network-1.id
}
networks {
network_url = gcp_compute_network.network-2.id
}
}
resource "gcp_dns_responsepolicyrule" "example-response-policy-rule" {
response_policy = gcp_dns_responsepolicy.response-policy.response_policy_name
rule_name = "example-rule"
dns_name = "dns.example.com."
local_data = {
local_datas = [{
"name" = "dns.example.com."
"type" = "A"
"ttl" = 300
"rrdatas" = ["192.0.2.91"]
}]
}
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.Network;
import com.pulumi.gcp.compute.NetworkArgs;
import com.pulumi.gcp.dns.ResponsePolicy;
import com.pulumi.gcp.dns.ResponsePolicyArgs;
import com.pulumi.gcp.dns.inputs.ResponsePolicyNetworkArgs;
import com.pulumi.gcp.dns.ResponsePolicyRule;
import com.pulumi.gcp.dns.ResponsePolicyRuleArgs;
import com.pulumi.gcp.dns.inputs.ResponsePolicyRuleLocalDataArgs;
import com.pulumi.gcp.dns.inputs.ResponsePolicyRuleLocalDataLocalDataArgs;
import java.util.ArrayList;
import java.util.Arrays;
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) {
var network_1 = new Network("network-1", NetworkArgs.builder()
.name("network-1")
.autoCreateSubnetworks(false)
.build());
var network_2 = new Network("network-2", NetworkArgs.builder()
.name("network-2")
.autoCreateSubnetworks(false)
.build());
var response_policy = new ResponsePolicy("response-policy", ResponsePolicyArgs.builder()
.responsePolicyName("example-response-policy")
.networks(
ResponsePolicyNetworkArgs.builder()
.networkUrl(network_1.id())
.build(),
ResponsePolicyNetworkArgs.builder()
.networkUrl(network_2.id())
.build())
.build());
var example_response_policy_rule = new ResponsePolicyRule("example-response-policy-rule", ResponsePolicyRuleArgs.builder()
.responsePolicy(response_policy.responsePolicyName())
.ruleName("example-rule")
.dnsName("dns.example.com.")
.localData(ResponsePolicyRuleLocalDataArgs.builder()
.localDatas(ResponsePolicyRuleLocalDataLocalDataArgs.builder()
.name("dns.example.com.")
.type("A")
.ttl(300)
.rrdatas("192.0.2.91")
.build())
.build())
.build());
}
}
resources:
network-1:
type: gcp:compute:Network
properties:
name: network-1
autoCreateSubnetworks: false
network-2:
type: gcp:compute:Network
properties:
name: network-2
autoCreateSubnetworks: false
response-policy:
type: gcp:dns:ResponsePolicy
properties:
responsePolicyName: example-response-policy
networks:
- networkUrl: ${["network-1"].id}
- networkUrl: ${["network-2"].id}
example-response-policy-rule:
type: gcp:dns:ResponsePolicyRule
properties:
responsePolicy: ${["response-policy"].responsePolicyName}
ruleName: example-rule
dnsName: dns.example.com.
localData:
localDatas:
- name: dns.example.com.
type: A
ttl: 300
rrdatas:
- 192.0.2.91
Import
ResponsePolicyRule can be imported using any of these accepted formats:
projects/{{project}}/responsePolicies/{{response_policy}}/rules/{{rule_name}}{{project}}/{{response_policy}}/{{rule_name}}{{response_policy}}/{{rule_name}}
When using the pulumi import command, ResponsePolicyRule can be imported using one of the formats above. For example:
$ pulumi import gcp:dns/responsePolicyRule:ResponsePolicyRule default projects/{{project}}/responsePolicies/{{response_policy}}/rules/{{rule_name}}
$ pulumi import gcp:dns/responsePolicyRule:ResponsePolicyRule default {{project}}/{{response_policy}}/{{rule_name}}
$ pulumi import gcp:dns/responsePolicyRule:ResponsePolicyRule default {{response_policy}}/{{rule_name}}
Constructors
- ResponsePolicyRule(String name, {ResponsePolicyRuleArgs? args, CustomResourceOptions? options})
-
Creates a new ResponsePolicyRule.
nameThe Pulumi resource name.argsArguments used to configure this ResponsePolicyRule. The set of arguments for ResponsePolicyRule.optionsResource options controlling this resource's behavior. - ResponsePolicyRule.reference(String urn)
- Creates a typed reference to an existing ResponsePolicyRule resource.
Properties
-
behavior
↔ Output<
String?> -
(Optional, Beta)
Answer this query with a behavior rather than DNS data. Acceptable values are 'behaviorUnspecified', and 'bypassResponsePolicy'
latefinal
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
deletionPolicy
↔ Output<
String> -
Whether Terraform will be prevented from destroying the resource. Defaults to DELETE.
When a 'terraform destroy' or 'pulumi up' would delete the resource,
the command will fail if this field is set to "PREVENT" in Terraform state.
When set to "ABANDON", the command will remove the resource from Terraform
management without updating or deleting the resource in the API.
When set to "DELETE", deleting the resource is allowed.
latefinal
-
dnsName
↔ Output<
String> -
The DNS name (wildcard or exact) to apply this rule to. Must be unique within the Response Policy Rule.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
localData
↔ Output<
ResponsePolicyRuleLocalData?> -
Answer this query directly with DNS data. These ResourceRecordSets override any other DNS behavior for the matched name;
in particular they override private zones, the public internet, and GCP internal DNS. No SOA nor NS types are allowed.
Structure is documented below.
latefinal
-
project
↔ Output<
String> -
The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
-
responsePolicy
↔ Output<
String> -
Identifies the response policy addressed by this request.
latefinal
-
ruleName
↔ Output<
String> -
An identifier for this rule. Must be unique with the ResponsePolicy.
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {ResponsePolicyRuleState? state, CustomResourceOptions? options}) → ResponsePolicyRule -
Gets an existing ResponsePolicyRule resource's state with the given
nameandid.