All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.azure.appservice.kotlin.StaticSiteCustomDomain.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azure.appservice.kotlin

import com.pulumi.core.Output
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 [StaticSiteCustomDomain].
 */
@PulumiTagMarker
public class StaticSiteCustomDomainResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: StaticSiteCustomDomainArgs = StaticSiteCustomDomainArgs()

    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 StaticSiteCustomDomainArgsBuilder.() -> Unit) {
        val builder = StaticSiteCustomDomainArgsBuilder()
        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(): StaticSiteCustomDomain {
        val builtJavaResource =
            com.pulumi.azure.appservice.StaticSiteCustomDomain(
                this.name,
                this.args.toJava(),
                this.opts.toJava(),
            )
        return StaticSiteCustomDomain(builtJavaResource)
    }
}

/**
 * ## Example Usage
 * ### CNAME validation
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * const exampleStaticSite = new azure.appservice.StaticSite("example", {
 *     name: "example",
 *     resourceGroupName: example.name,
 *     location: example.location,
 * });
 * const exampleCNameRecord = new azure.dns.CNameRecord("example", {
 *     name: "my-domain",
 *     zoneName: "contoso.com",
 *     resourceGroupName: example.name,
 *     ttl: 300,
 *     record: exampleStaticSite.defaultHostName,
 * });
 * const exampleStaticSiteCustomDomain = new azure.appservice.StaticSiteCustomDomain("example", {
 *     staticSiteId: exampleStaticSite.id,
 *     domainName: pulumi.interpolate`${exampleCNameRecord.name}.${exampleCNameRecord.zoneName}`,
 *     validationType: "cname-delegation",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * example_static_site = azure.appservice.StaticSite("example",
 *     name="example",
 *     resource_group_name=example.name,
 *     location=example.location)
 * example_c_name_record = azure.dns.CNameRecord("example",
 *     name="my-domain",
 *     zone_name="contoso.com",
 *     resource_group_name=example.name,
 *     ttl=300,
 *     record=example_static_site.default_host_name)
 * example_static_site_custom_domain = azure.appservice.StaticSiteCustomDomain("example",
 *     static_site_id=example_static_site.id,
 *     domain_name=pulumi.Output.all(example_c_name_record.name, example_c_name_record.zone_name).apply(lambda name, zone_name: f"{name}.{zone_name}"),
 *     validation_type="cname-delegation")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Azure.Core.ResourceGroup("example", new()
 *     {
 *         Name = "example-resources",
 *         Location = "West Europe",
 *     });
 *     var exampleStaticSite = new Azure.AppService.StaticSite("example", new()
 *     {
 *         Name = "example",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *     });
 *     var exampleCNameRecord = new Azure.Dns.CNameRecord("example", new()
 *     {
 *         Name = "my-domain",
 *         ZoneName = "contoso.com",
 *         ResourceGroupName = example.Name,
 *         Ttl = 300,
 *         Record = exampleStaticSite.DefaultHostName,
 *     });
 *     var exampleStaticSiteCustomDomain = new Azure.AppService.StaticSiteCustomDomain("example", new()
 *     {
 *         StaticSiteId = exampleStaticSite.Id,
 *         DomainName = Output.Tuple(exampleCNameRecord.Name, exampleCNameRecord.ZoneName).Apply(values =>
 *         {
 *             var name = values.Item1;
 *             var zoneName = values.Item2;
 *             return $"{name}.{zoneName}";
 *         }),
 *         ValidationType = "cname-delegation",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"fmt"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/appservice"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/dns"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("example-resources"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleStaticSite, err := appservice.NewStaticSite(ctx, "example", &appservice.StaticSiteArgs{
 * 			Name:              pulumi.String("example"),
 * 			ResourceGroupName: example.Name,
 * 			Location:          example.Location,
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleCNameRecord, err := dns.NewCNameRecord(ctx, "example", &dns.CNameRecordArgs{
 * 			Name:              pulumi.String("my-domain"),
 * 			ZoneName:          pulumi.String("contoso.com"),
 * 			ResourceGroupName: example.Name,
 * 			Ttl:               pulumi.Int(300),
 * 			Record:            exampleStaticSite.DefaultHostName,
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = appservice.NewStaticSiteCustomDomain(ctx, "example", &appservice.StaticSiteCustomDomainArgs{
 * 			StaticSiteId: exampleStaticSite.ID(),
 * 			DomainName: pulumi.All(exampleCNameRecord.Name, exampleCNameRecord.ZoneName).ApplyT(func(_args []interface{}) (string, error) {
 * 				name := _args[0].(string)
 * 				zoneName := _args[1].(string)
 * 				return fmt.Sprintf("%v.%v", name, zoneName), nil
 * 			}).(pulumi.StringOutput),
 * 			ValidationType: pulumi.String("cname-delegation"),
 * 		})
 * 		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.azure.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.appservice.StaticSite;
 * import com.pulumi.azure.appservice.StaticSiteArgs;
 * import com.pulumi.azure.dns.CNameRecord;
 * import com.pulumi.azure.dns.CNameRecordArgs;
 * import com.pulumi.azure.appservice.StaticSiteCustomDomain;
 * import com.pulumi.azure.appservice.StaticSiteCustomDomainArgs;
 * 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 example = new ResourceGroup("example", ResourceGroupArgs.builder()
 *             .name("example-resources")
 *             .location("West Europe")
 *             .build());
 *         var exampleStaticSite = new StaticSite("exampleStaticSite", StaticSiteArgs.builder()
 *             .name("example")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .build());
 *         var exampleCNameRecord = new CNameRecord("exampleCNameRecord", CNameRecordArgs.builder()
 *             .name("my-domain")
 *             .zoneName("contoso.com")
 *             .resourceGroupName(example.name())
 *             .ttl(300)
 *             .record(exampleStaticSite.defaultHostName())
 *             .build());
 *         var exampleStaticSiteCustomDomain = new StaticSiteCustomDomain("exampleStaticSiteCustomDomain", StaticSiteCustomDomainArgs.builder()
 *             .staticSiteId(exampleStaticSite.id())
 *             .domainName(Output.tuple(exampleCNameRecord.name(), exampleCNameRecord.zoneName()).applyValue(values -> {
 *                 var name = values.t1;
 *                 var zoneName = values.t2;
 *                 return String.format("%s.%s", name,zoneName);
 *             }))
 *             .validationType("cname-delegation")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleStaticSite:
 *     type: azure:appservice:StaticSite
 *     name: example
 *     properties:
 *       name: example
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *   exampleCNameRecord:
 *     type: azure:dns:CNameRecord
 *     name: example
 *     properties:
 *       name: my-domain
 *       zoneName: contoso.com
 *       resourceGroupName: ${example.name}
 *       ttl: 300
 *       record: ${exampleStaticSite.defaultHostName}
 *   exampleStaticSiteCustomDomain:
 *     type: azure:appservice:StaticSiteCustomDomain
 *     name: example
 *     properties:
 *       staticSiteId: ${exampleStaticSite.id}
 *       domainName: ${exampleCNameRecord.name}.${exampleCNameRecord.zoneName}
 *       validationType: cname-delegation
 * ```
 * 
 * ### TXT validation
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * const exampleStaticSite = new azure.appservice.StaticSite("example", {
 *     name: "example",
 *     resourceGroupName: example.name,
 *     location: example.location,
 * });
 * const exampleStaticSiteCustomDomain = new azure.appservice.StaticSiteCustomDomain("example", {
 *     staticSiteId: exampleStaticSite.id,
 *     domainName: "my-domain.contoso.com",
 *     validationType: "dns-txt-token",
 * });
 * const exampleTxtRecord = new azure.dns.TxtRecord("example", {
 *     name: "_dnsauth.my-domain",
 *     zoneName: "contoso.com",
 *     resourceGroupName: example.name,
 *     ttl: 300,
 *     records: [{
 *         value: exampleStaticSiteCustomDomain.validationToken,
 *     }],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * example_static_site = azure.appservice.StaticSite("example",
 *     name="example",
 *     resource_group_name=example.name,
 *     location=example.location)
 * example_static_site_custom_domain = azure.appservice.StaticSiteCustomDomain("example",
 *     static_site_id=example_static_site.id,
 *     domain_name="my-domain.contoso.com",
 *     validation_type="dns-txt-token")
 * example_txt_record = azure.dns.TxtRecord("example",
 *     name="_dnsauth.my-domain",
 *     zone_name="contoso.com",
 *     resource_group_name=example.name,
 *     ttl=300,
 *     records=[{
 *         "value": example_static_site_custom_domain.validation_token,
 *     }])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Azure.Core.ResourceGroup("example", new()
 *     {
 *         Name = "example-resources",
 *         Location = "West Europe",
 *     });
 *     var exampleStaticSite = new Azure.AppService.StaticSite("example", new()
 *     {
 *         Name = "example",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *     });
 *     var exampleStaticSiteCustomDomain = new Azure.AppService.StaticSiteCustomDomain("example", new()
 *     {
 *         StaticSiteId = exampleStaticSite.Id,
 *         DomainName = "my-domain.contoso.com",
 *         ValidationType = "dns-txt-token",
 *     });
 *     var exampleTxtRecord = new Azure.Dns.TxtRecord("example", new()
 *     {
 *         Name = "_dnsauth.my-domain",
 *         ZoneName = "contoso.com",
 *         ResourceGroupName = example.Name,
 *         Ttl = 300,
 *         Records = new[]
 *         {
 *             new Azure.Dns.Inputs.TxtRecordRecordArgs
 *             {
 *                 Value = exampleStaticSiteCustomDomain.ValidationToken,
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/appservice"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/dns"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("example-resources"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleStaticSite, err := appservice.NewStaticSite(ctx, "example", &appservice.StaticSiteArgs{
 * 			Name:              pulumi.String("example"),
 * 			ResourceGroupName: example.Name,
 * 			Location:          example.Location,
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleStaticSiteCustomDomain, err := appservice.NewStaticSiteCustomDomain(ctx, "example", &appservice.StaticSiteCustomDomainArgs{
 * 			StaticSiteId:   exampleStaticSite.ID(),
 * 			DomainName:     pulumi.String("my-domain.contoso.com"),
 * 			ValidationType: pulumi.String("dns-txt-token"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = dns.NewTxtRecord(ctx, "example", &dns.TxtRecordArgs{
 * 			Name:              pulumi.String("_dnsauth.my-domain"),
 * 			ZoneName:          pulumi.String("contoso.com"),
 * 			ResourceGroupName: example.Name,
 * 			Ttl:               pulumi.Int(300),
 * 			Records: dns.TxtRecordRecordArray{
 * 				&dns.TxtRecordRecordArgs{
 * 					Value: exampleStaticSiteCustomDomain.ValidationToken,
 * 				},
 * 			},
 * 		})
 * 		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.azure.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.appservice.StaticSite;
 * import com.pulumi.azure.appservice.StaticSiteArgs;
 * import com.pulumi.azure.appservice.StaticSiteCustomDomain;
 * import com.pulumi.azure.appservice.StaticSiteCustomDomainArgs;
 * import com.pulumi.azure.dns.TxtRecord;
 * import com.pulumi.azure.dns.TxtRecordArgs;
 * import com.pulumi.azure.dns.inputs.TxtRecordRecordArgs;
 * 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 example = new ResourceGroup("example", ResourceGroupArgs.builder()
 *             .name("example-resources")
 *             .location("West Europe")
 *             .build());
 *         var exampleStaticSite = new StaticSite("exampleStaticSite", StaticSiteArgs.builder()
 *             .name("example")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .build());
 *         var exampleStaticSiteCustomDomain = new StaticSiteCustomDomain("exampleStaticSiteCustomDomain", StaticSiteCustomDomainArgs.builder()
 *             .staticSiteId(exampleStaticSite.id())
 *             .domainName("my-domain.contoso.com")
 *             .validationType("dns-txt-token")
 *             .build());
 *         var exampleTxtRecord = new TxtRecord("exampleTxtRecord", TxtRecordArgs.builder()
 *             .name("_dnsauth.my-domain")
 *             .zoneName("contoso.com")
 *             .resourceGroupName(example.name())
 *             .ttl(300)
 *             .records(TxtRecordRecordArgs.builder()
 *                 .value(exampleStaticSiteCustomDomain.validationToken())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleStaticSite:
 *     type: azure:appservice:StaticSite
 *     name: example
 *     properties:
 *       name: example
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *   exampleStaticSiteCustomDomain:
 *     type: azure:appservice:StaticSiteCustomDomain
 *     name: example
 *     properties:
 *       staticSiteId: ${exampleStaticSite.id}
 *       domainName: my-domain.contoso.com
 *       validationType: dns-txt-token
 *   exampleTxtRecord:
 *     type: azure:dns:TxtRecord
 *     name: example
 *     properties:
 *       name: _dnsauth.my-domain
 *       zoneName: contoso.com
 *       resourceGroupName: ${example.name}
 *       ttl: 300
 *       records:
 *         - value: ${exampleStaticSiteCustomDomain.validationToken}
 * ```
 * 
 * ## Import
 * Static Site Custom Domains can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:appservice/staticSiteCustomDomain:StaticSiteCustomDomain example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Web/staticSites/my-static-site1/customDomains/name.contoso.com
 * ```
 */
public class StaticSiteCustomDomain internal constructor(
    override val javaResource: com.pulumi.azure.appservice.StaticSiteCustomDomain,
) : KotlinCustomResource(javaResource, StaticSiteCustomDomainMapper) {
    /**
     * The Domain Name which should be associated with this Static Site. Changing this forces a new Static Site Custom Domain to be created.
     */
    public val domainName: Output
        get() = javaResource.domainName().applyValue({ args0 -> args0 })

    /**
     * The ID of the Static Site. Changing this forces a new Static Site Custom Domain to be created.
     */
    public val staticSiteId: Output
        get() = javaResource.staticSiteId().applyValue({ args0 -> args0 })

    /**
     * Token to be used with `dns-txt-token` validation.
     */
    public val validationToken: Output
        get() = javaResource.validationToken().applyValue({ args0 -> args0 })

    /**
     * One of `cname-delegation` or `dns-txt-token`. Changing this forces a new Static Site Custom Domain to be created.
     */
    public val validationType: Output?
        get() = javaResource.validationType().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })
}

public object StaticSiteCustomDomainMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.appservice.StaticSiteCustomDomain::class == javaResource::class

    override fun map(javaResource: Resource): StaticSiteCustomDomain =
        StaticSiteCustomDomain(javaResource as com.pulumi.azure.appservice.StaticSiteCustomDomain)
}

/**
 * @see [StaticSiteCustomDomain].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [StaticSiteCustomDomain].
 */
public suspend fun staticSiteCustomDomain(
    name: String,
    block: suspend StaticSiteCustomDomainResourceBuilder.() -> Unit,
): StaticSiteCustomDomain {
    val builder = StaticSiteCustomDomainResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [StaticSiteCustomDomain].
 * @param name The _unique_ name of the resulting resource.
 */
public fun staticSiteCustomDomain(name: String): StaticSiteCustomDomain {
    val builder = StaticSiteCustomDomainResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy