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

com.pulumi.azure.postgresql.kotlin.ActiveDirectoryAdministrator.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 6.14.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azure.postgresql.kotlin

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

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

    public var args: ActiveDirectoryAdministratorArgs = ActiveDirectoryAdministratorArgs()

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

/**
 * Allows you to set a user or group as the AD administrator for an PostgreSQL server in Azure
 * ## 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 exampleServer = new azure.postgresql.Server("example", {
 *     name: "example-psqlserver",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     version: "9.6",
 *     administratorLogin: "4dm1n157r470r",
 *     administratorLoginPassword: "4-v3ry-53cr37-p455w0rd",
 *     skuName: "GP_Gen5_2",
 *     sslEnforcementEnabled: true,
 * });
 * const exampleActiveDirectoryAdministrator = new azure.postgresql.ActiveDirectoryAdministrator("example", {
 *     serverName: exampleServer.name,
 *     resourceGroupName: example.name,
 *     login: "sqladmin",
 *     tenantId: current.then(current => current.tenantId),
 *     objectId: current.then(current => current.objectId),
 * });
 * ```
 * ```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_server = azure.postgresql.Server("example",
 *     name="example-psqlserver",
 *     resource_group_name=example.name,
 *     location=example.location,
 *     version="9.6",
 *     administrator_login="4dm1n157r470r",
 *     administrator_login_password="4-v3ry-53cr37-p455w0rd",
 *     sku_name="GP_Gen5_2",
 *     ssl_enforcement_enabled=True)
 * example_active_directory_administrator = azure.postgresql.ActiveDirectoryAdministrator("example",
 *     server_name=example_server.name,
 *     resource_group_name=example.name,
 *     login="sqladmin",
 *     tenant_id=current.tenant_id,
 *     object_id=current.object_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 exampleServer = new Azure.PostgreSql.Server("example", new()
 *     {
 *         Name = "example-psqlserver",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *         Version = "9.6",
 *         AdministratorLogin = "4dm1n157r470r",
 *         AdministratorLoginPassword = "4-v3ry-53cr37-p455w0rd",
 *         SkuName = "GP_Gen5_2",
 *         SslEnforcementEnabled = true,
 *     });
 *     var exampleActiveDirectoryAdministrator = new Azure.PostgreSql.ActiveDirectoryAdministrator("example", new()
 *     {
 *         ServerName = exampleServer.Name,
 *         ResourceGroupName = example.Name,
 *         Login = "sqladmin",
 *         TenantId = current.Apply(getClientConfigResult => getClientConfigResult.TenantId),
 *         ObjectId = current.Apply(getClientConfigResult => getClientConfigResult.ObjectId),
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/postgresql"
 * 	"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
 * 		}
 * 		exampleServer, err := postgresql.NewServer(ctx, "example", &postgresql.ServerArgs{
 * 			Name:                       pulumi.String("example-psqlserver"),
 * 			ResourceGroupName:          example.Name,
 * 			Location:                   example.Location,
 * 			Version:                    pulumi.String("9.6"),
 * 			AdministratorLogin:         pulumi.String("4dm1n157r470r"),
 * 			AdministratorLoginPassword: pulumi.String("4-v3ry-53cr37-p455w0rd"),
 * 			SkuName:                    pulumi.String("GP_Gen5_2"),
 * 			SslEnforcementEnabled:      pulumi.Bool(true),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = postgresql.NewActiveDirectoryAdministrator(ctx, "example", &postgresql.ActiveDirectoryAdministratorArgs{
 * 			ServerName:        exampleServer.Name,
 * 			ResourceGroupName: example.Name,
 * 			Login:             pulumi.String("sqladmin"),
 * 			TenantId:          pulumi.String(current.TenantId),
 * 			ObjectId:          pulumi.String(current.ObjectId),
 * 		})
 * 		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.postgresql.Server;
 * import com.pulumi.azure.postgresql.ServerArgs;
 * import com.pulumi.azure.postgresql.ActiveDirectoryAdministrator;
 * import com.pulumi.azure.postgresql.ActiveDirectoryAdministratorArgs;
 * 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 exampleServer = new Server("exampleServer", ServerArgs.builder()
 *             .name("example-psqlserver")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .version("9.6")
 *             .administratorLogin("4dm1n157r470r")
 *             .administratorLoginPassword("4-v3ry-53cr37-p455w0rd")
 *             .skuName("GP_Gen5_2")
 *             .sslEnforcementEnabled(true)
 *             .build());
 *         var exampleActiveDirectoryAdministrator = new ActiveDirectoryAdministrator("exampleActiveDirectoryAdministrator", ActiveDirectoryAdministratorArgs.builder()
 *             .serverName(exampleServer.name())
 *             .resourceGroupName(example.name())
 *             .login("sqladmin")
 *             .tenantId(current.applyValue(getClientConfigResult -> getClientConfigResult.tenantId()))
 *             .objectId(current.applyValue(getClientConfigResult -> getClientConfigResult.objectId()))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleServer:
 *     type: azure:postgresql:Server
 *     name: example
 *     properties:
 *       name: example-psqlserver
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *       version: '9.6'
 *       administratorLogin: 4dm1n157r470r
 *       administratorLoginPassword: 4-v3ry-53cr37-p455w0rd
 *       skuName: GP_Gen5_2
 *       sslEnforcementEnabled: true
 *   exampleActiveDirectoryAdministrator:
 *     type: azure:postgresql:ActiveDirectoryAdministrator
 *     name: example
 *     properties:
 *       serverName: ${exampleServer.name}
 *       resourceGroupName: ${example.name}
 *       login: sqladmin
 *       tenantId: ${current.tenantId}
 *       objectId: ${current.objectId}
 * variables:
 *   current:
 *     fn::invoke:
 *       Function: azure:core:getClientConfig
 *       Arguments: {}
 * ```
 * 
 * ## Import
 * A PostgreSQL Active Directory Administrator can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:postgresql/activeDirectoryAdministrator:ActiveDirectoryAdministrator administrator /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.DBforPostgreSQL/servers/myserver
 * ```
 */
public class ActiveDirectoryAdministrator internal constructor(
    override val javaResource: com.pulumi.azure.postgresql.ActiveDirectoryAdministrator,
) : KotlinCustomResource(javaResource, ActiveDirectoryAdministratorMapper) {
    /**
     * The login name of the principal to set as the server administrator
     */
    public val login: Output
        get() = javaResource.login().applyValue({ args0 -> args0 })

    /**
     * The ID of the principal to set as the server administrator. For a managed identity this should be the Client ID of the identity.
     */
    public val objectId: Output
        get() = javaResource.objectId().applyValue({ args0 -> args0 })

    /**
     * The name of the resource group for the PostgreSQL server. Changing this forces a new resource to be created.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

    /**
     * The name of the PostgreSQL Server on which to set the administrator. Changing this forces a new resource to be created.
     */
    public val serverName: Output
        get() = javaResource.serverName().applyValue({ args0 -> args0 })

    /**
     * The Azure Tenant ID
     */
    public val tenantId: Output
        get() = javaResource.tenantId().applyValue({ args0 -> args0 })
}

public object ActiveDirectoryAdministratorMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.postgresql.ActiveDirectoryAdministrator::class == javaResource::class

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy