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

com.pulumi.azure.containerapp.kotlin.App.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.containerapp.kotlin

import com.pulumi.azure.containerapp.kotlin.outputs.AppDapr
import com.pulumi.azure.containerapp.kotlin.outputs.AppIdentity
import com.pulumi.azure.containerapp.kotlin.outputs.AppIngress
import com.pulumi.azure.containerapp.kotlin.outputs.AppRegistry
import com.pulumi.azure.containerapp.kotlin.outputs.AppSecret
import com.pulumi.azure.containerapp.kotlin.outputs.AppTemplate
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
import kotlin.collections.List
import kotlin.collections.Map
import com.pulumi.azure.containerapp.kotlin.outputs.AppDapr.Companion.toKotlin as appDaprToKotlin
import com.pulumi.azure.containerapp.kotlin.outputs.AppIdentity.Companion.toKotlin as appIdentityToKotlin
import com.pulumi.azure.containerapp.kotlin.outputs.AppIngress.Companion.toKotlin as appIngressToKotlin
import com.pulumi.azure.containerapp.kotlin.outputs.AppRegistry.Companion.toKotlin as appRegistryToKotlin
import com.pulumi.azure.containerapp.kotlin.outputs.AppSecret.Companion.toKotlin as appSecretToKotlin
import com.pulumi.azure.containerapp.kotlin.outputs.AppTemplate.Companion.toKotlin as appTemplateToKotlin

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

    public var args: AppArgs = AppArgs()

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

/**
 * Manages a Container App.
 * ## Example Usage
 * 
 * ```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 exampleAnalyticsWorkspace = new azure.operationalinsights.AnalyticsWorkspace("example", {
 *     name: "acctest-01",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     sku: "PerGB2018",
 *     retentionInDays: 30,
 * });
 * const exampleEnvironment = new azure.containerapp.Environment("example", {
 *     name: "Example-Environment",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     logAnalyticsWorkspaceId: exampleAnalyticsWorkspace.id,
 * });
 * const exampleApp = new azure.containerapp.App("example", {
 *     name: "example-app",
 *     containerAppEnvironmentId: exampleEnvironment.id,
 *     resourceGroupName: example.name,
 *     revisionMode: "Single",
 *     template: {
 *         containers: [{
 *             name: "examplecontainerapp",
 *             image: "mcr.microsoft.com/k8se/quickstart:latest",
 *             cpu: 0.25,
 *             memory: "0.5Gi",
 *         }],
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * example_analytics_workspace = azure.operationalinsights.AnalyticsWorkspace("example",
 *     name="acctest-01",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     sku="PerGB2018",
 *     retention_in_days=30)
 * example_environment = azure.containerapp.Environment("example",
 *     name="Example-Environment",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     log_analytics_workspace_id=example_analytics_workspace.id)
 * example_app = azure.containerapp.App("example",
 *     name="example-app",
 *     container_app_environment_id=example_environment.id,
 *     resource_group_name=example.name,
 *     revision_mode="Single",
 *     template={
 *         "containers": [{
 *             "name": "examplecontainerapp",
 *             "image": "mcr.microsoft.com/k8se/quickstart:latest",
 *             "cpu": 0.25,
 *             "memory": "0.5Gi",
 *         }],
 *     })
 * ```
 * ```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 exampleAnalyticsWorkspace = new Azure.OperationalInsights.AnalyticsWorkspace("example", new()
 *     {
 *         Name = "acctest-01",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         Sku = "PerGB2018",
 *         RetentionInDays = 30,
 *     });
 *     var exampleEnvironment = new Azure.ContainerApp.Environment("example", new()
 *     {
 *         Name = "Example-Environment",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         LogAnalyticsWorkspaceId = exampleAnalyticsWorkspace.Id,
 *     });
 *     var exampleApp = new Azure.ContainerApp.App("example", new()
 *     {
 *         Name = "example-app",
 *         ContainerAppEnvironmentId = exampleEnvironment.Id,
 *         ResourceGroupName = example.Name,
 *         RevisionMode = "Single",
 *         Template = new Azure.ContainerApp.Inputs.AppTemplateArgs
 *         {
 *             Containers = new[]
 *             {
 *                 new Azure.ContainerApp.Inputs.AppTemplateContainerArgs
 *                 {
 *                     Name = "examplecontainerapp",
 *                     Image = "mcr.microsoft.com/k8se/quickstart:latest",
 *                     Cpu = 0.25,
 *                     Memory = "0.5Gi",
 *                 },
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/containerapp"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/operationalinsights"
 * 	"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
 * 		}
 * 		exampleAnalyticsWorkspace, err := operationalinsights.NewAnalyticsWorkspace(ctx, "example", &operationalinsights.AnalyticsWorkspaceArgs{
 * 			Name:              pulumi.String("acctest-01"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 			Sku:               pulumi.String("PerGB2018"),
 * 			RetentionInDays:   pulumi.Int(30),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleEnvironment, err := containerapp.NewEnvironment(ctx, "example", &containerapp.EnvironmentArgs{
 * 			Name:                    pulumi.String("Example-Environment"),
 * 			Location:                example.Location,
 * 			ResourceGroupName:       example.Name,
 * 			LogAnalyticsWorkspaceId: exampleAnalyticsWorkspace.ID(),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = containerapp.NewApp(ctx, "example", &containerapp.AppArgs{
 * 			Name:                      pulumi.String("example-app"),
 * 			ContainerAppEnvironmentId: exampleEnvironment.ID(),
 * 			ResourceGroupName:         example.Name,
 * 			RevisionMode:              pulumi.String("Single"),
 * 			Template: &containerapp.AppTemplateArgs{
 * 				Containers: containerapp.AppTemplateContainerArray{
 * 					&containerapp.AppTemplateContainerArgs{
 * 						Name:   pulumi.String("examplecontainerapp"),
 * 						Image:  pulumi.String("mcr.microsoft.com/k8se/quickstart:latest"),
 * 						Cpu:    pulumi.Float64(0.25),
 * 						Memory: pulumi.String("0.5Gi"),
 * 					},
 * 				},
 * 			},
 * 		})
 * 		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.operationalinsights.AnalyticsWorkspace;
 * import com.pulumi.azure.operationalinsights.AnalyticsWorkspaceArgs;
 * import com.pulumi.azure.containerapp.Environment;
 * import com.pulumi.azure.containerapp.EnvironmentArgs;
 * import com.pulumi.azure.containerapp.App;
 * import com.pulumi.azure.containerapp.AppArgs;
 * import com.pulumi.azure.containerapp.inputs.AppTemplateArgs;
 * 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 exampleAnalyticsWorkspace = new AnalyticsWorkspace("exampleAnalyticsWorkspace", AnalyticsWorkspaceArgs.builder()
 *             .name("acctest-01")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .sku("PerGB2018")
 *             .retentionInDays(30)
 *             .build());
 *         var exampleEnvironment = new Environment("exampleEnvironment", EnvironmentArgs.builder()
 *             .name("Example-Environment")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .logAnalyticsWorkspaceId(exampleAnalyticsWorkspace.id())
 *             .build());
 *         var exampleApp = new App("exampleApp", AppArgs.builder()
 *             .name("example-app")
 *             .containerAppEnvironmentId(exampleEnvironment.id())
 *             .resourceGroupName(example.name())
 *             .revisionMode("Single")
 *             .template(AppTemplateArgs.builder()
 *                 .containers(AppTemplateContainerArgs.builder()
 *                     .name("examplecontainerapp")
 *                     .image("mcr.microsoft.com/k8se/quickstart:latest")
 *                     .cpu(0.25)
 *                     .memory("0.5Gi")
 *                     .build())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleAnalyticsWorkspace:
 *     type: azure:operationalinsights:AnalyticsWorkspace
 *     name: example
 *     properties:
 *       name: acctest-01
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       sku: PerGB2018
 *       retentionInDays: 30
 *   exampleEnvironment:
 *     type: azure:containerapp:Environment
 *     name: example
 *     properties:
 *       name: Example-Environment
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       logAnalyticsWorkspaceId: ${exampleAnalyticsWorkspace.id}
 *   exampleApp:
 *     type: azure:containerapp:App
 *     name: example
 *     properties:
 *       name: example-app
 *       containerAppEnvironmentId: ${exampleEnvironment.id}
 *       resourceGroupName: ${example.name}
 *       revisionMode: Single
 *       template:
 *         containers:
 *           - name: examplecontainerapp
 *             image: mcr.microsoft.com/k8se/quickstart:latest
 *             cpu: 0.25
 *             memory: 0.5Gi
 * ```
 * 
 * ## Import
 * A Container App can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:containerapp/app:App example "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.App/containerApps/myContainerApp"
 * ```
 */
public class App internal constructor(
    override val javaResource: com.pulumi.azure.containerapp.App,
) : KotlinCustomResource(javaResource, AppMapper) {
    /**
     * The ID of the Container App Environment within which this Container App should exist. Changing this forces a new resource to be created.
     */
    public val containerAppEnvironmentId: Output
        get() = javaResource.containerAppEnvironmentId().applyValue({ args0 -> args0 })

    /**
     * The ID of the Custom Domain Verification for this Container App.
     */
    public val customDomainVerificationId: Output
        get() = javaResource.customDomainVerificationId().applyValue({ args0 -> args0 })

    /**
     * A `dapr` block as detailed below.
     */
    public val dapr: Output?
        get() = javaResource.dapr().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    appDaprToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * An `identity` block as detailed below.
     */
    public val identity: Output?
        get() = javaResource.identity().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    appIdentityToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * An `ingress` block as detailed below.
     */
    public val ingress: Output?
        get() = javaResource.ingress().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    appIngressToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * The FQDN of the Latest Revision of the Container App.
     */
    public val latestRevisionFqdn: Output
        get() = javaResource.latestRevisionFqdn().applyValue({ args0 -> args0 })

    /**
     * The name of the latest Container Revision.
     */
    public val latestRevisionName: Output
        get() = javaResource.latestRevisionName().applyValue({ args0 -> args0 })

    /**
     * The location this Container App is deployed in. This is the same as the Environment in which it is deployed.
     */
    public val location: Output
        get() = javaResource.location().applyValue({ args0 -> args0 })

    /**
     * The name for this Container App. Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * A list of the Public IP Addresses which the Container App uses for outbound network access.
     */
    public val outboundIpAddresses: Output>
        get() = javaResource.outboundIpAddresses().applyValue({ args0 -> args0.map({ args0 -> args0 }) })

    /**
     * A `registry` block as detailed below.
     */
    public val registries: Output>?
        get() = javaResource.registries().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 -> appRegistryToKotlin(args0) })
                })
            }).orElse(null)
        })

    /**
     * The name of the resource group in which the Container App Environment is to be created. Changing this forces a new resource to be created.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

    /**
     * The revisions operational mode for the Container App. Possible values include `Single` and `Multiple`. In `Single` mode, a single revision is in operation at any given time. In `Multiple` mode, more than one revision can be active at a time and can be configured with load distribution via the `traffic_weight` block in the `ingress` configuration.
     */
    public val revisionMode: Output
        get() = javaResource.revisionMode().applyValue({ args0 -> args0 })

    /**
     * One or more `secret` block as detailed below.
     */
    public val secrets: Output>?
        get() = javaResource.secrets().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 -> appSecretToKotlin(args0) })
                })
            }).orElse(null)
        })

    /**
     * A mapping of tags to assign to the Container App.
     */
    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * A `template` block as detailed below.
     */
    public val template: Output
        get() = javaResource.template().applyValue({ args0 ->
            args0.let({ args0 ->
                appTemplateToKotlin(args0)
            })
        })

    /**
     * The name of the Workload Profile in the Container App Environment to place this Container App.
     * > **Note:** Omit this value to use the default `Consumption` Workload Profile.
     */
    public val workloadProfileName: Output?
        get() = javaResource.workloadProfileName().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })
}

public object AppMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.containerapp.App::class == javaResource::class

    override fun map(javaResource: Resource): App = App(
        javaResource as
            com.pulumi.azure.containerapp.App,
    )
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy