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

com.pulumi.azure.monitoring.kotlin.LogProfile.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.LogProfileRetentionPolicy
import com.pulumi.azure.monitoring.kotlin.outputs.LogProfileRetentionPolicy.Companion.toKotlin
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 [LogProfile].
 */
@PulumiTagMarker
public class LogProfileResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: LogProfileArgs = LogProfileArgs()

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

/**
 * Manages a [Log Profile](https://docs.microsoft.com/azure/monitoring-and-diagnostics/monitoring-overview-activity-logs#export-the-activity-log-with-a-log-profile). A Log Profile configures how Activity Logs are exported.
 * > **NOTE:** It's only possible to configure one Log Profile per Subscription. If you are trying to create more than one Log Profile, an error with `StatusCode=409` will occur.
 * !> **NOTE:** Azure Log Profiles will be retired on 30th September 2026 and will be removed in v4.0 of the AzureRM Provider. More information on the deprecation can be found [in the Azure documentation](https://learn.microsoft.com/azure/azure-monitor/essentials/activity-log?tabs=powershell#legacy-collection-methods).
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "logprofiletest-rg",
 *     location: "West Europe",
 * });
 * const exampleAccount = new azure.storage.Account("example", {
 *     name: "afscsdfytw",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     accountTier: "Standard",
 *     accountReplicationType: "GRS",
 * });
 * const exampleEventHubNamespace = new azure.eventhub.EventHubNamespace("example", {
 *     name: "logprofileeventhub",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     sku: "Standard",
 *     capacity: 2,
 * });
 * const exampleLogProfile = new azure.monitoring.LogProfile("example", {
 *     name: "default",
 *     categories: [
 *         "Action",
 *         "Delete",
 *         "Write",
 *     ],
 *     locations: [
 *         "westus",
 *         "global",
 *     ],
 *     servicebusRuleId: pulumi.interpolate`${exampleEventHubNamespace.id}/authorizationrules/RootManageSharedAccessKey`,
 *     storageAccountId: exampleAccount.id,
 *     retentionPolicy: {
 *         enabled: true,
 *         days: 7,
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="logprofiletest-rg",
 *     location="West Europe")
 * example_account = azure.storage.Account("example",
 *     name="afscsdfytw",
 *     resource_group_name=example.name,
 *     location=example.location,
 *     account_tier="Standard",
 *     account_replication_type="GRS")
 * example_event_hub_namespace = azure.eventhub.EventHubNamespace("example",
 *     name="logprofileeventhub",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     sku="Standard",
 *     capacity=2)
 * example_log_profile = azure.monitoring.LogProfile("example",
 *     name="default",
 *     categories=[
 *         "Action",
 *         "Delete",
 *         "Write",
 *     ],
 *     locations=[
 *         "westus",
 *         "global",
 *     ],
 *     servicebus_rule_id=example_event_hub_namespace.id.apply(lambda id: f"{id}/authorizationrules/RootManageSharedAccessKey"),
 *     storage_account_id=example_account.id,
 *     retention_policy=azure.monitoring.LogProfileRetentionPolicyArgs(
 *         enabled=True,
 *         days=7,
 *     ))
 * ```
 * ```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 = "logprofiletest-rg",
 *         Location = "West Europe",
 *     });
 *     var exampleAccount = new Azure.Storage.Account("example", new()
 *     {
 *         Name = "afscsdfytw",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *         AccountTier = "Standard",
 *         AccountReplicationType = "GRS",
 *     });
 *     var exampleEventHubNamespace = new Azure.EventHub.EventHubNamespace("example", new()
 *     {
 *         Name = "logprofileeventhub",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         Sku = "Standard",
 *         Capacity = 2,
 *     });
 *     var exampleLogProfile = new Azure.Monitoring.LogProfile("example", new()
 *     {
 *         Name = "default",
 *         Categories = new[]
 *         {
 *             "Action",
 *             "Delete",
 *             "Write",
 *         },
 *         Locations = new[]
 *         {
 *             "westus",
 *             "global",
 *         },
 *         ServicebusRuleId = exampleEventHubNamespace.Id.Apply(id => $"{id}/authorizationrules/RootManageSharedAccessKey"),
 *         StorageAccountId = exampleAccount.Id,
 *         RetentionPolicy = new Azure.Monitoring.Inputs.LogProfileRetentionPolicyArgs
 *         {
 *             Enabled = true,
 *             Days = 7,
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"fmt"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/eventhub"
 * 	"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("logprofiletest-rg"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleAccount, err := storage.NewAccount(ctx, "example", &storage.AccountArgs{
 * 			Name:                   pulumi.String("afscsdfytw"),
 * 			ResourceGroupName:      example.Name,
 * 			Location:               example.Location,
 * 			AccountTier:            pulumi.String("Standard"),
 * 			AccountReplicationType: pulumi.String("GRS"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleEventHubNamespace, err := eventhub.NewEventHubNamespace(ctx, "example", &eventhub.EventHubNamespaceArgs{
 * 			Name:              pulumi.String("logprofileeventhub"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 			Sku:               pulumi.String("Standard"),
 * 			Capacity:          pulumi.Int(2),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = monitoring.NewLogProfile(ctx, "example", &monitoring.LogProfileArgs{
 * 			Name: pulumi.String("default"),
 * 			Categories: pulumi.StringArray{
 * 				pulumi.String("Action"),
 * 				pulumi.String("Delete"),
 * 				pulumi.String("Write"),
 * 			},
 * 			Locations: pulumi.StringArray{
 * 				pulumi.String("westus"),
 * 				pulumi.String("global"),
 * 			},
 * 			ServicebusRuleId: exampleEventHubNamespace.ID().ApplyT(func(id string) (string, error) {
 * 				return fmt.Sprintf("%v/authorizationrules/RootManageSharedAccessKey", id), nil
 * 			}).(pulumi.StringOutput),
 * 			StorageAccountId: exampleAccount.ID(),
 * 			RetentionPolicy: &monitoring.LogProfileRetentionPolicyArgs{
 * 				Enabled: pulumi.Bool(true),
 * 				Days:    pulumi.Int(7),
 * 			},
 * 		})
 * 		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.eventhub.EventHubNamespace;
 * import com.pulumi.azure.eventhub.EventHubNamespaceArgs;
 * import com.pulumi.azure.monitoring.LogProfile;
 * import com.pulumi.azure.monitoring.LogProfileArgs;
 * import com.pulumi.azure.monitoring.inputs.LogProfileRetentionPolicyArgs;
 * 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("logprofiletest-rg")
 *             .location("West Europe")
 *             .build());
 *         var exampleAccount = new Account("exampleAccount", AccountArgs.builder()
 *             .name("afscsdfytw")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .accountTier("Standard")
 *             .accountReplicationType("GRS")
 *             .build());
 *         var exampleEventHubNamespace = new EventHubNamespace("exampleEventHubNamespace", EventHubNamespaceArgs.builder()
 *             .name("logprofileeventhub")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .sku("Standard")
 *             .capacity(2)
 *             .build());
 *         var exampleLogProfile = new LogProfile("exampleLogProfile", LogProfileArgs.builder()
 *             .name("default")
 *             .categories(
 *                 "Action",
 *                 "Delete",
 *                 "Write")
 *             .locations(
 *                 "westus",
 *                 "global")
 *             .servicebusRuleId(exampleEventHubNamespace.id().applyValue(id -> String.format("%s/authorizationrules/RootManageSharedAccessKey", id)))
 *             .storageAccountId(exampleAccount.id())
 *             .retentionPolicy(LogProfileRetentionPolicyArgs.builder()
 *                 .enabled(true)
 *                 .days(7)
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: logprofiletest-rg
 *       location: West Europe
 *   exampleAccount:
 *     type: azure:storage:Account
 *     name: example
 *     properties:
 *       name: afscsdfytw
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *       accountTier: Standard
 *       accountReplicationType: GRS
 *   exampleEventHubNamespace:
 *     type: azure:eventhub:EventHubNamespace
 *     name: example
 *     properties:
 *       name: logprofileeventhub
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       sku: Standard
 *       capacity: 2
 *   exampleLogProfile:
 *     type: azure:monitoring:LogProfile
 *     name: example
 *     properties:
 *       name: default
 *       categories:
 *         - Action
 *         - Delete
 *         - Write
 *       locations:
 *         - westus
 *         - global
 *       servicebusRuleId: ${exampleEventHubNamespace.id}/authorizationrules/RootManageSharedAccessKey
 *       storageAccountId: ${exampleAccount.id}
 *       retentionPolicy:
 *         enabled: true
 *         days: 7
 * ```
 * 
 * ## Import
 * A Log Profile can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:monitoring/logProfile:LogProfile example /subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Insights/logProfiles/test
 * ```
 */
public class LogProfile internal constructor(
    override val javaResource: com.pulumi.azure.monitoring.LogProfile,
) : KotlinCustomResource(javaResource, LogProfileMapper) {
    /**
     * List of categories of the logs.
     */
    public val categories: Output>
        get() = javaResource.categories().applyValue({ args0 -> args0.map({ args0 -> args0 }) })

    /**
     * List of regions for which Activity Log events are stored or streamed.
     */
    public val locations: Output>
        get() = javaResource.locations().applyValue({ args0 -> args0.map({ args0 -> args0 }) })

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

    /**
     * A `retention_policy` block as documented below. A retention policy for how long Activity Logs are retained in the storage account.
     */
    public val retentionPolicy: Output
        get() = javaResource.retentionPolicy().applyValue({ args0 ->
            args0.let({ args0 ->
                toKotlin(args0)
            })
        })

    /**
     * The service bus (or event hub) rule ID of the service bus (or event hub) namespace in which the Activity Log is streamed to. At least one of `storage_account_id` or `servicebus_rule_id` must be set.
     */
    public val servicebusRuleId: Output?
        get() = javaResource.servicebusRuleId().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The resource ID of the storage account in which the Activity Log is stored. At least one of `storage_account_id` or `servicebus_rule_id` must be set.
     */
    public val storageAccountId: Output?
        get() = javaResource.storageAccountId().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })
}

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

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy