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

com.pulumi.azure.role.kotlin.Definition.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.role.kotlin

import com.pulumi.azure.role.kotlin.outputs.DefinitionPermission
import com.pulumi.azure.role.kotlin.outputs.DefinitionPermission.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.Deprecated
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List

/**
 * Builder for [Definition].
 */
@PulumiTagMarker
@Deprecated(
    message = """
azure.role.Definition has been deprecated in favor of azure.authorization.RoleDefinition
""",
)
public class DefinitionResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: DefinitionArgs = DefinitionArgs()

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

/**
 * Manages a custom Role Definition, used to assign Roles to Users/Principals. See ['Understand role definitions'](https://docs.microsoft.com/azure/role-based-access-control/role-definitions) in the Azure documentation for more details.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const primary = azure.core.getSubscription({});
 * const example = new azure.authorization.RoleDefinition("example", {
 *     name: "my-custom-role",
 *     scope: primary.then(primary => primary.id),
 *     description: "This is a custom role created",
 *     permissions: [{
 *         actions: ["*"],
 *         notActions: [],
 *     }],
 *     assignableScopes: [primary.then(primary => primary.id)],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * primary = azure.core.get_subscription()
 * example = azure.authorization.RoleDefinition("example",
 *     name="my-custom-role",
 *     scope=primary.id,
 *     description="This is a custom role created",
 *     permissions=[{
 *         "actions": ["*"],
 *         "not_actions": [],
 *     }],
 *     assignable_scopes=[primary.id])
 * ```
 * ```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 example = new Azure.Authorization.RoleDefinition("example", new()
 *     {
 *         Name = "my-custom-role",
 *         Scope = primary.Apply(getSubscriptionResult => getSubscriptionResult.Id),
 *         Description = "This is a custom role created",
 *         Permissions = new[]
 *         {
 *             new Azure.Authorization.Inputs.RoleDefinitionPermissionArgs
 *             {
 *                 Actions = new[]
 *                 {
 *                     "*",
 *                 },
 *                 NotActions = new() { },
 *             },
 *         },
 *         AssignableScopes = new[]
 *         {
 *             primary.Apply(getSubscriptionResult => getSubscriptionResult.Id),
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"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
 * 		}
 * 		_, err = authorization.NewRoleDefinition(ctx, "example", &authorization.RoleDefinitionArgs{
 * 			Name:        pulumi.String("my-custom-role"),
 * 			Scope:       pulumi.String(primary.Id),
 * 			Description: pulumi.String("This is a custom role created"),
 * 			Permissions: authorization.RoleDefinitionPermissionArray{
 * 				&authorization.RoleDefinitionPermissionArgs{
 * 					Actions: pulumi.StringArray{
 * 						pulumi.String("*"),
 * 					},
 * 					NotActions: pulumi.StringArray{},
 * 				},
 * 			},
 * 			AssignableScopes: pulumi.StringArray{
 * 				pulumi.String(primary.Id),
 * 			},
 * 		})
 * 		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.RoleDefinition;
 * import com.pulumi.azure.authorization.RoleDefinitionArgs;
 * import com.pulumi.azure.authorization.inputs.RoleDefinitionPermissionArgs;
 * 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();
 *         var example = new RoleDefinition("example", RoleDefinitionArgs.builder()
 *             .name("my-custom-role")
 *             .scope(primary.applyValue(getSubscriptionResult -> getSubscriptionResult.id()))
 *             .description("This is a custom role created")
 *             .permissions(RoleDefinitionPermissionArgs.builder()
 *                 .actions("*")
 *                 .notActions()
 *                 .build())
 *             .assignableScopes(primary.applyValue(getSubscriptionResult -> getSubscriptionResult.id()))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:authorization:RoleDefinition
 *     properties:
 *       name: my-custom-role
 *       scope: ${primary.id}
 *       description: This is a custom role created
 *       permissions:
 *         - actions:
 *             - '*'
 *           notActions: []
 *       assignableScopes:
 *         - ${primary.id}
 * variables:
 *   primary:
 *     fn::invoke:
 *       Function: azure:core:getSubscription
 *       Arguments: {}
 * ```
 * 
 * ## Import
 * Role Definitions can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:role/definition:Definition example "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/00000000-0000-0000-0000-000000000000|/subscriptions/00000000-0000-0000-0000-000000000000"
 * ```
 */
@Deprecated(
    message = """
azure.role.Definition has been deprecated in favor of azure.authorization.RoleDefinition
""",
)
public class Definition internal constructor(
    override val javaResource: com.pulumi.azure.role.Definition,
) : KotlinCustomResource(javaResource, DefinitionMapper) {
    /**
     * One or more assignable scopes for this Role Definition, such as `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333`, `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup`, or `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM`.
     * > **NOTE:** The value for `scope` is automatically included in this list if no other values supplied.
     */
    public val assignableScopes: Output>
        get() = javaResource.assignableScopes().applyValue({ args0 -> args0.map({ args0 -> args0 }) })

    /**
     * A description of the Role Definition.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The name of the Role Definition.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

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

    /**
     * A unique UUID/GUID which identifies this role - one will be generated if not specified. Changing this forces a new resource to be created.
     */
    public val roleDefinitionId: Output
        get() = javaResource.roleDefinitionId().applyValue({ args0 -> args0 })

    /**
     * The Azure Resource Manager ID for the resource.
     */
    public val roleDefinitionResourceId: Output
        get() = javaResource.roleDefinitionResourceId().applyValue({ args0 -> args0 })

    /**
     * The scope at which the Role Definition applies to, such as `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333`, `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup`, or `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM`. It is recommended to use the first entry of the `assignable_scopes`. Changing this forces a new resource to be created.
     */
    public val scope: Output
        get() = javaResource.scope().applyValue({ args0 -> args0 })
}

public object DefinitionMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.role.Definition::class == javaResource::class

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

/**
 * @see [Definition].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [Definition].
 */
@Deprecated(
    message = """
azure.role.Definition has been deprecated in favor of azure.authorization.RoleDefinition
""",
)
public suspend fun definition(name: String, block: suspend DefinitionResourceBuilder.() -> Unit): Definition {
    val builder = DefinitionResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [Definition].
 * @param name The _unique_ name of the resulting resource.
 */
@Deprecated(
    message = """
azure.role.Definition has been deprecated in favor of azure.authorization.RoleDefinition
""",
)
public fun definition(name: String): Definition {
    val builder = DefinitionResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy