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

com.pulumi.azure.costmanagement.kotlin.AnomalyAlert.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 6.15.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azure.costmanagement.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
import kotlin.collections.List

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

    public var args: AnomalyAlertArgs = AnomalyAlertArgs()

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

/**
 * Manages a Cost Anomaly Alert.
 * > **Note:** Anomaly alerts are sent based on the current access of the rule creator at the time that the email is sent. Learn more [here](https://learn.microsoft.com/en-us/azure/cost-management-billing/understand/analyze-unexpected-charges#create-an-anomaly-alert).
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.costmanagement.AnomalyAlert("example", {
 *     name: "alertname",
 *     displayName: "Alert DisplayName",
 *     subscriptionId: "/subscriptions/00000000-0000-0000-0000-000000000000",
 *     emailSubject: "My Test Anomaly Alert",
 *     emailAddresses: ["example@test.net"],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.costmanagement.AnomalyAlert("example",
 *     name="alertname",
 *     display_name="Alert DisplayName",
 *     subscription_id="/subscriptions/00000000-0000-0000-0000-000000000000",
 *     email_subject="My Test Anomaly Alert",
 *     email_addresses=["example@test.net"])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Azure.CostManagement.AnomalyAlert("example", new()
 *     {
 *         Name = "alertname",
 *         DisplayName = "Alert DisplayName",
 *         SubscriptionId = "/subscriptions/00000000-0000-0000-0000-000000000000",
 *         EmailSubject = "My Test Anomaly Alert",
 *         EmailAddresses = new[]
 *         {
 *             "[email protected]",
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/costmanagement"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := costmanagement.NewAnomalyAlert(ctx, "example", &costmanagement.AnomalyAlertArgs{
 * 			Name:           pulumi.String("alertname"),
 * 			DisplayName:    pulumi.String("Alert DisplayName"),
 * 			SubscriptionId: pulumi.String("/subscriptions/00000000-0000-0000-0000-000000000000"),
 * 			EmailSubject:   pulumi.String("My Test Anomaly Alert"),
 * 			EmailAddresses: pulumi.StringArray{
 * 				pulumi.String("[email protected]"),
 * 			},
 * 		})
 * 		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.costmanagement.AnomalyAlert;
 * import com.pulumi.azure.costmanagement.AnomalyAlertArgs;
 * 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 AnomalyAlert("example", AnomalyAlertArgs.builder()
 *             .name("alertname")
 *             .displayName("Alert DisplayName")
 *             .subscriptionId("/subscriptions/00000000-0000-0000-0000-000000000000")
 *             .emailSubject("My Test Anomaly Alert")
 *             .emailAddresses("[email protected]")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:costmanagement:AnomalyAlert
 *     properties:
 *       name: alertname
 *       displayName: Alert DisplayName
 *       subscriptionId: /subscriptions/00000000-0000-0000-0000-000000000000
 *       emailSubject: My Test Anomaly Alert
 *       emailAddresses:
 *         - [email protected]
 * ```
 * 
 * ## Import
 * Cost Anomaly Alerts can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:costmanagement/anomalyAlert:AnomalyAlert example /subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/dailyanomalybyresourcegroup
 * ```
 */
public class AnomalyAlert internal constructor(
    override val javaResource: com.pulumi.azure.costmanagement.AnomalyAlert,
) : KotlinCustomResource(javaResource, AnomalyAlertMapper) {
    /**
     * The display name which should be used for this Cost Anomaly Alert.
     */
    public val displayName: Output
        get() = javaResource.displayName().applyValue({ args0 -> args0 })

    /**
     * Specifies a list of email addresses which the Anomaly Alerts are send to.
     */
    public val emailAddresses: Output>
        get() = javaResource.emailAddresses().applyValue({ args0 -> args0.map({ args0 -> args0 }) })

    /**
     * The email subject of the Cost Anomaly Alerts. Maximum length of the subject is 70.
     */
    public val emailSubject: Output
        get() = javaResource.emailSubject().applyValue({ args0 -> args0 })

    /**
     * The message of the Cost Anomaly Alert. Maximum length of the message is 250.
     */
    public val message: Output?
        get() = javaResource.message().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The name which should be used for this Cost Anomaly Alert. Changing this forces a new resource to be created. The name can contain only lowercase letters, numbers and hyphens.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The ID of the Subscription this Cost Anomaly Alert is scoped to. Changing this forces a new resource to be created. When not supplied this defaults to the subscription configured in the provider.
     */
    public val subscriptionId: Output
        get() = javaResource.subscriptionId().applyValue({ args0 -> args0 })
}

public object AnomalyAlertMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.costmanagement.AnomalyAlert::class == javaResource::class

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy