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

com.pulumi.gcp.cloudrun.kotlin.DomainMapping.kt Maven / Gradle / Ivy

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

package com.pulumi.gcp.cloudrun.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.cloudrun.kotlin.outputs.DomainMappingMetadata
import com.pulumi.gcp.cloudrun.kotlin.outputs.DomainMappingSpec
import com.pulumi.gcp.cloudrun.kotlin.outputs.DomainMappingStatus
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
import kotlin.collections.List
import com.pulumi.gcp.cloudrun.kotlin.outputs.DomainMappingMetadata.Companion.toKotlin as domainMappingMetadataToKotlin
import com.pulumi.gcp.cloudrun.kotlin.outputs.DomainMappingSpec.Companion.toKotlin as domainMappingSpecToKotlin
import com.pulumi.gcp.cloudrun.kotlin.outputs.DomainMappingStatus.Companion.toKotlin as domainMappingStatusToKotlin

/**
 * Builder for [DomainMapping].
 */
@PulumiTagMarker
public class DomainMappingResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: DomainMappingArgs = DomainMappingArgs()

    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 DomainMappingArgsBuilder.() -> Unit) {
        val builder = DomainMappingArgsBuilder()
        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(): DomainMapping {
        val builtJavaResource = com.pulumi.gcp.cloudrun.DomainMapping(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return DomainMapping(builtJavaResource)
    }
}

/**
 * Resource to hold the state and status of a user's domain mapping.
 * To get more information about DomainMapping, see:
 * * [API documentation](https://cloud.google.com/run/docs/reference/rest/v1/projects.locations.domainmappings)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/run/docs/mapping-custom-domains)
 * ## Example Usage
 * ### Cloud Run Domain Mapping Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const _default = new gcp.cloudrun.Service("default", {
 *     name: "cloudrun-srv",
 *     location: "us-central1",
 *     metadata: {
 *         namespace: "my-project-name",
 *     },
 *     template: {
 *         spec: {
 *             containers: [{
 *                 image: "us-docker.pkg.dev/cloudrun/container/hello",
 *             }],
 *         },
 *     },
 * });
 * const defaultDomainMapping = new gcp.cloudrun.DomainMapping("default", {
 *     location: "us-central1",
 *     name: "verified-domain.com",
 *     metadata: {
 *         namespace: "my-project-name",
 *     },
 *     spec: {
 *         routeName: _default.name,
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * default = gcp.cloudrun.Service("default",
 *     name="cloudrun-srv",
 *     location="us-central1",
 *     metadata={
 *         "namespace": "my-project-name",
 *     },
 *     template={
 *         "spec": {
 *             "containers": [{
 *                 "image": "us-docker.pkg.dev/cloudrun/container/hello",
 *             }],
 *         },
 *     })
 * default_domain_mapping = gcp.cloudrun.DomainMapping("default",
 *     location="us-central1",
 *     name="verified-domain.com",
 *     metadata={
 *         "namespace": "my-project-name",
 *     },
 *     spec={
 *         "route_name": default.name,
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var @default = new Gcp.CloudRun.Service("default", new()
 *     {
 *         Name = "cloudrun-srv",
 *         Location = "us-central1",
 *         Metadata = new Gcp.CloudRun.Inputs.ServiceMetadataArgs
 *         {
 *             Namespace = "my-project-name",
 *         },
 *         Template = new Gcp.CloudRun.Inputs.ServiceTemplateArgs
 *         {
 *             Spec = new Gcp.CloudRun.Inputs.ServiceTemplateSpecArgs
 *             {
 *                 Containers = new[]
 *                 {
 *                     new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerArgs
 *                     {
 *                         Image = "us-docker.pkg.dev/cloudrun/container/hello",
 *                     },
 *                 },
 *             },
 *         },
 *     });
 *     var defaultDomainMapping = new Gcp.CloudRun.DomainMapping("default", new()
 *     {
 *         Location = "us-central1",
 *         Name = "verified-domain.com",
 *         Metadata = new Gcp.CloudRun.Inputs.DomainMappingMetadataArgs
 *         {
 *             Namespace = "my-project-name",
 *         },
 *         Spec = new Gcp.CloudRun.Inputs.DomainMappingSpecArgs
 *         {
 *             RouteName = @default.Name,
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/cloudrun"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := cloudrun.NewService(ctx, "default", &cloudrun.ServiceArgs{
 * 			Name:     pulumi.String("cloudrun-srv"),
 * 			Location: pulumi.String("us-central1"),
 * 			Metadata: &cloudrun.ServiceMetadataArgs{
 * 				Namespace: pulumi.String("my-project-name"),
 * 			},
 * 			Template: &cloudrun.ServiceTemplateArgs{
 * 				Spec: &cloudrun.ServiceTemplateSpecArgs{
 * 					Containers: cloudrun.ServiceTemplateSpecContainerArray{
 * 						&cloudrun.ServiceTemplateSpecContainerArgs{
 * 							Image: pulumi.String("us-docker.pkg.dev/cloudrun/container/hello"),
 * 						},
 * 					},
 * 				},
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = cloudrun.NewDomainMapping(ctx, "default", &cloudrun.DomainMappingArgs{
 * 			Location: pulumi.String("us-central1"),
 * 			Name:     pulumi.String("verified-domain.com"),
 * 			Metadata: &cloudrun.DomainMappingMetadataArgs{
 * 				Namespace: pulumi.String("my-project-name"),
 * 			},
 * 			Spec: &cloudrun.DomainMappingSpecArgs{
 * 				RouteName: _default.Name,
 * 			},
 * 		})
 * 		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.cloudrun.Service;
 * import com.pulumi.gcp.cloudrun.ServiceArgs;
 * import com.pulumi.gcp.cloudrun.inputs.ServiceMetadataArgs;
 * import com.pulumi.gcp.cloudrun.inputs.ServiceTemplateArgs;
 * import com.pulumi.gcp.cloudrun.inputs.ServiceTemplateSpecArgs;
 * import com.pulumi.gcp.cloudrun.DomainMapping;
 * import com.pulumi.gcp.cloudrun.DomainMappingArgs;
 * import com.pulumi.gcp.cloudrun.inputs.DomainMappingMetadataArgs;
 * import com.pulumi.gcp.cloudrun.inputs.DomainMappingSpecArgs;
 * 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 default_ = new Service("default", ServiceArgs.builder()
 *             .name("cloudrun-srv")
 *             .location("us-central1")
 *             .metadata(ServiceMetadataArgs.builder()
 *                 .namespace("my-project-name")
 *                 .build())
 *             .template(ServiceTemplateArgs.builder()
 *                 .spec(ServiceTemplateSpecArgs.builder()
 *                     .containers(ServiceTemplateSpecContainerArgs.builder()
 *                         .image("us-docker.pkg.dev/cloudrun/container/hello")
 *                         .build())
 *                     .build())
 *                 .build())
 *             .build());
 *         var defaultDomainMapping = new DomainMapping("defaultDomainMapping", DomainMappingArgs.builder()
 *             .location("us-central1")
 *             .name("verified-domain.com")
 *             .metadata(DomainMappingMetadataArgs.builder()
 *                 .namespace("my-project-name")
 *                 .build())
 *             .spec(DomainMappingSpecArgs.builder()
 *                 .routeName(default_.name())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   default:
 *     type: gcp:cloudrun:Service
 *     properties:
 *       name: cloudrun-srv
 *       location: us-central1
 *       metadata:
 *         namespace: my-project-name
 *       template:
 *         spec:
 *           containers:
 *             - image: us-docker.pkg.dev/cloudrun/container/hello
 *   defaultDomainMapping:
 *     type: gcp:cloudrun:DomainMapping
 *     name: default
 *     properties:
 *       location: us-central1
 *       name: verified-domain.com
 *       metadata:
 *         namespace: my-project-name
 *       spec:
 *         routeName: ${default.name}
 * ```
 * 
 * ## Import
 * DomainMapping can be imported using any of these accepted formats:
 * * `locations/{{location}}/namespaces/{{project}}/domainmappings/{{name}}`
 * * `{{location}}/{{project}}/{{name}}`
 * * `{{location}}/{{name}}`
 * When using the `pulumi import` command, DomainMapping can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:cloudrun/domainMapping:DomainMapping default locations/{{location}}/namespaces/{{project}}/domainmappings/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:cloudrun/domainMapping:DomainMapping default {{location}}/{{project}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:cloudrun/domainMapping:DomainMapping default {{location}}/{{name}}
 * ```
 */
public class DomainMapping internal constructor(
    override val javaResource: com.pulumi.gcp.cloudrun.DomainMapping,
) : KotlinCustomResource(javaResource, DomainMappingMapper) {
    /**
     * The location of the cloud run instance. eg us-central1
     */
    public val location: Output
        get() = javaResource.location().applyValue({ args0 -> args0 })

    /**
     * Metadata associated with this DomainMapping.
     */
    public val metadata: Output
        get() = javaResource.metadata().applyValue({ args0 ->
            args0.let({ args0 ->
                domainMappingMetadataToKotlin(args0)
            })
        })

    /**
     * Name should be a [verified](https://support.google.com/webmasters/answer/9008080) domain
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * The spec for this DomainMapping.
     * Structure is documented below.
     */
    public val spec: Output
        get() = javaResource.spec().applyValue({ args0 ->
            args0.let({ args0 ->
                domainMappingSpecToKotlin(args0)
            })
        })

    /**
     * (Output)
     * Status of the condition, one of True, False, Unknown.
     */
    public val statuses: Output>
        get() = javaResource.statuses().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    domainMappingStatusToKotlin(args0)
                })
            })
        })
}

public object DomainMappingMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.cloudrun.DomainMapping::class == javaResource::class

    override fun map(javaResource: Resource): DomainMapping = DomainMapping(
        javaResource as
            com.pulumi.gcp.cloudrun.DomainMapping,
    )
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy