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

com.pulumi.azure.storage.kotlin.LocalUser.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.storage.kotlin

import com.pulumi.azure.storage.kotlin.outputs.LocalUserPermissionScope
import com.pulumi.azure.storage.kotlin.outputs.LocalUserSshAuthorizedKey
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 com.pulumi.azure.storage.kotlin.outputs.LocalUserPermissionScope.Companion.toKotlin as localUserPermissionScopeToKotlin
import com.pulumi.azure.storage.kotlin.outputs.LocalUserSshAuthorizedKey.Companion.toKotlin as localUserSshAuthorizedKeyToKotlin

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

    public var args: LocalUserArgs = LocalUserArgs()

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

/**
 * Manages a Storage Account Local User.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-rg",
 *     location: "WestEurope",
 * });
 * const exampleAccount = new azure.storage.Account("example", {
 *     name: "example-account",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     accountKind: "StorageV2",
 *     accountTier: "Standard",
 *     accountReplicationType: "LRS",
 *     isHnsEnabled: true,
 * });
 * const exampleContainer = new azure.storage.Container("example", {
 *     name: "example-container",
 *     storageAccountName: exampleAccount.name,
 * });
 * const exampleLocalUser = new azure.storage.LocalUser("example", {
 *     name: "user1",
 *     storageAccountId: exampleAccount.id,
 *     sshKeyEnabled: true,
 *     sshPasswordEnabled: true,
 *     homeDirectory: "example_path",
 *     sshAuthorizedKeys: [
 *         {
 *             description: "key1",
 *             key: firstPublicKey,
 *         },
 *         {
 *             description: "key2",
 *             key: secondPublicKey,
 *         },
 *     ],
 *     permissionScopes: [{
 *         permissions: {
 *             read: true,
 *             create: true,
 *         },
 *         service: "blob",
 *         resourceName: exampleContainer.name,
 *     }],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-rg",
 *     location="WestEurope")
 * example_account = azure.storage.Account("example",
 *     name="example-account",
 *     resource_group_name=example.name,
 *     location=example.location,
 *     account_kind="StorageV2",
 *     account_tier="Standard",
 *     account_replication_type="LRS",
 *     is_hns_enabled=True)
 * example_container = azure.storage.Container("example",
 *     name="example-container",
 *     storage_account_name=example_account.name)
 * example_local_user = azure.storage.LocalUser("example",
 *     name="user1",
 *     storage_account_id=example_account.id,
 *     ssh_key_enabled=True,
 *     ssh_password_enabled=True,
 *     home_directory="example_path",
 *     ssh_authorized_keys=[
 *         {
 *             "description": "key1",
 *             "key": first_public_key,
 *         },
 *         {
 *             "description": "key2",
 *             "key": second_public_key,
 *         },
 *     ],
 *     permission_scopes=[{
 *         "permissions": {
 *             "read": True,
 *             "create": True,
 *         },
 *         "service": "blob",
 *         "resource_name": example_container.name,
 *     }])
 * ```
 * ```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-rg",
 *         Location = "WestEurope",
 *     });
 *     var exampleAccount = new Azure.Storage.Account("example", new()
 *     {
 *         Name = "example-account",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *         AccountKind = "StorageV2",
 *         AccountTier = "Standard",
 *         AccountReplicationType = "LRS",
 *         IsHnsEnabled = true,
 *     });
 *     var exampleContainer = new Azure.Storage.Container("example", new()
 *     {
 *         Name = "example-container",
 *         StorageAccountName = exampleAccount.Name,
 *     });
 *     var exampleLocalUser = new Azure.Storage.LocalUser("example", new()
 *     {
 *         Name = "user1",
 *         StorageAccountId = exampleAccount.Id,
 *         SshKeyEnabled = true,
 *         SshPasswordEnabled = true,
 *         HomeDirectory = "example_path",
 *         SshAuthorizedKeys = new[]
 *         {
 *             new Azure.Storage.Inputs.LocalUserSshAuthorizedKeyArgs
 *             {
 *                 Description = "key1",
 *                 Key = firstPublicKey,
 *             },
 *             new Azure.Storage.Inputs.LocalUserSshAuthorizedKeyArgs
 *             {
 *                 Description = "key2",
 *                 Key = secondPublicKey,
 *             },
 *         },
 *         PermissionScopes = new[]
 *         {
 *             new Azure.Storage.Inputs.LocalUserPermissionScopeArgs
 *             {
 *                 Permissions = new Azure.Storage.Inputs.LocalUserPermissionScopePermissionsArgs
 *                 {
 *                     Read = true,
 *                     Create = true,
 *                 },
 *                 Service = "blob",
 *                 ResourceName = exampleContainer.Name,
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"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-rg"),
 * 			Location: pulumi.String("WestEurope"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleAccount, err := storage.NewAccount(ctx, "example", &storage.AccountArgs{
 * 			Name:                   pulumi.String("example-account"),
 * 			ResourceGroupName:      example.Name,
 * 			Location:               example.Location,
 * 			AccountKind:            pulumi.String("StorageV2"),
 * 			AccountTier:            pulumi.String("Standard"),
 * 			AccountReplicationType: pulumi.String("LRS"),
 * 			IsHnsEnabled:           pulumi.Bool(true),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleContainer, err := storage.NewContainer(ctx, "example", &storage.ContainerArgs{
 * 			Name:               pulumi.String("example-container"),
 * 			StorageAccountName: exampleAccount.Name,
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = storage.NewLocalUser(ctx, "example", &storage.LocalUserArgs{
 * 			Name:               pulumi.String("user1"),
 * 			StorageAccountId:   exampleAccount.ID(),
 * 			SshKeyEnabled:      pulumi.Bool(true),
 * 			SshPasswordEnabled: pulumi.Bool(true),
 * 			HomeDirectory:      pulumi.String("example_path"),
 * 			SshAuthorizedKeys: storage.LocalUserSshAuthorizedKeyArray{
 * 				&storage.LocalUserSshAuthorizedKeyArgs{
 * 					Description: pulumi.String("key1"),
 * 					Key:         pulumi.Any(firstPublicKey),
 * 				},
 * 				&storage.LocalUserSshAuthorizedKeyArgs{
 * 					Description: pulumi.String("key2"),
 * 					Key:         pulumi.Any(secondPublicKey),
 * 				},
 * 			},
 * 			PermissionScopes: storage.LocalUserPermissionScopeArray{
 * 				&storage.LocalUserPermissionScopeArgs{
 * 					Permissions: &storage.LocalUserPermissionScopePermissionsArgs{
 * 						Read:   pulumi.Bool(true),
 * 						Create: pulumi.Bool(true),
 * 					},
 * 					Service:      pulumi.String("blob"),
 * 					ResourceName: exampleContainer.Name,
 * 				},
 * 			},
 * 		})
 * 		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.storage.Container;
 * import com.pulumi.azure.storage.ContainerArgs;
 * import com.pulumi.azure.storage.LocalUser;
 * import com.pulumi.azure.storage.LocalUserArgs;
 * import com.pulumi.azure.storage.inputs.LocalUserSshAuthorizedKeyArgs;
 * import com.pulumi.azure.storage.inputs.LocalUserPermissionScopeArgs;
 * import com.pulumi.azure.storage.inputs.LocalUserPermissionScopePermissionsArgs;
 * 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-rg")
 *             .location("WestEurope")
 *             .build());
 *         var exampleAccount = new Account("exampleAccount", AccountArgs.builder()
 *             .name("example-account")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .accountKind("StorageV2")
 *             .accountTier("Standard")
 *             .accountReplicationType("LRS")
 *             .isHnsEnabled(true)
 *             .build());
 *         var exampleContainer = new Container("exampleContainer", ContainerArgs.builder()
 *             .name("example-container")
 *             .storageAccountName(exampleAccount.name())
 *             .build());
 *         var exampleLocalUser = new LocalUser("exampleLocalUser", LocalUserArgs.builder()
 *             .name("user1")
 *             .storageAccountId(exampleAccount.id())
 *             .sshKeyEnabled(true)
 *             .sshPasswordEnabled(true)
 *             .homeDirectory("example_path")
 *             .sshAuthorizedKeys(
 *                 LocalUserSshAuthorizedKeyArgs.builder()
 *                     .description("key1")
 *                     .key(firstPublicKey)
 *                     .build(),
 *                 LocalUserSshAuthorizedKeyArgs.builder()
 *                     .description("key2")
 *                     .key(secondPublicKey)
 *                     .build())
 *             .permissionScopes(LocalUserPermissionScopeArgs.builder()
 *                 .permissions(LocalUserPermissionScopePermissionsArgs.builder()
 *                     .read(true)
 *                     .create(true)
 *                     .build())
 *                 .service("blob")
 *                 .resourceName(exampleContainer.name())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-rg
 *       location: WestEurope
 *   exampleAccount:
 *     type: azure:storage:Account
 *     name: example
 *     properties:
 *       name: example-account
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *       accountKind: StorageV2
 *       accountTier: Standard
 *       accountReplicationType: LRS
 *       isHnsEnabled: true
 *   exampleContainer:
 *     type: azure:storage:Container
 *     name: example
 *     properties:
 *       name: example-container
 *       storageAccountName: ${exampleAccount.name}
 *   exampleLocalUser:
 *     type: azure:storage:LocalUser
 *     name: example
 *     properties:
 *       name: user1
 *       storageAccountId: ${exampleAccount.id}
 *       sshKeyEnabled: true
 *       sshPasswordEnabled: true
 *       homeDirectory: example_path
 *       sshAuthorizedKeys:
 *         - description: key1
 *           key: ${firstPublicKey}
 *         - description: key2
 *           key: ${secondPublicKey}
 *       permissionScopes:
 *         - permissions:
 *             read: true
 *             create: true
 *           service: blob
 *           resourceName: ${exampleContainer.name}
 * ```
 * 
 * ## Import
 * Storage Account Local Users can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:storage/localUser:LocalUser example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/localUsers/user1
 * ```
 */
public class LocalUser internal constructor(
    override val javaResource: com.pulumi.azure.storage.LocalUser,
) : KotlinCustomResource(javaResource, LocalUserMapper) {
    /**
     * The home directory of the Storage Account Local User.
     */
    public val homeDirectory: Output?
        get() = javaResource.homeDirectory().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The name which should be used for this Storage Account Local User. Changing this forces a new Storage Account Local User to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The value of the password, which is only available when `ssh_password_enabled` is set to `true`.
     */
    public val password: Output
        get() = javaResource.password().applyValue({ args0 -> args0 })

    /**
     * One or more `permission_scope` blocks as defined below.
     */
    public val permissionScopes: Output>?
        get() = javaResource.permissionScopes().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 ->
                        localUserPermissionScopeToKotlin(args0)
                    })
                })
            }).orElse(null)
        })

    /**
     * The unique Security Identifier of this Storage Account Local User.
     */
    public val sid: Output
        get() = javaResource.sid().applyValue({ args0 -> args0 })

    /**
     * One or more `ssh_authorized_key` blocks as defined below.
     */
    public val sshAuthorizedKeys: Output>?
        get() = javaResource.sshAuthorizedKeys().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 ->
                        localUserSshAuthorizedKeyToKotlin(args0)
                    })
                })
            }).orElse(null)
        })

    /**
     * Specifies whether SSH Key Authentication is enabled. Defaults to `false`.
     */
    public val sshKeyEnabled: Output?
        get() = javaResource.sshKeyEnabled().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Specifies whether SSH Password Authentication is enabled. Defaults to `false`.
     */
    public val sshPasswordEnabled: Output?
        get() = javaResource.sshPasswordEnabled().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The ID of the Storage Account that this Storage Account Local User resides in. Changing this forces a new Storage Account Local User to be created.
     */
    public val storageAccountId: Output
        get() = javaResource.storageAccountId().applyValue({ args0 -> args0 })
}

public object LocalUserMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.storage.LocalUser::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy