com.pulumi.gcp.dns.kotlin.ResponsePolicyRule.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-gcp-kotlin Show documentation
Show all versions of pulumi-gcp-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.dns.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.dns.kotlin.outputs.ResponsePolicyRuleLocalData
import com.pulumi.gcp.dns.kotlin.outputs.ResponsePolicyRuleLocalData.Companion.toKotlin
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
/**
* Builder for [ResponsePolicyRule].
*/
@PulumiTagMarker
public class ResponsePolicyRuleResourceBuilder internal constructor() {
public var name: String? = null
public var args: ResponsePolicyRuleArgs = ResponsePolicyRuleArgs()
public var opts: CustomResourceOptions = CustomResourceOptions()
/**
* @param name The _unique_ name of the resulting resource.
*/
public fun name(`value`: String) {
this.name = value
}
/**
* @param block The arguments to use to populate this resource's properties.
*/
public suspend fun args(block: suspend ResponsePolicyRuleArgsBuilder.() -> Unit) {
val builder = ResponsePolicyRuleArgsBuilder()
block(builder)
this.args = builder.build()
}
/**
* @param block A bag of options that control this resource's behavior.
*/
public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
}
internal fun build(): ResponsePolicyRule {
val builtJavaResource = com.pulumi.gcp.dns.ResponsePolicyRule(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return ResponsePolicyRule(builtJavaResource)
}
}
/**
* 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 dns_name field with the longest matching suffix.
* ## Example Usage
* ### Dns Response Policy Rule Basic
*
* ```typescript
* 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"],
* }],
* },
* });
* ```
* ```python
* 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=[
* gcp.dns.ResponsePolicyNetworkArgs(
* network_url=network_1.id,
* ),
* gcp.dns.ResponsePolicyNetworkArgs(
* 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=gcp.dns.ResponsePolicyRuleLocalDataArgs(
* local_datas=[gcp.dns.ResponsePolicyRuleLocalDataLocalDataArgs(
* name="dns.example.com.",
* type="A",
* ttl=300,
* rrdatas=["192.0.2.91"],
* )],
* ))
* ```
* ```csharp
* 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",
* },
* },
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/dns"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := compute.NewNetwork(ctx, "network-1", &compute.NetworkArgs{
* Name: pulumi.String("network-1"),
* AutoCreateSubnetworks: pulumi.Bool(false),
* })
* if err != nil {
* return err
* }
* _, err = compute.NewNetwork(ctx, "network-2", &compute.NetworkArgs{
* Name: pulumi.String("network-2"),
* AutoCreateSubnetworks: pulumi.Bool(false),
* })
* if err != nil {
* return err
* }
* _, err = dns.NewResponsePolicy(ctx, "response-policy", &dns.ResponsePolicyArgs{
* ResponsePolicyName: pulumi.String("example-response-policy"),
* Networks: dns.ResponsePolicyNetworkArray{
* &dns.ResponsePolicyNetworkArgs{
* NetworkUrl: network_1.ID(),
* },
* &dns.ResponsePolicyNetworkArgs{
* NetworkUrl: network_2.ID(),
* },
* },
* })
* 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
* })
* }
* ```
* ```java
* 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 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) {
* 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());
* }
* }
* ```
* ```yaml
* 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:
* ```sh
* $ pulumi import gcp:dns/responsePolicyRule:ResponsePolicyRule default projects/{{project}}/responsePolicies/{{response_policy}}/rules/{{rule_name}}
* ```
* ```sh
* $ pulumi import gcp:dns/responsePolicyRule:ResponsePolicyRule default {{project}}/{{response_policy}}/{{rule_name}}
* ```
* ```sh
* $ pulumi import gcp:dns/responsePolicyRule:ResponsePolicyRule default {{response_policy}}/{{rule_name}}
* ```
*/
public class ResponsePolicyRule internal constructor(
override val javaResource: com.pulumi.gcp.dns.ResponsePolicyRule,
) : KotlinCustomResource(javaResource, ResponsePolicyRuleMapper) {
/**
* Answer this query with a behavior rather than DNS data. Acceptable values are 'behaviorUnspecified', and 'bypassResponsePolicy'
*/
public val behavior: Output?
get() = javaResource.behavior().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* The DNS name (wildcard or exact) to apply this rule to. Must be unique within the Response Policy Rule.
*/
public val dnsName: Output
get() = javaResource.dnsName().applyValue({ args0 -> args0 })
/**
* 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.
*/
public val localData: Output?
get() = javaResource.localData().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
toKotlin(args0)
})
}).orElse(null)
})
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
public val project: Output
get() = javaResource.project().applyValue({ args0 -> args0 })
/**
* Identifies the response policy addressed by this request.
* - - -
*/
public val responsePolicy: Output
get() = javaResource.responsePolicy().applyValue({ args0 -> args0 })
/**
* An identifier for this rule. Must be unique with the ResponsePolicy.
*/
public val ruleName: Output
get() = javaResource.ruleName().applyValue({ args0 -> args0 })
}
public object ResponsePolicyRuleMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.gcp.dns.ResponsePolicyRule::class == javaResource::class
override fun map(javaResource: Resource): ResponsePolicyRule = ResponsePolicyRule(
javaResource as
com.pulumi.gcp.dns.ResponsePolicyRule,
)
}
/**
* @see [ResponsePolicyRule].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [ResponsePolicyRule].
*/
public suspend fun responsePolicyRule(
name: String,
block: suspend ResponsePolicyRuleResourceBuilder.() -> Unit,
): ResponsePolicyRule {
val builder = ResponsePolicyRuleResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [ResponsePolicyRule].
* @param name The _unique_ name of the resulting resource.
*/
public fun responsePolicyRule(name: String): ResponsePolicyRule {
val builder = ResponsePolicyRuleResourceBuilder()
builder.name(name)
return builder.build()
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy