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

com.pulumi.azure.monitoring.kotlin.AadDiagnosticSetting.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.monitoring.kotlin

import com.pulumi.azure.monitoring.kotlin.outputs.AadDiagnosticSettingEnabledLog
import com.pulumi.azure.monitoring.kotlin.outputs.AadDiagnosticSettingLog
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.Deprecated
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import com.pulumi.azure.monitoring.kotlin.outputs.AadDiagnosticSettingEnabledLog.Companion.toKotlin as aadDiagnosticSettingEnabledLogToKotlin
import com.pulumi.azure.monitoring.kotlin.outputs.AadDiagnosticSettingLog.Companion.toKotlin as aadDiagnosticSettingLogToKotlin

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

    public var args: AadDiagnosticSettingArgs = AadDiagnosticSettingArgs()

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

/**
 * Manages an Azure Active Directory Diagnostic Setting for Azure Monitor.
 * !> **Authentication** The API for this resource does not support service principal authentication. This resource can only be used with Azure CLI authentication.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-rg",
 *     location: "west europe",
 * });
 * const exampleAccount = new azure.storage.Account("example", {
 *     name: "examplestorageaccount",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     accountTier: "Standard",
 *     accountKind: "StorageV2",
 *     accountReplicationType: "LRS",
 * });
 * const exampleAadDiagnosticSetting = new azure.monitoring.AadDiagnosticSetting("example", {
 *     name: "setting1",
 *     storageAccountId: exampleAccount.id,
 *     enabledLogs: [
 *         {
 *             category: "SignInLogs",
 *             retentionPolicy: {
 *                 enabled: true,
 *                 days: 1,
 *             },
 *         },
 *         {
 *             category: "AuditLogs",
 *             retentionPolicy: {
 *                 enabled: true,
 *                 days: 1,
 *             },
 *         },
 *         {
 *             category: "NonInteractiveUserSignInLogs",
 *             retentionPolicy: {
 *                 enabled: true,
 *                 days: 1,
 *             },
 *         },
 *         {
 *             category: "ServicePrincipalSignInLogs",
 *             retentionPolicy: {
 *                 enabled: true,
 *                 days: 1,
 *             },
 *         },
 *     ],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-rg",
 *     location="west europe")
 * example_account = azure.storage.Account("example",
 *     name="examplestorageaccount",
 *     resource_group_name=example.name,
 *     location=example.location,
 *     account_tier="Standard",
 *     account_kind="StorageV2",
 *     account_replication_type="LRS")
 * example_aad_diagnostic_setting = azure.monitoring.AadDiagnosticSetting("example",
 *     name="setting1",
 *     storage_account_id=example_account.id,
 *     enabled_logs=[
 *         azure.monitoring.AadDiagnosticSettingEnabledLogArgs(
 *             category="SignInLogs",
 *             retention_policy=azure.monitoring.AadDiagnosticSettingEnabledLogRetentionPolicyArgs(
 *                 enabled=True,
 *                 days=1,
 *             ),
 *         ),
 *         azure.monitoring.AadDiagnosticSettingEnabledLogArgs(
 *             category="AuditLogs",
 *             retention_policy=azure.monitoring.AadDiagnosticSettingEnabledLogRetentionPolicyArgs(
 *                 enabled=True,
 *                 days=1,
 *             ),
 *         ),
 *         azure.monitoring.AadDiagnosticSettingEnabledLogArgs(
 *             category="NonInteractiveUserSignInLogs",
 *             retention_policy=azure.monitoring.AadDiagnosticSettingEnabledLogRetentionPolicyArgs(
 *                 enabled=True,
 *                 days=1,
 *             ),
 *         ),
 *         azure.monitoring.AadDiagnosticSettingEnabledLogArgs(
 *             category="ServicePrincipalSignInLogs",
 *             retention_policy=azure.monitoring.AadDiagnosticSettingEnabledLogRetentionPolicyArgs(
 *                 enabled=True,
 *                 days=1,
 *             ),
 *         ),
 *     ])
 * ```
 * ```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-rg",
 *         Location = "west europe",
 *     });
 *     var exampleAccount = new Azure.Storage.Account("example", new()
 *     {
 *         Name = "examplestorageaccount",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *         AccountTier = "Standard",
 *         AccountKind = "StorageV2",
 *         AccountReplicationType = "LRS",
 *     });
 *     var exampleAadDiagnosticSetting = new Azure.Monitoring.AadDiagnosticSetting("example", new()
 *     {
 *         Name = "setting1",
 *         StorageAccountId = exampleAccount.Id,
 *         EnabledLogs = new[]
 *         {
 *             new Azure.Monitoring.Inputs.AadDiagnosticSettingEnabledLogArgs
 *             {
 *                 Category = "SignInLogs",
 *                 RetentionPolicy = new Azure.Monitoring.Inputs.AadDiagnosticSettingEnabledLogRetentionPolicyArgs
 *                 {
 *                     Enabled = true,
 *                     Days = 1,
 *                 },
 *             },
 *             new Azure.Monitoring.Inputs.AadDiagnosticSettingEnabledLogArgs
 *             {
 *                 Category = "AuditLogs",
 *                 RetentionPolicy = new Azure.Monitoring.Inputs.AadDiagnosticSettingEnabledLogRetentionPolicyArgs
 *                 {
 *                     Enabled = true,
 *                     Days = 1,
 *                 },
 *             },
 *             new Azure.Monitoring.Inputs.AadDiagnosticSettingEnabledLogArgs
 *             {
 *                 Category = "NonInteractiveUserSignInLogs",
 *                 RetentionPolicy = new Azure.Monitoring.Inputs.AadDiagnosticSettingEnabledLogRetentionPolicyArgs
 *                 {
 *                     Enabled = true,
 *                     Days = 1,
 *                 },
 *             },
 *             new Azure.Monitoring.Inputs.AadDiagnosticSettingEnabledLogArgs
 *             {
 *                 Category = "ServicePrincipalSignInLogs",
 *                 RetentionPolicy = new Azure.Monitoring.Inputs.AadDiagnosticSettingEnabledLogRetentionPolicyArgs
 *                 {
 *                     Enabled = true,
 *                     Days = 1,
 *                 },
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/monitoring"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/storage"
 * 	"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-rg"),
 * 			Location: pulumi.String("west europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleAccount, err := storage.NewAccount(ctx, "example", &storage.AccountArgs{
 * 			Name:                   pulumi.String("examplestorageaccount"),
 * 			ResourceGroupName:      example.Name,
 * 			Location:               example.Location,
 * 			AccountTier:            pulumi.String("Standard"),
 * 			AccountKind:            pulumi.String("StorageV2"),
 * 			AccountReplicationType: pulumi.String("LRS"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = monitoring.NewAadDiagnosticSetting(ctx, "example", &monitoring.AadDiagnosticSettingArgs{
 * 			Name:             pulumi.String("setting1"),
 * 			StorageAccountId: exampleAccount.ID(),
 * 			EnabledLogs: monitoring.AadDiagnosticSettingEnabledLogArray{
 * 				&monitoring.AadDiagnosticSettingEnabledLogArgs{
 * 					Category: pulumi.String("SignInLogs"),
 * 					RetentionPolicy: &monitoring.AadDiagnosticSettingEnabledLogRetentionPolicyArgs{
 * 						Enabled: pulumi.Bool(true),
 * 						Days:    pulumi.Int(1),
 * 					},
 * 				},
 * 				&monitoring.AadDiagnosticSettingEnabledLogArgs{
 * 					Category: pulumi.String("AuditLogs"),
 * 					RetentionPolicy: &monitoring.AadDiagnosticSettingEnabledLogRetentionPolicyArgs{
 * 						Enabled: pulumi.Bool(true),
 * 						Days:    pulumi.Int(1),
 * 					},
 * 				},
 * 				&monitoring.AadDiagnosticSettingEnabledLogArgs{
 * 					Category: pulumi.String("NonInteractiveUserSignInLogs"),
 * 					RetentionPolicy: &monitoring.AadDiagnosticSettingEnabledLogRetentionPolicyArgs{
 * 						Enabled: pulumi.Bool(true),
 * 						Days:    pulumi.Int(1),
 * 					},
 * 				},
 * 				&monitoring.AadDiagnosticSettingEnabledLogArgs{
 * 					Category: pulumi.String("ServicePrincipalSignInLogs"),
 * 					RetentionPolicy: &monitoring.AadDiagnosticSettingEnabledLogRetentionPolicyArgs{
 * 						Enabled: pulumi.Bool(true),
 * 						Days:    pulumi.Int(1),
 * 					},
 * 				},
 * 			},
 * 		})
 * 		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.storage.Account;
 * import com.pulumi.azure.storage.AccountArgs;
 * import com.pulumi.azure.monitoring.AadDiagnosticSetting;
 * import com.pulumi.azure.monitoring.AadDiagnosticSettingArgs;
 * import com.pulumi.azure.monitoring.inputs.AadDiagnosticSettingEnabledLogArgs;
 * import com.pulumi.azure.monitoring.inputs.AadDiagnosticSettingEnabledLogRetentionPolicyArgs;
 * 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-rg")
 *             .location("west europe")
 *             .build());
 *         var exampleAccount = new Account("exampleAccount", AccountArgs.builder()
 *             .name("examplestorageaccount")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .accountTier("Standard")
 *             .accountKind("StorageV2")
 *             .accountReplicationType("LRS")
 *             .build());
 *         var exampleAadDiagnosticSetting = new AadDiagnosticSetting("exampleAadDiagnosticSetting", AadDiagnosticSettingArgs.builder()
 *             .name("setting1")
 *             .storageAccountId(exampleAccount.id())
 *             .enabledLogs(
 *                 AadDiagnosticSettingEnabledLogArgs.builder()
 *                     .category("SignInLogs")
 *                     .retentionPolicy(AadDiagnosticSettingEnabledLogRetentionPolicyArgs.builder()
 *                         .enabled(true)
 *                         .days(1)
 *                         .build())
 *                     .build(),
 *                 AadDiagnosticSettingEnabledLogArgs.builder()
 *                     .category("AuditLogs")
 *                     .retentionPolicy(AadDiagnosticSettingEnabledLogRetentionPolicyArgs.builder()
 *                         .enabled(true)
 *                         .days(1)
 *                         .build())
 *                     .build(),
 *                 AadDiagnosticSettingEnabledLogArgs.builder()
 *                     .category("NonInteractiveUserSignInLogs")
 *                     .retentionPolicy(AadDiagnosticSettingEnabledLogRetentionPolicyArgs.builder()
 *                         .enabled(true)
 *                         .days(1)
 *                         .build())
 *                     .build(),
 *                 AadDiagnosticSettingEnabledLogArgs.builder()
 *                     .category("ServicePrincipalSignInLogs")
 *                     .retentionPolicy(AadDiagnosticSettingEnabledLogRetentionPolicyArgs.builder()
 *                         .enabled(true)
 *                         .days(1)
 *                         .build())
 *                     .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-rg
 *       location: west europe
 *   exampleAccount:
 *     type: azure:storage:Account
 *     name: example
 *     properties:
 *       name: examplestorageaccount
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *       accountTier: Standard
 *       accountKind: StorageV2
 *       accountReplicationType: LRS
 *   exampleAadDiagnosticSetting:
 *     type: azure:monitoring:AadDiagnosticSetting
 *     name: example
 *     properties:
 *       name: setting1
 *       storageAccountId: ${exampleAccount.id}
 *       enabledLogs:
 *         - category: SignInLogs
 *           retentionPolicy:
 *             enabled: true
 *             days: 1
 *         - category: AuditLogs
 *           retentionPolicy:
 *             enabled: true
 *             days: 1
 *         - category: NonInteractiveUserSignInLogs
 *           retentionPolicy:
 *             enabled: true
 *             days: 1
 *         - category: ServicePrincipalSignInLogs
 *           retentionPolicy:
 *             enabled: true
 *             days: 1
 * ```
 * 
 * ## Import
 * Monitor Azure Active Directory Diagnostic Settings can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:monitoring/aadDiagnosticSetting:AadDiagnosticSetting example /providers/Microsoft.AADIAM/diagnosticSettings/setting1
 * ```
 */
public class AadDiagnosticSetting internal constructor(
    override val javaResource: com.pulumi.azure.monitoring.AadDiagnosticSetting,
) : KotlinCustomResource(javaResource, AadDiagnosticSettingMapper) {
    /**
     * One or more `enabled_log` blocks as defined below.
     * > **NOTE:** At least one `log` or `enabled_log` block must be specified. At least one type of Log must be enabled.
     */
    public val enabledLogs: Output>
        get() = javaResource.enabledLogs().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    aadDiagnosticSettingEnabledLogToKotlin(args0)
                })
            })
        })

    /**
     * Specifies the ID of an Event Hub Namespace Authorization Rule used to send Diagnostics Data. Changing this forces a new resource to be created.
     * > **NOTE:** This can be sourced from the `azure.eventhub.EventHubNamespaceAuthorizationRule` resource and is different from a `azure.eventhub.AuthorizationRule` resource.
     */
    public val eventhubAuthorizationRuleId: Output?
        get() = javaResource.eventhubAuthorizationRuleId().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Specifies the name of the Event Hub where Diagnostics Data should be sent. If not specified, the default Event Hub will be used. Changing this forces a new resource to be created.
     */
    public val eventhubName: Output?
        get() = javaResource.eventhubName().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Specifies the ID of a Log Analytics Workspace where Diagnostics Data should be sent.
     */
    public val logAnalyticsWorkspaceId: Output?
        get() = javaResource.logAnalyticsWorkspaceId().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * One or more `log` blocks as defined below.
     * > **NOTE:** `log` is deprecated in favour of the `enabled_log` property and will be removed in version 4.0 of the AzureRM Provider.
     */
    @Deprecated(
        message = """
  `log` has been superseded by `enabled_log` and will be removed in version 4.0 of the AzureRM
      Provider.
  """,
    )
    public val logs: Output>
        get() = javaResource.logs().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    aadDiagnosticSettingLogToKotlin(args0)
                })
            })
        })

    /**
     * The name which should be used for this Monitor Azure Active Directory Diagnostic Setting. Changing this forces a new Monitor Azure Active Directory Diagnostic Setting to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The ID of the Storage Account where logs should be sent. Changing this forces a new resource to be created.
     * > **NOTE:** One of `eventhub_authorization_rule_id`, `log_analytics_workspace_id` and `storage_account_id` must be specified.
     */
    public val storageAccountId: Output?
        get() = javaResource.storageAccountId().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })
}

public object AadDiagnosticSettingMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.monitoring.AadDiagnosticSetting::class == javaResource::class

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy