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

com.pulumi.azure.network.kotlin.NetworkWatcherFlowLog.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.network.kotlin

import com.pulumi.azure.network.kotlin.outputs.NetworkWatcherFlowLogRetentionPolicy
import com.pulumi.azure.network.kotlin.outputs.NetworkWatcherFlowLogTrafficAnalytics
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.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.Map
import com.pulumi.azure.network.kotlin.outputs.NetworkWatcherFlowLogRetentionPolicy.Companion.toKotlin as networkWatcherFlowLogRetentionPolicyToKotlin
import com.pulumi.azure.network.kotlin.outputs.NetworkWatcherFlowLogTrafficAnalytics.Companion.toKotlin as networkWatcherFlowLogTrafficAnalyticsToKotlin

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

    public var args: NetworkWatcherFlowLogArgs = NetworkWatcherFlowLogArgs()

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

/**
 * Manages a Network Watcher Flow Log.
 * > **Note** The `azure.network.NetworkWatcherFlowLog` creates a new storage lifecyle management rule that overwrites existing rules. Please make sure to use a `storage_account` with no existing management rules, until the issue is fixed.
 * ## 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 test = new azure.network.NetworkSecurityGroup("test", {
 *     name: "acctestnsg",
 *     location: example.location,
 *     resourceGroupName: example.name,
 * });
 * const testNetworkWatcher = new azure.network.NetworkWatcher("test", {
 *     name: "acctestnw",
 *     location: example.location,
 *     resourceGroupName: example.name,
 * });
 * const testAccount = new azure.storage.Account("test", {
 *     name: "acctestsa",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     accountTier: "Standard",
 *     accountKind: "StorageV2",
 *     accountReplicationType: "LRS",
 *     enableHttpsTrafficOnly: true,
 * });
 * const testAnalyticsWorkspace = new azure.operationalinsights.AnalyticsWorkspace("test", {
 *     name: "acctestlaw",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     sku: "PerGB2018",
 * });
 * const testNetworkWatcherFlowLog = new azure.network.NetworkWatcherFlowLog("test", {
 *     networkWatcherName: testNetworkWatcher.name,
 *     resourceGroupName: example.name,
 *     name: "example-log",
 *     networkSecurityGroupId: test.id,
 *     storageAccountId: testAccount.id,
 *     enabled: true,
 *     retentionPolicy: {
 *         enabled: true,
 *         days: 7,
 *     },
 *     trafficAnalytics: {
 *         enabled: true,
 *         workspaceId: testAnalyticsWorkspace.workspaceId,
 *         workspaceRegion: testAnalyticsWorkspace.location,
 *         workspaceResourceId: testAnalyticsWorkspace.id,
 *         intervalInMinutes: 10,
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * test = azure.network.NetworkSecurityGroup("test",
 *     name="acctestnsg",
 *     location=example.location,
 *     resource_group_name=example.name)
 * test_network_watcher = azure.network.NetworkWatcher("test",
 *     name="acctestnw",
 *     location=example.location,
 *     resource_group_name=example.name)
 * test_account = azure.storage.Account("test",
 *     name="acctestsa",
 *     resource_group_name=example.name,
 *     location=example.location,
 *     account_tier="Standard",
 *     account_kind="StorageV2",
 *     account_replication_type="LRS",
 *     enable_https_traffic_only=True)
 * test_analytics_workspace = azure.operationalinsights.AnalyticsWorkspace("test",
 *     name="acctestlaw",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     sku="PerGB2018")
 * test_network_watcher_flow_log = azure.network.NetworkWatcherFlowLog("test",
 *     network_watcher_name=test_network_watcher.name,
 *     resource_group_name=example.name,
 *     name="example-log",
 *     network_security_group_id=test.id,
 *     storage_account_id=test_account.id,
 *     enabled=True,
 *     retention_policy={
 *         "enabled": True,
 *         "days": 7,
 *     },
 *     traffic_analytics={
 *         "enabled": True,
 *         "workspace_id": test_analytics_workspace.workspace_id,
 *         "workspace_region": test_analytics_workspace.location,
 *         "workspace_resource_id": test_analytics_workspace.id,
 *         "interval_in_minutes": 10,
 *     })
 * ```
 * ```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 test = new Azure.Network.NetworkSecurityGroup("test", new()
 *     {
 *         Name = "acctestnsg",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *     });
 *     var testNetworkWatcher = new Azure.Network.NetworkWatcher("test", new()
 *     {
 *         Name = "acctestnw",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *     });
 *     var testAccount = new Azure.Storage.Account("test", new()
 *     {
 *         Name = "acctestsa",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *         AccountTier = "Standard",
 *         AccountKind = "StorageV2",
 *         AccountReplicationType = "LRS",
 *         EnableHttpsTrafficOnly = true,
 *     });
 *     var testAnalyticsWorkspace = new Azure.OperationalInsights.AnalyticsWorkspace("test", new()
 *     {
 *         Name = "acctestlaw",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         Sku = "PerGB2018",
 *     });
 *     var testNetworkWatcherFlowLog = new Azure.Network.NetworkWatcherFlowLog("test", new()
 *     {
 *         NetworkWatcherName = testNetworkWatcher.Name,
 *         ResourceGroupName = example.Name,
 *         Name = "example-log",
 *         NetworkSecurityGroupId = test.Id,
 *         StorageAccountId = testAccount.Id,
 *         Enabled = true,
 *         RetentionPolicy = new Azure.Network.Inputs.NetworkWatcherFlowLogRetentionPolicyArgs
 *         {
 *             Enabled = true,
 *             Days = 7,
 *         },
 *         TrafficAnalytics = new Azure.Network.Inputs.NetworkWatcherFlowLogTrafficAnalyticsArgs
 *         {
 *             Enabled = true,
 *             WorkspaceId = testAnalyticsWorkspace.WorkspaceId,
 *             WorkspaceRegion = testAnalyticsWorkspace.Location,
 *             WorkspaceResourceId = testAnalyticsWorkspace.Id,
 *             IntervalInMinutes = 10,
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/network"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/operationalinsights"
 * 	"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-resources"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		test, err := network.NewNetworkSecurityGroup(ctx, "test", &network.NetworkSecurityGroupArgs{
 * 			Name:              pulumi.String("acctestnsg"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		testNetworkWatcher, err := network.NewNetworkWatcher(ctx, "test", &network.NetworkWatcherArgs{
 * 			Name:              pulumi.String("acctestnw"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		testAccount, err := storage.NewAccount(ctx, "test", &storage.AccountArgs{
 * 			Name:                   pulumi.String("acctestsa"),
 * 			ResourceGroupName:      example.Name,
 * 			Location:               example.Location,
 * 			AccountTier:            pulumi.String("Standard"),
 * 			AccountKind:            pulumi.String("StorageV2"),
 * 			AccountReplicationType: pulumi.String("LRS"),
 * 			EnableHttpsTrafficOnly: pulumi.Bool(true),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		testAnalyticsWorkspace, err := operationalinsights.NewAnalyticsWorkspace(ctx, "test", &operationalinsights.AnalyticsWorkspaceArgs{
 * 			Name:              pulumi.String("acctestlaw"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 			Sku:               pulumi.String("PerGB2018"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = network.NewNetworkWatcherFlowLog(ctx, "test", &network.NetworkWatcherFlowLogArgs{
 * 			NetworkWatcherName:     testNetworkWatcher.Name,
 * 			ResourceGroupName:      example.Name,
 * 			Name:                   pulumi.String("example-log"),
 * 			NetworkSecurityGroupId: test.ID(),
 * 			StorageAccountId:       testAccount.ID(),
 * 			Enabled:                pulumi.Bool(true),
 * 			RetentionPolicy: &network.NetworkWatcherFlowLogRetentionPolicyArgs{
 * 				Enabled: pulumi.Bool(true),
 * 				Days:    pulumi.Int(7),
 * 			},
 * 			TrafficAnalytics: &network.NetworkWatcherFlowLogTrafficAnalyticsArgs{
 * 				Enabled:             pulumi.Bool(true),
 * 				WorkspaceId:         testAnalyticsWorkspace.WorkspaceId,
 * 				WorkspaceRegion:     testAnalyticsWorkspace.Location,
 * 				WorkspaceResourceId: testAnalyticsWorkspace.ID(),
 * 				IntervalInMinutes:   pulumi.Int(10),
 * 			},
 * 		})
 * 		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.network.NetworkSecurityGroup;
 * import com.pulumi.azure.network.NetworkSecurityGroupArgs;
 * import com.pulumi.azure.network.NetworkWatcher;
 * import com.pulumi.azure.network.NetworkWatcherArgs;
 * import com.pulumi.azure.storage.Account;
 * import com.pulumi.azure.storage.AccountArgs;
 * import com.pulumi.azure.operationalinsights.AnalyticsWorkspace;
 * import com.pulumi.azure.operationalinsights.AnalyticsWorkspaceArgs;
 * import com.pulumi.azure.network.NetworkWatcherFlowLog;
 * import com.pulumi.azure.network.NetworkWatcherFlowLogArgs;
 * import com.pulumi.azure.network.inputs.NetworkWatcherFlowLogRetentionPolicyArgs;
 * import com.pulumi.azure.network.inputs.NetworkWatcherFlowLogTrafficAnalyticsArgs;
 * 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 test = new NetworkSecurityGroup("test", NetworkSecurityGroupArgs.builder()
 *             .name("acctestnsg")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .build());
 *         var testNetworkWatcher = new NetworkWatcher("testNetworkWatcher", NetworkWatcherArgs.builder()
 *             .name("acctestnw")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .build());
 *         var testAccount = new Account("testAccount", AccountArgs.builder()
 *             .name("acctestsa")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .accountTier("Standard")
 *             .accountKind("StorageV2")
 *             .accountReplicationType("LRS")
 *             .enableHttpsTrafficOnly(true)
 *             .build());
 *         var testAnalyticsWorkspace = new AnalyticsWorkspace("testAnalyticsWorkspace", AnalyticsWorkspaceArgs.builder()
 *             .name("acctestlaw")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .sku("PerGB2018")
 *             .build());
 *         var testNetworkWatcherFlowLog = new NetworkWatcherFlowLog("testNetworkWatcherFlowLog", NetworkWatcherFlowLogArgs.builder()
 *             .networkWatcherName(testNetworkWatcher.name())
 *             .resourceGroupName(example.name())
 *             .name("example-log")
 *             .networkSecurityGroupId(test.id())
 *             .storageAccountId(testAccount.id())
 *             .enabled(true)
 *             .retentionPolicy(NetworkWatcherFlowLogRetentionPolicyArgs.builder()
 *                 .enabled(true)
 *                 .days(7)
 *                 .build())
 *             .trafficAnalytics(NetworkWatcherFlowLogTrafficAnalyticsArgs.builder()
 *                 .enabled(true)
 *                 .workspaceId(testAnalyticsWorkspace.workspaceId())
 *                 .workspaceRegion(testAnalyticsWorkspace.location())
 *                 .workspaceResourceId(testAnalyticsWorkspace.id())
 *                 .intervalInMinutes(10)
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   test:
 *     type: azure:network:NetworkSecurityGroup
 *     properties:
 *       name: acctestnsg
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *   testNetworkWatcher:
 *     type: azure:network:NetworkWatcher
 *     name: test
 *     properties:
 *       name: acctestnw
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *   testAccount:
 *     type: azure:storage:Account
 *     name: test
 *     properties:
 *       name: acctestsa
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *       accountTier: Standard
 *       accountKind: StorageV2
 *       accountReplicationType: LRS
 *       enableHttpsTrafficOnly: true
 *   testAnalyticsWorkspace:
 *     type: azure:operationalinsights:AnalyticsWorkspace
 *     name: test
 *     properties:
 *       name: acctestlaw
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       sku: PerGB2018
 *   testNetworkWatcherFlowLog:
 *     type: azure:network:NetworkWatcherFlowLog
 *     name: test
 *     properties:
 *       networkWatcherName: ${testNetworkWatcher.name}
 *       resourceGroupName: ${example.name}
 *       name: example-log
 *       networkSecurityGroupId: ${test.id}
 *       storageAccountId: ${testAccount.id}
 *       enabled: true
 *       retentionPolicy:
 *         enabled: true
 *         days: 7
 *       trafficAnalytics:
 *         enabled: true
 *         workspaceId: ${testAnalyticsWorkspace.workspaceId}
 *         workspaceRegion: ${testAnalyticsWorkspace.location}
 *         workspaceResourceId: ${testAnalyticsWorkspace.id}
 *         intervalInMinutes: 10
 * ```
 * 
 * ## Import
 * Network Watcher Flow Logs can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:network/networkWatcherFlowLog:NetworkWatcherFlowLog watcher1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/networkWatchers/watcher1/flowLogs/log1
 * ```
 */
public class NetworkWatcherFlowLog internal constructor(
    override val javaResource: com.pulumi.azure.network.NetworkWatcherFlowLog,
) : KotlinCustomResource(javaResource, NetworkWatcherFlowLogMapper) {
    /**
     * Should Network Flow Logging be Enabled?
     */
    public val enabled: Output
        get() = javaResource.enabled().applyValue({ args0 -> args0 })

    /**
     * The location where the Network Watcher Flow Log resides. Changing this forces a new resource to be created. Defaults to the `location` of the Network Watcher.
     */
    public val location: Output
        get() = javaResource.location().applyValue({ args0 -> args0 })

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

    /**
     * The ID of the Network Security Group for which to enable flow logs for. Changing this forces a new resource to be created.
     */
    public val networkSecurityGroupId: Output
        get() = javaResource.networkSecurityGroupId().applyValue({ args0 -> args0 })

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

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

    /**
     * A `retention_policy` block as documented below.
     */
    public val retentionPolicy: Output
        get() = javaResource.retentionPolicy().applyValue({ args0 ->
            args0.let({ args0 ->
                networkWatcherFlowLogRetentionPolicyToKotlin(args0)
            })
        })

    /**
     * The ID of the Storage Account where flow logs are stored.
     */
    public val storageAccountId: Output
        get() = javaResource.storageAccountId().applyValue({ args0 -> args0 })

    /**
     * A mapping of tags which should be assigned to the Network Watcher Flow Log.
     */
    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

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

    /**
     * The version (revision) of the flow log. Possible values are `1` and `2`.
     */
    public val version: Output
        get() = javaResource.version().applyValue({ args0 -> args0 })
}

public object NetworkWatcherFlowLogMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.network.NetworkWatcherFlowLog::class == javaResource::class

    override fun map(javaResource: Resource): NetworkWatcherFlowLog =
        NetworkWatcherFlowLog(javaResource as com.pulumi.azure.network.NetworkWatcherFlowLog)
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy