Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.pulumi.azure.securitycenter.kotlin.Automation.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.azure.securitycenter.kotlin
import com.pulumi.azure.securitycenter.kotlin.outputs.AutomationAction
import com.pulumi.azure.securitycenter.kotlin.outputs.AutomationSource
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.securitycenter.kotlin.outputs.AutomationAction.Companion.toKotlin as automationActionToKotlin
import com.pulumi.azure.securitycenter.kotlin.outputs.AutomationSource.Companion.toKotlin as automationSourceToKotlin
/**
* Builder for [Automation].
*/
@PulumiTagMarker
public class AutomationResourceBuilder internal constructor() {
public var name: String? = null
public var args: AutomationArgs = AutomationArgs()
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 AutomationArgsBuilder.() -> Unit) {
val builder = AutomationArgsBuilder()
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(): Automation {
val builtJavaResource = com.pulumi.azure.securitycenter.Automation(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return Automation(builtJavaResource)
}
}
/**
* Manages Security Center Automation and Continuous Export. This resource supports three types of destination in the `action`, Logic Apps, Log Analytics and Event Hubs
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as azure from "@pulumi/azure";
* const current = azure.core.getClientConfig({});
* const example = new azure.core.ResourceGroup("example", {
* name: "example-resources",
* location: "West Europe",
* });
* const exampleEventHubNamespace = new azure.eventhub.EventHubNamespace("example", {
* name: "example-namespace",
* location: example.location,
* resourceGroupName: example.name,
* sku: "Standard",
* capacity: 2,
* });
* const exampleEventHub = new azure.eventhub.EventHub("example", {
* name: "acceptanceTestEventHub",
* namespaceName: exampleEventHubNamespace.name,
* resourceGroupName: example.name,
* partitionCount: 2,
* messageRetention: 2,
* });
* const exampleAuthorizationRule = new azure.eventhub.AuthorizationRule("example", {
* name: "example-rule",
* namespaceName: exampleEventHubNamespace.name,
* eventhubName: exampleEventHub.name,
* resourceGroupName: example.name,
* listen: true,
* send: false,
* manage: false,
* });
* const exampleAutomation = new azure.securitycenter.Automation("example", {
* name: "example-automation",
* location: example.location,
* resourceGroupName: example.name,
* actions: [{
* type: "eventhub",
* resourceId: exampleEventHub.id,
* connectionString: exampleAuthorizationRule.primaryConnectionString,
* }],
* sources: [{
* eventSource: "Alerts",
* ruleSets: [{
* rules: [{
* propertyPath: "properties.metadata.severity",
* operator: "Equals",
* expectedValue: "High",
* propertyType: "String",
* }],
* }],
* }],
* scopes: [current.then(current => `/subscriptions/${current.subscriptionId}`)],
* });
* ```
* ```python
* import pulumi
* import pulumi_azure as azure
* current = azure.core.get_client_config()
* example = azure.core.ResourceGroup("example",
* name="example-resources",
* location="West Europe")
* example_event_hub_namespace = azure.eventhub.EventHubNamespace("example",
* name="example-namespace",
* location=example.location,
* resource_group_name=example.name,
* sku="Standard",
* capacity=2)
* example_event_hub = azure.eventhub.EventHub("example",
* name="acceptanceTestEventHub",
* namespace_name=example_event_hub_namespace.name,
* resource_group_name=example.name,
* partition_count=2,
* message_retention=2)
* example_authorization_rule = azure.eventhub.AuthorizationRule("example",
* name="example-rule",
* namespace_name=example_event_hub_namespace.name,
* eventhub_name=example_event_hub.name,
* resource_group_name=example.name,
* listen=True,
* send=False,
* manage=False)
* example_automation = azure.securitycenter.Automation("example",
* name="example-automation",
* location=example.location,
* resource_group_name=example.name,
* actions=[{
* "type": "eventhub",
* "resource_id": example_event_hub.id,
* "connection_string": example_authorization_rule.primary_connection_string,
* }],
* sources=[{
* "event_source": "Alerts",
* "rule_sets": [{
* "rules": [{
* "property_path": "properties.metadata.severity",
* "operator": "Equals",
* "expected_value": "High",
* "property_type": "String",
* }],
* }],
* }],
* scopes=[f"/subscriptions/{current.subscription_id}"])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Azure = Pulumi.Azure;
* return await Deployment.RunAsync(() =>
* {
* var current = Azure.Core.GetClientConfig.Invoke();
* var example = new Azure.Core.ResourceGroup("example", new()
* {
* Name = "example-resources",
* Location = "West Europe",
* });
* var exampleEventHubNamespace = new Azure.EventHub.EventHubNamespace("example", new()
* {
* Name = "example-namespace",
* Location = example.Location,
* ResourceGroupName = example.Name,
* Sku = "Standard",
* Capacity = 2,
* });
* var exampleEventHub = new Azure.EventHub.EventHub("example", new()
* {
* Name = "acceptanceTestEventHub",
* NamespaceName = exampleEventHubNamespace.Name,
* ResourceGroupName = example.Name,
* PartitionCount = 2,
* MessageRetention = 2,
* });
* var exampleAuthorizationRule = new Azure.EventHub.AuthorizationRule("example", new()
* {
* Name = "example-rule",
* NamespaceName = exampleEventHubNamespace.Name,
* EventhubName = exampleEventHub.Name,
* ResourceGroupName = example.Name,
* Listen = true,
* Send = false,
* Manage = false,
* });
* var exampleAutomation = new Azure.SecurityCenter.Automation("example", new()
* {
* Name = "example-automation",
* Location = example.Location,
* ResourceGroupName = example.Name,
* Actions = new[]
* {
* new Azure.SecurityCenter.Inputs.AutomationActionArgs
* {
* Type = "eventhub",
* ResourceId = exampleEventHub.Id,
* ConnectionString = exampleAuthorizationRule.PrimaryConnectionString,
* },
* },
* Sources = new[]
* {
* new Azure.SecurityCenter.Inputs.AutomationSourceArgs
* {
* EventSource = "Alerts",
* RuleSets = new[]
* {
* new Azure.SecurityCenter.Inputs.AutomationSourceRuleSetArgs
* {
* Rules = new[]
* {
* new Azure.SecurityCenter.Inputs.AutomationSourceRuleSetRuleArgs
* {
* PropertyPath = "properties.metadata.severity",
* Operator = "Equals",
* ExpectedValue = "High",
* PropertyType = "String",
* },
* },
* },
* },
* },
* },
* Scopes = new[]
* {
* $"/subscriptions/{current.Apply(getClientConfigResult => getClientConfigResult.SubscriptionId)}",
* },
* });
* });
* ```
* ```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/securitycenter"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* current, err := core.GetClientConfig(ctx, nil, nil)
* if err != nil {
* return err
* }
* example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
* Name: pulumi.String("example-resources"),
* Location: pulumi.String("West Europe"),
* })
* if err != nil {
* return err
* }
* exampleEventHubNamespace, err := eventhub.NewEventHubNamespace(ctx, "example", &eventhub.EventHubNamespaceArgs{
* Name: pulumi.String("example-namespace"),
* Location: example.Location,
* ResourceGroupName: example.Name,
* Sku: pulumi.String("Standard"),
* Capacity: pulumi.Int(2),
* })
* if err != nil {
* return err
* }
* exampleEventHub, err := eventhub.NewEventHub(ctx, "example", &eventhub.EventHubArgs{
* Name: pulumi.String("acceptanceTestEventHub"),
* NamespaceName: exampleEventHubNamespace.Name,
* ResourceGroupName: example.Name,
* PartitionCount: pulumi.Int(2),
* MessageRetention: pulumi.Int(2),
* })
* if err != nil {
* return err
* }
* exampleAuthorizationRule, err := eventhub.NewAuthorizationRule(ctx, "example", &eventhub.AuthorizationRuleArgs{
* Name: pulumi.String("example-rule"),
* NamespaceName: exampleEventHubNamespace.Name,
* EventhubName: exampleEventHub.Name,
* ResourceGroupName: example.Name,
* Listen: pulumi.Bool(true),
* Send: pulumi.Bool(false),
* Manage: pulumi.Bool(false),
* })
* if err != nil {
* return err
* }
* _, err = securitycenter.NewAutomation(ctx, "example", &securitycenter.AutomationArgs{
* Name: pulumi.String("example-automation"),
* Location: example.Location,
* ResourceGroupName: example.Name,
* Actions: securitycenter.AutomationActionArray{
* &securitycenter.AutomationActionArgs{
* Type: pulumi.String("eventhub"),
* ResourceId: exampleEventHub.ID(),
* ConnectionString: exampleAuthorizationRule.PrimaryConnectionString,
* },
* },
* Sources: securitycenter.AutomationSourceArray{
* &securitycenter.AutomationSourceArgs{
* EventSource: pulumi.String("Alerts"),
* RuleSets: securitycenter.AutomationSourceRuleSetArray{
* &securitycenter.AutomationSourceRuleSetArgs{
* Rules: securitycenter.AutomationSourceRuleSetRuleArray{
* &securitycenter.AutomationSourceRuleSetRuleArgs{
* PropertyPath: pulumi.String("properties.metadata.severity"),
* Operator: pulumi.String("Equals"),
* ExpectedValue: pulumi.String("High"),
* PropertyType: pulumi.String("String"),
* },
* },
* },
* },
* },
* },
* Scopes: pulumi.StringArray{
* pulumi.Sprintf("/subscriptions/%v", current.SubscriptionId),
* },
* })
* 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.CoreFunctions;
* import com.pulumi.azure.core.ResourceGroup;
* import com.pulumi.azure.core.ResourceGroupArgs;
* import com.pulumi.azure.eventhub.EventHubNamespace;
* import com.pulumi.azure.eventhub.EventHubNamespaceArgs;
* import com.pulumi.azure.eventhub.EventHub;
* import com.pulumi.azure.eventhub.EventHubArgs;
* import com.pulumi.azure.eventhub.AuthorizationRule;
* import com.pulumi.azure.eventhub.AuthorizationRuleArgs;
* import com.pulumi.azure.securitycenter.Automation;
* import com.pulumi.azure.securitycenter.AutomationArgs;
* import com.pulumi.azure.securitycenter.inputs.AutomationActionArgs;
* import com.pulumi.azure.securitycenter.inputs.AutomationSourceArgs;
* 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) {
* final var current = CoreFunctions.getClientConfig();
* var example = new ResourceGroup("example", ResourceGroupArgs.builder()
* .name("example-resources")
* .location("West Europe")
* .build());
* var exampleEventHubNamespace = new EventHubNamespace("exampleEventHubNamespace", EventHubNamespaceArgs.builder()
* .name("example-namespace")
* .location(example.location())
* .resourceGroupName(example.name())
* .sku("Standard")
* .capacity(2)
* .build());
* var exampleEventHub = new EventHub("exampleEventHub", EventHubArgs.builder()
* .name("acceptanceTestEventHub")
* .namespaceName(exampleEventHubNamespace.name())
* .resourceGroupName(example.name())
* .partitionCount(2)
* .messageRetention(2)
* .build());
* var exampleAuthorizationRule = new AuthorizationRule("exampleAuthorizationRule", AuthorizationRuleArgs.builder()
* .name("example-rule")
* .namespaceName(exampleEventHubNamespace.name())
* .eventhubName(exampleEventHub.name())
* .resourceGroupName(example.name())
* .listen(true)
* .send(false)
* .manage(false)
* .build());
* var exampleAutomation = new Automation("exampleAutomation", AutomationArgs.builder()
* .name("example-automation")
* .location(example.location())
* .resourceGroupName(example.name())
* .actions(AutomationActionArgs.builder()
* .type("eventhub")
* .resourceId(exampleEventHub.id())
* .connectionString(exampleAuthorizationRule.primaryConnectionString())
* .build())
* .sources(AutomationSourceArgs.builder()
* .eventSource("Alerts")
* .ruleSets(AutomationSourceRuleSetArgs.builder()
* .rules(AutomationSourceRuleSetRuleArgs.builder()
* .propertyPath("properties.metadata.severity")
* .operator("Equals")
* .expectedValue("High")
* .propertyType("String")
* .build())
* .build())
* .build())
* .scopes(String.format("/subscriptions/%s", current.applyValue(getClientConfigResult -> getClientConfigResult.subscriptionId())))
* .build());
* }
* }
* ```
* ```yaml
* resources:
* example:
* type: azure:core:ResourceGroup
* properties:
* name: example-resources
* location: West Europe
* exampleEventHubNamespace:
* type: azure:eventhub:EventHubNamespace
* name: example
* properties:
* name: example-namespace
* location: ${example.location}
* resourceGroupName: ${example.name}
* sku: Standard
* capacity: 2
* exampleEventHub:
* type: azure:eventhub:EventHub
* name: example
* properties:
* name: acceptanceTestEventHub
* namespaceName: ${exampleEventHubNamespace.name}
* resourceGroupName: ${example.name}
* partitionCount: 2
* messageRetention: 2
* exampleAuthorizationRule:
* type: azure:eventhub:AuthorizationRule
* name: example
* properties:
* name: example-rule
* namespaceName: ${exampleEventHubNamespace.name}
* eventhubName: ${exampleEventHub.name}
* resourceGroupName: ${example.name}
* listen: true
* send: false
* manage: false
* exampleAutomation:
* type: azure:securitycenter:Automation
* name: example
* properties:
* name: example-automation
* location: ${example.location}
* resourceGroupName: ${example.name}
* actions:
* - type: eventhub
* resourceId: ${exampleEventHub.id}
* connectionString: ${exampleAuthorizationRule.primaryConnectionString}
* sources:
* - eventSource: Alerts
* ruleSets:
* - rules:
* - propertyPath: properties.metadata.severity
* operator: Equals
* expectedValue: High
* propertyType: String
* scopes:
* - /subscriptions/${current.subscriptionId}
* variables:
* current:
* fn::invoke:
* Function: azure:core:getClientConfig
* Arguments: {}
* ```
*
* ## Import
* Security Center Automations can be imported using the `resource id`, e.g.
* ```sh
* $ pulumi import azure:securitycenter/automation:Automation example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Security/automations/automation1
* ```
*/
public class Automation internal constructor(
override val javaResource: com.pulumi.azure.securitycenter.Automation,
) : KotlinCustomResource(javaResource, AutomationMapper) {
/**
* One or more `action` blocks as defined below. An `action` tells this automation where the data is to be sent to upon being evaluated by the rules in the `source`.
*/
public val actions: Output>
get() = javaResource.actions().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
automationActionToKotlin(args0)
})
})
})
/**
* Specifies the description for the Security Center Automation.
*/
public val description: Output?
get() = javaResource.description().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* Boolean to enable or disable this Security Center Automation. Defaults to `true`.
*/
public val enabled: Output?
get() = javaResource.enabled().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* The Azure Region where the Security Center Automation should exist. Changing this forces a new Security Center Automation to be created.
*/
public val location: Output
get() = javaResource.location().applyValue({ args0 -> args0 })
/**
* The name which should be used for this Security Center Automation. Changing this forces a new Security Center Automation to be created.
* > **NOTE:** For the automation to appear in Azure Portal correctly under Microsoft Defender for Cloud > Environment Settings > Account > Continuous Export, either `ExportToWorkspace` or `ExportToEventHub` must be used.
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* The name of the Resource Group where the Security Center Automation should exist. Changing this forces a new Security Center Automation to be created.
*/
public val resourceGroupName: Output
get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })
/**
* A list of scopes on which the automation logic is applied, at least one is required. Supported scopes are a subscription (in this format `/subscriptions/00000000-0000-0000-0000-000000000000`) or a resource group under that subscription (in the format `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example`). The automation will only apply on defined scopes.
*/
public val scopes: Output>
get() = javaResource.scopes().applyValue({ args0 -> args0.map({ args0 -> args0 }) })
/**
* One or more `source` blocks as defined below. A `source` defines what data types will be processed and a set of rules to filter that data.
*/
public val sources: Output>
get() = javaResource.sources().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
automationSourceToKotlin(args0)
})
})
})
/**
* A mapping of tags assigned to the resource.
*/
public val tags: Output>?
get() = javaResource.tags().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0.key.to(args0.value)
}).toMap()
}).orElse(null)
})
}
public object AutomationMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.azure.securitycenter.Automation::class == javaResource::class
override fun map(javaResource: Resource): Automation = Automation(
javaResource as
com.pulumi.azure.securitycenter.Automation,
)
}
/**
* @see [Automation].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [Automation].
*/
public suspend fun automation(name: String, block: suspend AutomationResourceBuilder.() -> Unit): Automation {
val builder = AutomationResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [Automation].
* @param name The _unique_ name of the resulting resource.
*/
public fun automation(name: String): Automation {
val builder = AutomationResourceBuilder()
builder.name(name)
return builder.build()
}