Skip to content

azurermPostgresqlActiveDirectoryAdministrator

Allows you to set a user or group as the AD administrator for an PostgreSQL server in Azure

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-resources",
  }
);
const dataAzurermClientConfigCurrent =
  new azurerm.dataAzurermClientConfig.DataAzurermClientConfig(
    this,
    "current",
    {}
  );
const azurermPostgresqlServerExample =
  new azurerm.postgresqlServer.PostgresqlServer(this, "example_2", {
    administrator_login: "4dm1n157r470r",
    administrator_login_password: "4-v3ry-53cr37-p455w0rd",
    location: azurermResourceGroupExample.location,
    name: "example-psqlserver",
    resource_group_name: azurermResourceGroupExample.name,
    sku_name: "GP_Gen5_2",
    ssl_enforcement_enabled: true,
    version: "9.6",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermPostgresqlServerExample.overrideLogicalId("example");
const azurermPostgresqlActiveDirectoryAdministratorExample =
  new azurerm.postgresqlActiveDirectoryAdministrator.PostgresqlActiveDirectoryAdministrator(
    this,
    "example_3",
    {
      login: "sqladmin",
      object_id: dataAzurermClientConfigCurrent.objectId,
      resource_group_name: azurermResourceGroupExample.name,
      server_name: azurermPostgresqlServerExample.name,
      tenant_id: dataAzurermClientConfigCurrent.tenantId,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermPostgresqlActiveDirectoryAdministratorExample.overrideLogicalId(
  "example"
);

Argument Reference

The following arguments are supported:

  • serverName - (Required) The name of the PostgreSQL Server on which to set the administrator. Changing this forces a new resource to be created.

  • resourceGroupName - (Required) The name of the resource group for the PostgreSQL server. Changing this forces a new resource to be created.

  • login - (Required) The login name of the principal to set as the server administrator

  • objectId - (Required) The ID of the principal to set as the server administrator. For a managed identity this should be the Client ID of the identity.

  • tenantId - (Required) The Azure Tenant ID

Attributes Reference

The following attributes are exported:

  • id - The ID of the PostgreSQL Active Directory Administrator.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the PostgreSQL Active Directory Administrator.
  • update - (Defaults to 30 minutes) Used when updating the PostgreSQL Active Directory Administrator.
  • read - (Defaults to 5 minutes) Used when retrieving the PostgreSQL Active Directory Administrator.
  • delete - (Defaults to 30 minutes) Used when deleting the PostgreSQL Active Directory Administrator.

Import

A PostgreSQL Active Directory Administrator can be imported using the resourceId, e.g.

terraform import azurerm_postgresql_active_directory_administrator.administrator /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.DBforPostgreSQL/servers/myserver