FlexibleServerActiveDirectoryAdministrator

class FlexibleServerActiveDirectoryAdministrator : KotlinCustomResource

Allows you to set a user or group as the AD administrator for a PostgreSQL Flexible Server.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
import * as azuread from "@pulumi/azuread";
const current = azure.core.getClientConfig({});
const example = current.then(current => azuread.getServicePrincipal({
objectId: current.objectId,
}));
const exampleResourceGroup = new azure.core.ResourceGroup("example", {
name: "example-resources",
location: "West Europe",
});
const exampleFlexibleServer = new azure.postgresql.FlexibleServer("example", {
name: "example-fs",
resourceGroupName: exampleResourceGroup.name,
location: exampleResourceGroup.location,
administratorLogin: "adminTerraform",
administratorPassword: "QAZwsx123",
storageMb: 32768,
version: "12",
skuName: "GP_Standard_D2s_v3",
zone: "2",
authentication: {
activeDirectoryAuthEnabled: true,
tenantId: current.then(current => current.tenantId),
},
});
const exampleFlexibleServerActiveDirectoryAdministrator = new azure.postgresql.FlexibleServerActiveDirectoryAdministrator("example", {
serverName: exampleFlexibleServer.name,
resourceGroupName: exampleResourceGroup.name,
tenantId: current.then(current => current.tenantId),
objectId: example.then(example => example.objectId),
principalName: example.then(example => example.displayName),
principalType: "ServicePrincipal",
});
import pulumi
import pulumi_azure as azure
import pulumi_azuread as azuread
current = azure.core.get_client_config()
example = azuread.get_service_principal(object_id=current.object_id)
example_resource_group = azure.core.ResourceGroup("example",
name="example-resources",
location="West Europe")
example_flexible_server = azure.postgresql.FlexibleServer("example",
name="example-fs",
resource_group_name=example_resource_group.name,
location=example_resource_group.location,
administrator_login="adminTerraform",
administrator_password="QAZwsx123",
storage_mb=32768,
version="12",
sku_name="GP_Standard_D2s_v3",
zone="2",
authentication={
"active_directory_auth_enabled": True,
"tenant_id": current.tenant_id,
})
example_flexible_server_active_directory_administrator = azure.postgresql.FlexibleServerActiveDirectoryAdministrator("example",
server_name=example_flexible_server.name,
resource_group_name=example_resource_group.name,
tenant_id=current.tenant_id,
object_id=example.object_id,
principal_name=example.display_name,
principal_type="ServicePrincipal")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
using AzureAD = Pulumi.AzureAD;
return await Deployment.RunAsync(() =>
{
var current = Azure.Core.GetClientConfig.Invoke();
var example = AzureAD.GetServicePrincipal.Invoke(new()
{
ObjectId = current.Apply(getClientConfigResult => getClientConfigResult.ObjectId),
});
var exampleResourceGroup = new Azure.Core.ResourceGroup("example", new()
{
Name = "example-resources",
Location = "West Europe",
});
var exampleFlexibleServer = new Azure.PostgreSql.FlexibleServer("example", new()
{
Name = "example-fs",
ResourceGroupName = exampleResourceGroup.Name,
Location = exampleResourceGroup.Location,
AdministratorLogin = "adminTerraform",
AdministratorPassword = "QAZwsx123",
StorageMb = 32768,
Version = "12",
SkuName = "GP_Standard_D2s_v3",
Zone = "2",
Authentication = new Azure.PostgreSql.Inputs.FlexibleServerAuthenticationArgs
{
ActiveDirectoryAuthEnabled = true,
TenantId = current.Apply(getClientConfigResult => getClientConfigResult.TenantId),
},
});
var exampleFlexibleServerActiveDirectoryAdministrator = new Azure.PostgreSql.FlexibleServerActiveDirectoryAdministrator("example", new()
{
ServerName = exampleFlexibleServer.Name,
ResourceGroupName = exampleResourceGroup.Name,
TenantId = current.Apply(getClientConfigResult => getClientConfigResult.TenantId),
ObjectId = example.Apply(getServicePrincipalResult => getServicePrincipalResult.ObjectId),
PrincipalName = example.Apply(getServicePrincipalResult => getServicePrincipalResult.DisplayName),
PrincipalType = "ServicePrincipal",
});
});
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/postgresql"
"github.com/pulumi/pulumi-azuread/sdk/v5/go/azuread"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
current, err := core.GetClientConfig(ctx, map[string]interface{}{}, nil)
if err != nil {
return err
}
example, err := azuread.LookupServicePrincipal(ctx, &azuread.LookupServicePrincipalArgs{
ObjectId: pulumi.StringRef(current.ObjectId),
}, nil)
if err != nil {
return err
}
exampleResourceGroup, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
Name: pulumi.String("example-resources"),
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
exampleFlexibleServer, err := postgresql.NewFlexibleServer(ctx, "example", &postgresql.FlexibleServerArgs{
Name: pulumi.String("example-fs"),
ResourceGroupName: exampleResourceGroup.Name,
Location: exampleResourceGroup.Location,
AdministratorLogin: pulumi.String("adminTerraform"),
AdministratorPassword: pulumi.String("QAZwsx123"),
StorageMb: pulumi.Int(32768),
Version: pulumi.String("12"),
SkuName: pulumi.String("GP_Standard_D2s_v3"),
Zone: pulumi.String("2"),
Authentication: &postgresql.FlexibleServerAuthenticationArgs{
ActiveDirectoryAuthEnabled: pulumi.Bool(true),
TenantId: pulumi.String(current.TenantId),
},
})
if err != nil {
return err
}
_, err = postgresql.NewFlexibleServerActiveDirectoryAdministrator(ctx, "example", &postgresql.FlexibleServerActiveDirectoryAdministratorArgs{
ServerName: exampleFlexibleServer.Name,
ResourceGroupName: exampleResourceGroup.Name,
TenantId: pulumi.String(current.TenantId),
ObjectId: pulumi.String(example.ObjectId),
PrincipalName: pulumi.String(example.DisplayName),
PrincipalType: pulumi.String("ServicePrincipal"),
})
if err != nil {
return err
}
return nil
})
}
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.azuread.AzureadFunctions;
import com.pulumi.azuread.inputs.GetServicePrincipalArgs;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.postgresql.FlexibleServer;
import com.pulumi.azure.postgresql.FlexibleServerArgs;
import com.pulumi.azure.postgresql.inputs.FlexibleServerAuthenticationArgs;
import com.pulumi.azure.postgresql.FlexibleServerActiveDirectoryAdministrator;
import com.pulumi.azure.postgresql.FlexibleServerActiveDirectoryAdministratorArgs;
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(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference);
final var example = AzureadFunctions.getServicePrincipal(GetServicePrincipalArgs.builder()
.objectId(current.objectId())
.build());
var exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()
.name("example-resources")
.location("West Europe")
.build());
var exampleFlexibleServer = new FlexibleServer("exampleFlexibleServer", FlexibleServerArgs.builder()
.name("example-fs")
.resourceGroupName(exampleResourceGroup.name())
.location(exampleResourceGroup.location())
.administratorLogin("adminTerraform")
.administratorPassword("QAZwsx123")
.storageMb(32768)
.version("12")
.skuName("GP_Standard_D2s_v3")
.zone("2")
.authentication(FlexibleServerAuthenticationArgs.builder()
.activeDirectoryAuthEnabled(true)
.tenantId(current.tenantId())
.build())
.build());
var exampleFlexibleServerActiveDirectoryAdministrator = new FlexibleServerActiveDirectoryAdministrator("exampleFlexibleServerActiveDirectoryAdministrator", FlexibleServerActiveDirectoryAdministratorArgs.builder()
.serverName(exampleFlexibleServer.name())
.resourceGroupName(exampleResourceGroup.name())
.tenantId(current.tenantId())
.objectId(example.objectId())
.principalName(example.displayName())
.principalType("ServicePrincipal")
.build());
}
}
resources:
exampleResourceGroup:
type: azure:core:ResourceGroup
name: example
properties:
name: example-resources
location: West Europe
exampleFlexibleServer:
type: azure:postgresql:FlexibleServer
name: example
properties:
name: example-fs
resourceGroupName: ${exampleResourceGroup.name}
location: ${exampleResourceGroup.location}
administratorLogin: adminTerraform
administratorPassword: QAZwsx123
storageMb: 32768
version: '12'
skuName: GP_Standard_D2s_v3
zone: '2'
authentication:
activeDirectoryAuthEnabled: true
tenantId: ${current.tenantId}
exampleFlexibleServerActiveDirectoryAdministrator:
type: azure:postgresql:FlexibleServerActiveDirectoryAdministrator
name: example
properties:
serverName: ${exampleFlexibleServer.name}
resourceGroupName: ${exampleResourceGroup.name}
tenantId: ${current.tenantId}
objectId: ${example.objectId}
principalName: ${example.displayName}
principalType: ServicePrincipal
variables:
current:
fn::invoke:
function: azure:core:getClientConfig
arguments: {}
example:
fn::invoke:
function: azuread:getServicePrincipal
arguments:
objectId: ${current.objectId}

API Providers

This resource uses the following Azure API Providers:

  • Microsoft.DBforPostgreSQL: 2024-08-01

Import

A PostgreSQL Flexible Server Active Directory Administrator can be imported using the resource id, e.g.

$ pulumi import azure:postgresql/flexibleServerActiveDirectoryAdministrator:FlexibleServerActiveDirectoryAdministrator example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/myserver/administrators/objectId

Properties

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val objectId: Output<String>

The object ID of a user, service principal or security group in the Azure Active Directory tenant set as the Flexible Server Admin. Changing this forces a new resource to be created.

Link copied to clipboard
val principalName: Output<String>

The name of Azure Active Directory principal. Changing this forces a new resource to be created.

Link copied to clipboard
val principalType: Output<String>

The type of Azure Active Directory principal. Possible values are Group, ServicePrincipal and User. Changing this forces a new resource to be created.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The name of the resource group for the PostgreSQL Server. Changing this forces a new resource to be created.

Link copied to clipboard
val serverName: Output<String>

The name of the PostgreSQL Flexible Server on which to set the administrator. Changing this forces a new resource to be created.

Link copied to clipboard
val tenantId: Output<String>

The Azure Tenant ID. Changing this forces a new resource to be created.

Link copied to clipboard
val urn: Output<String>