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.newrelic.kotlin.Monitor.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.azure.newrelic.kotlin
import com.pulumi.azure.newrelic.kotlin.outputs.MonitorIdentity
import com.pulumi.azure.newrelic.kotlin.outputs.MonitorPlan
import com.pulumi.azure.newrelic.kotlin.outputs.MonitorUser
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 com.pulumi.azure.newrelic.kotlin.outputs.MonitorIdentity.Companion.toKotlin as monitorIdentityToKotlin
import com.pulumi.azure.newrelic.kotlin.outputs.MonitorPlan.Companion.toKotlin as monitorPlanToKotlin
import com.pulumi.azure.newrelic.kotlin.outputs.MonitorUser.Companion.toKotlin as monitorUserToKotlin
/**
* Builder for [Monitor].
*/
@PulumiTagMarker
public class MonitorResourceBuilder internal constructor() {
public var name: String? = null
public var args: MonitorArgs = MonitorArgs()
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 MonitorArgsBuilder.() -> Unit) {
val builder = MonitorArgsBuilder()
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(): Monitor {
val builtJavaResource = com.pulumi.azure.newrelic.Monitor(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return Monitor(builtJavaResource)
}
}
/**
* Manages an Azure Native New Relic Monitor.
* ## 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: "East US",
* });
* const exampleMonitor = new azure.newrelic.Monitor("example", {
* name: "example-nrm",
* resourceGroupName: example.name,
* location: example.location,
* plan: {
* effectiveDate: "2023-06-06T00:00:00Z",
* },
* user: {
* email: "[email protected] ",
* firstName: "Example",
* lastName: "User",
* phoneNumber: "+12313803556",
* },
* identity: {
* type: "SystemAssigned",
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_azure as azure
* example = azure.core.ResourceGroup("example",
* name="example-resources",
* location="East US")
* example_monitor = azure.newrelic.Monitor("example",
* name="example-nrm",
* resource_group_name=example.name,
* location=example.location,
* plan={
* "effective_date": "2023-06-06T00:00:00Z",
* },
* user={
* "email": "[email protected] ",
* "first_name": "Example",
* "last_name": "User",
* "phone_number": "+12313803556",
* },
* identity={
* "type": "SystemAssigned",
* })
* ```
* ```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 = "East US",
* });
* var exampleMonitor = new Azure.NewRelic.Monitor("example", new()
* {
* Name = "example-nrm",
* ResourceGroupName = example.Name,
* Location = example.Location,
* Plan = new Azure.NewRelic.Inputs.MonitorPlanArgs
* {
* EffectiveDate = "2023-06-06T00:00:00Z",
* },
* User = new Azure.NewRelic.Inputs.MonitorUserArgs
* {
* Email = "[email protected] ",
* FirstName = "Example",
* LastName = "User",
* PhoneNumber = "+12313803556",
* },
* Identity = new Azure.NewRelic.Inputs.MonitorIdentityArgs
* {
* Type = "SystemAssigned",
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
* "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/newrelic"
* "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("East US"),
* })
* if err != nil {
* return err
* }
* _, err = newrelic.NewMonitor(ctx, "example", &newrelic.MonitorArgs{
* Name: pulumi.String("example-nrm"),
* ResourceGroupName: example.Name,
* Location: example.Location,
* Plan: &newrelic.MonitorPlanArgs{
* EffectiveDate: pulumi.String("2023-06-06T00:00:00Z"),
* },
* User: &newrelic.MonitorUserArgs{
* Email: pulumi.String("[email protected] "),
* FirstName: pulumi.String("Example"),
* LastName: pulumi.String("User"),
* PhoneNumber: pulumi.String("+12313803556"),
* },
* Identity: &newrelic.MonitorIdentityArgs{
* Type: pulumi.String("SystemAssigned"),
* },
* })
* 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.newrelic.Monitor;
* import com.pulumi.azure.newrelic.MonitorArgs;
* import com.pulumi.azure.newrelic.inputs.MonitorPlanArgs;
* import com.pulumi.azure.newrelic.inputs.MonitorUserArgs;
* import com.pulumi.azure.newrelic.inputs.MonitorIdentityArgs;
* 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("East US")
* .build());
* var exampleMonitor = new Monitor("exampleMonitor", MonitorArgs.builder()
* .name("example-nrm")
* .resourceGroupName(example.name())
* .location(example.location())
* .plan(MonitorPlanArgs.builder()
* .effectiveDate("2023-06-06T00:00:00Z")
* .build())
* .user(MonitorUserArgs.builder()
* .email("[email protected] ")
* .firstName("Example")
* .lastName("User")
* .phoneNumber("+12313803556")
* .build())
* .identity(MonitorIdentityArgs.builder()
* .type("SystemAssigned")
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* example:
* type: azure:core:ResourceGroup
* properties:
* name: example-resources
* location: East US
* exampleMonitor:
* type: azure:newrelic:Monitor
* name: example
* properties:
* name: example-nrm
* resourceGroupName: ${example.name}
* location: ${example.location}
* plan:
* effectiveDate: 2023-06-06T00:00:00Z
* user:
* email: [email protected]
* firstName: Example
* lastName: User
* phoneNumber: '+12313803556'
* identity:
* type: SystemAssigned
* ```
*
* ## Role Assignment
* To enable metrics flow, perform role assignment on the identity created above. `Monitoring reader(43d0d8ad-25c7-4714-9337-8ba259a9fe05)` role is required .
* ### Role assignment on the monitor created
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as azure from "@pulumi/azure";
* const primary = azure.core.getSubscription({});
* const monitoringReader = azure.authorization.getRoleDefinition({
* name: "Monitoring Reader",
* });
* const example = new azure.authorization.Assignment("example", {
* scope: primary.then(primary => primary.id),
* roleDefinitionId: Promise.all([primary, monitoringReader]).then(([primary, monitoringReader]) => `${primary.id}${monitoringReader.id}`),
* principalId: exampleAzurermNewRelicMonitor.identity[0].principalId,
* });
* ```
* ```python
* import pulumi
* import pulumi_azure as azure
* primary = azure.core.get_subscription()
* monitoring_reader = azure.authorization.get_role_definition(name="Monitoring Reader")
* example = azure.authorization.Assignment("example",
* scope=primary.id,
* role_definition_id=f"{primary.id}{monitoring_reader.id}",
* principal_id=example_azurerm_new_relic_monitor["identity"][0]["principalId"])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Azure = Pulumi.Azure;
* return await Deployment.RunAsync(() =>
* {
* var primary = Azure.Core.GetSubscription.Invoke();
* var monitoringReader = Azure.Authorization.GetRoleDefinition.Invoke(new()
* {
* Name = "Monitoring Reader",
* });
* var example = new Azure.Authorization.Assignment("example", new()
* {
* Scope = primary.Apply(getSubscriptionResult => getSubscriptionResult.Id),
* RoleDefinitionId = Output.Tuple(primary, monitoringReader).Apply(values =>
* {
* var primary = values.Item1;
* var monitoringReader = values.Item2;
* return $"{primary.Apply(getSubscriptionResult => getSubscriptionResult.Id)}{monitoringReader.Apply(getRoleDefinitionResult => getRoleDefinitionResult.Id)}";
* }),
* PrincipalId = exampleAzurermNewRelicMonitor.Identity[0].PrincipalId,
* });
* });
* ```
* ```go
* package main
* import (
* "fmt"
* "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/authorization"
* "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* primary, err := core.LookupSubscription(ctx, nil, nil)
* if err != nil {
* return err
* }
* monitoringReader, err := authorization.LookupRoleDefinition(ctx, &authorization.LookupRoleDefinitionArgs{
* Name: pulumi.StringRef("Monitoring Reader"),
* }, nil)
* if err != nil {
* return err
* }
* _, err = authorization.NewAssignment(ctx, "example", &authorization.AssignmentArgs{
* Scope: pulumi.String(primary.Id),
* RoleDefinitionId: pulumi.Sprintf("%v%v", primary.Id, monitoringReader.Id),
* PrincipalId: pulumi.Any(exampleAzurermNewRelicMonitor.Identity[0].PrincipalId),
* })
* 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.inputs.GetSubscriptionArgs;
* import com.pulumi.azure.authorization.AuthorizationFunctions;
* import com.pulumi.azure.authorization.inputs.GetRoleDefinitionArgs;
* import com.pulumi.azure.authorization.Assignment;
* import com.pulumi.azure.authorization.AssignmentArgs;
* 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 primary = CoreFunctions.getSubscription();
* final var monitoringReader = AuthorizationFunctions.getRoleDefinition(GetRoleDefinitionArgs.builder()
* .name("Monitoring Reader")
* .build());
* var example = new Assignment("example", AssignmentArgs.builder()
* .scope(primary.applyValue(getSubscriptionResult -> getSubscriptionResult.id()))
* .roleDefinitionId(String.format("%s%s", primary.applyValue(getSubscriptionResult -> getSubscriptionResult.id()),monitoringReader.applyValue(getRoleDefinitionResult -> getRoleDefinitionResult.id())))
* .principalId(exampleAzurermNewRelicMonitor.identity()[0].principalId())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* example:
* type: azure:authorization:Assignment
* properties:
* scope: ${primary.id}
* roleDefinitionId: ${primary.id}${monitoringReader.id}
* principalId: ${exampleAzurermNewRelicMonitor.identity[0].principalId}
* variables:
* primary:
* fn::invoke:
* Function: azure:core:getSubscription
* Arguments: {}
* monitoringReader:
* fn::invoke:
* Function: azure:authorization:getRoleDefinition
* Arguments:
* name: Monitoring Reader
* ```
*
* ## Import
* Azure Native New Relic Monitor can be imported using the `resource id`, e.g.
* ```sh
* $ pulumi import azure:newrelic/monitor:Monitor example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/NewRelic.Observability/monitors/monitor1
* ```
*/
public class Monitor internal constructor(
override val javaResource: com.pulumi.azure.newrelic.Monitor,
) : KotlinCustomResource(javaResource, MonitorMapper) {
/**
* Specifies the source of account creation. Possible values are `LIFTR` and `NEWRELIC`. Defaults to `LIFTR`. Changing this forces a new Azure Native New Relic Monitor to be created.
*/
public val accountCreationSource: Output?
get() = javaResource.accountCreationSource().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* Specifies the account id. Changing this forces a new Azure Native New Relic Monitor to be created.
* > **NOTE:** The value of `account_id` must come from an Azure Native New Relic Monitor instance of another different subscription.
*/
public val accountId: Output
get() = javaResource.accountId().applyValue({ args0 -> args0 })
/**
* An `identity` block as defined below. Changing this forces a new Azure Native New Relic Monitor to be created.
*/
public val identity: Output?
get() = javaResource.identity().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
monitorIdentityToKotlin(args0)
})
}).orElse(null)
})
/**
* Specifies the ingestion key of account. Changing this forces a new Azure Native New Relic Monitor to be created.
*/
public val ingestionKey: Output?
get() = javaResource.ingestionKey().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* Specifies the Azure Region where the Azure Native New Relic Monitor should exist. Changing this forces a new Azure Native New Relic Monitor to be created.
*/
public val location: Output
get() = javaResource.location().applyValue({ args0 -> args0 })
/**
* Specifies the name which should be used for this Azure Native New Relic Monitor. Changing this forces a new Azure Native New Relic Monitor to be created.
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* Specifies the source of org creation. Possible values are `LIFTR` and `NEWRELIC`. Defaults to `LIFTR`. Changing this forces a new Azure Native New Relic Monitor to be created.
*/
public val orgCreationSource: Output?
get() = javaResource.orgCreationSource().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* Specifies the organization id. Changing this forces a new Azure Native New Relic Monitor to be created.
* > **NOTE:** The value of `organization_id` must come from an Azure Native New Relic Monitor instance of another different subscription.
*/
public val organizationId: Output
get() = javaResource.organizationId().applyValue({ args0 -> args0 })
/**
* A `plan` block as defined below. Changing this forces a new Azure Native New Relic Monitor to be created.
*/
public val plan: Output
get() = javaResource.plan().applyValue({ args0 ->
args0.let({ args0 ->
monitorPlanToKotlin(args0)
})
})
/**
* Specifies the name of the Resource Group where the Azure Native New Relic Monitor should exist. Changing this forces a new Azure Native New Relic Monitor to be created.
*/
public val resourceGroupName: Output
get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })
/**
* A `user` block as defined below. Changing this forces a new Azure Native New Relic Monitor to be created.
*/
public val user: Output
get() = javaResource.user().applyValue({ args0 ->
args0.let({ args0 ->
monitorUserToKotlin(args0)
})
})
/**
* Specifies the user id. Changing this forces a new Azure Native New Relic Monitor to be created.
*/
public val userId: Output?
get() = javaResource.userId().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
}
public object MonitorMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.azure.newrelic.Monitor::class == javaResource::class
override fun map(javaResource: Resource): Monitor = Monitor(
javaResource as
com.pulumi.azure.newrelic.Monitor,
)
}
/**
* @see [Monitor].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [Monitor].
*/
public suspend fun monitor(name: String, block: suspend MonitorResourceBuilder.() -> Unit): Monitor {
val builder = MonitorResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [Monitor].
* @param name The _unique_ name of the resulting resource.
*/
public fun monitor(name: String): Monitor {
val builder = MonitorResourceBuilder()
builder.name(name)
return builder.build()
}