1. Packages
  2. Postgresql Provider
  3. API Docs
  4. SecurityLabel
PostgreSQL v3.15.1 published on Saturday, Mar 15, 2025 by Pulumi

postgresql.SecurityLabel

Explore with Pulumi AI

The postgresql.SecurityLabel resource creates and manages security labels.

See PostgreSQL documentation

Note: This resource needs Postgresql version 11 or above.

Usage

import * as pulumi from "@pulumi/pulumi";
import * as postgresql from "@pulumi/postgresql";

const myRole = new postgresql.Role("my_role", {
    name: "my_role",
    login: true,
});
const workload = new postgresql.SecurityLabel("workload", {
    objectType: "role",
    objectName: myRole.name,
    labelProvider: "pgaadauth",
    label: "aadauth,oid=00000000-0000-0000-0000-000000000000,type=service",
});
Copy
import pulumi
import pulumi_postgresql as postgresql

my_role = postgresql.Role("my_role",
    name="my_role",
    login=True)
workload = postgresql.SecurityLabel("workload",
    object_type="role",
    object_name=my_role.name,
    label_provider="pgaadauth",
    label="aadauth,oid=00000000-0000-0000-0000-000000000000,type=service")
Copy
package main

import (
	"github.com/pulumi/pulumi-postgresql/sdk/v3/go/postgresql"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		myRole, err := postgresql.NewRole(ctx, "my_role", &postgresql.RoleArgs{
			Name:  pulumi.String("my_role"),
			Login: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		_, err = postgresql.NewSecurityLabel(ctx, "workload", &postgresql.SecurityLabelArgs{
			ObjectType:    pulumi.String("role"),
			ObjectName:    myRole.Name,
			LabelProvider: pulumi.String("pgaadauth"),
			Label:         pulumi.String("aadauth,oid=00000000-0000-0000-0000-000000000000,type=service"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using PostgreSql = Pulumi.PostgreSql;

return await Deployment.RunAsync(() => 
{
    var myRole = new PostgreSql.Role("my_role", new()
    {
        Name = "my_role",
        Login = true,
    });

    var workload = new PostgreSql.SecurityLabel("workload", new()
    {
        ObjectType = "role",
        ObjectName = myRole.Name,
        LabelProvider = "pgaadauth",
        Label = "aadauth,oid=00000000-0000-0000-0000-000000000000,type=service",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.postgresql.Role;
import com.pulumi.postgresql.RoleArgs;
import com.pulumi.postgresql.SecurityLabel;
import com.pulumi.postgresql.SecurityLabelArgs;
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 myRole = new Role("myRole", RoleArgs.builder()
            .name("my_role")
            .login(true)
            .build());

        var workload = new SecurityLabel("workload", SecurityLabelArgs.builder()
            .objectType("role")
            .objectName(myRole.name())
            .labelProvider("pgaadauth")
            .label("aadauth,oid=00000000-0000-0000-0000-000000000000,type=service")
            .build());

    }
}
Copy
resources:
  myRole:
    type: postgresql:Role
    name: my_role
    properties:
      name: my_role
      login: true
  workload:
    type: postgresql:SecurityLabel
    properties:
      objectType: role
      objectName: ${myRole.name}
      labelProvider: pgaadauth
      label: aadauth,oid=00000000-0000-0000-0000-000000000000,type=service
Copy

Create SecurityLabel Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new SecurityLabel(name: string, args: SecurityLabelArgs, opts?: CustomResourceOptions);
@overload
def SecurityLabel(resource_name: str,
                  args: SecurityLabelArgs,
                  opts: Optional[ResourceOptions] = None)

@overload
def SecurityLabel(resource_name: str,
                  opts: Optional[ResourceOptions] = None,
                  label: Optional[str] = None,
                  label_provider: Optional[str] = None,
                  object_name: Optional[str] = None,
                  object_type: Optional[str] = None)
func NewSecurityLabel(ctx *Context, name string, args SecurityLabelArgs, opts ...ResourceOption) (*SecurityLabel, error)
public SecurityLabel(string name, SecurityLabelArgs args, CustomResourceOptions? opts = null)
public SecurityLabel(String name, SecurityLabelArgs args)
public SecurityLabel(String name, SecurityLabelArgs args, CustomResourceOptions options)
type: postgresql:SecurityLabel
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. SecurityLabelArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. SecurityLabelArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. SecurityLabelArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. SecurityLabelArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. SecurityLabelArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var securityLabelResource = new PostgreSql.SecurityLabel("securityLabelResource", new()
{
    Label = "string",
    LabelProvider = "string",
    ObjectName = "string",
    ObjectType = "string",
});
Copy
example, err := postgresql.NewSecurityLabel(ctx, "securityLabelResource", &postgresql.SecurityLabelArgs{
	Label:         pulumi.String("string"),
	LabelProvider: pulumi.String("string"),
	ObjectName:    pulumi.String("string"),
	ObjectType:    pulumi.String("string"),
})
Copy
var securityLabelResource = new SecurityLabel("securityLabelResource", SecurityLabelArgs.builder()
    .label("string")
    .labelProvider("string")
    .objectName("string")
    .objectType("string")
    .build());
Copy
security_label_resource = postgresql.SecurityLabel("securityLabelResource",
    label="string",
    label_provider="string",
    object_name="string",
    object_type="string")
Copy
const securityLabelResource = new postgresql.SecurityLabel("securityLabelResource", {
    label: "string",
    labelProvider: "string",
    objectName: "string",
    objectType: "string",
});
Copy
type: postgresql:SecurityLabel
properties:
    label: string
    labelProvider: string
    objectName: string
    objectType: string
Copy

SecurityLabel Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The SecurityLabel resource accepts the following input properties:

Label This property is required. string
The value of the security label.
LabelProvider
This property is required.
Changes to this property will trigger replacement.
string
The name of the provider with which this label is to be associated.
ObjectName
This property is required.
Changes to this property will trigger replacement.
string
The name of the object to be labeled. Names of objects that reside in schemas (tables, functions, etc.) can be schema-qualified.
ObjectType
This property is required.
Changes to this property will trigger replacement.
string
The PostgreSQL object type to apply this security label to.
Label This property is required. string
The value of the security label.
LabelProvider
This property is required.
Changes to this property will trigger replacement.
string
The name of the provider with which this label is to be associated.
ObjectName
This property is required.
Changes to this property will trigger replacement.
string
The name of the object to be labeled. Names of objects that reside in schemas (tables, functions, etc.) can be schema-qualified.
ObjectType
This property is required.
Changes to this property will trigger replacement.
string
The PostgreSQL object type to apply this security label to.
label This property is required. String
The value of the security label.
labelProvider
This property is required.
Changes to this property will trigger replacement.
String
The name of the provider with which this label is to be associated.
objectName
This property is required.
Changes to this property will trigger replacement.
String
The name of the object to be labeled. Names of objects that reside in schemas (tables, functions, etc.) can be schema-qualified.
objectType
This property is required.
Changes to this property will trigger replacement.
String
The PostgreSQL object type to apply this security label to.
label This property is required. string
The value of the security label.
labelProvider
This property is required.
Changes to this property will trigger replacement.
string
The name of the provider with which this label is to be associated.
objectName
This property is required.
Changes to this property will trigger replacement.
string
The name of the object to be labeled. Names of objects that reside in schemas (tables, functions, etc.) can be schema-qualified.
objectType
This property is required.
Changes to this property will trigger replacement.
string
The PostgreSQL object type to apply this security label to.
label This property is required. str
The value of the security label.
label_provider
This property is required.
Changes to this property will trigger replacement.
str
The name of the provider with which this label is to be associated.
object_name
This property is required.
Changes to this property will trigger replacement.
str
The name of the object to be labeled. Names of objects that reside in schemas (tables, functions, etc.) can be schema-qualified.
object_type
This property is required.
Changes to this property will trigger replacement.
str
The PostgreSQL object type to apply this security label to.
label This property is required. String
The value of the security label.
labelProvider
This property is required.
Changes to this property will trigger replacement.
String
The name of the provider with which this label is to be associated.
objectName
This property is required.
Changes to this property will trigger replacement.
String
The name of the object to be labeled. Names of objects that reside in schemas (tables, functions, etc.) can be schema-qualified.
objectType
This property is required.
Changes to this property will trigger replacement.
String
The PostgreSQL object type to apply this security label to.

Outputs

All input properties are implicitly available as output properties. Additionally, the SecurityLabel resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing SecurityLabel Resource

Get an existing SecurityLabel resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: SecurityLabelState, opts?: CustomResourceOptions): SecurityLabel
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        label: Optional[str] = None,
        label_provider: Optional[str] = None,
        object_name: Optional[str] = None,
        object_type: Optional[str] = None) -> SecurityLabel
func GetSecurityLabel(ctx *Context, name string, id IDInput, state *SecurityLabelState, opts ...ResourceOption) (*SecurityLabel, error)
public static SecurityLabel Get(string name, Input<string> id, SecurityLabelState? state, CustomResourceOptions? opts = null)
public static SecurityLabel get(String name, Output<String> id, SecurityLabelState state, CustomResourceOptions options)
resources:  _:    type: postgresql:SecurityLabel    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Label string
The value of the security label.
LabelProvider Changes to this property will trigger replacement. string
The name of the provider with which this label is to be associated.
ObjectName Changes to this property will trigger replacement. string
The name of the object to be labeled. Names of objects that reside in schemas (tables, functions, etc.) can be schema-qualified.
ObjectType Changes to this property will trigger replacement. string
The PostgreSQL object type to apply this security label to.
Label string
The value of the security label.
LabelProvider Changes to this property will trigger replacement. string
The name of the provider with which this label is to be associated.
ObjectName Changes to this property will trigger replacement. string
The name of the object to be labeled. Names of objects that reside in schemas (tables, functions, etc.) can be schema-qualified.
ObjectType Changes to this property will trigger replacement. string
The PostgreSQL object type to apply this security label to.
label String
The value of the security label.
labelProvider Changes to this property will trigger replacement. String
The name of the provider with which this label is to be associated.
objectName Changes to this property will trigger replacement. String
The name of the object to be labeled. Names of objects that reside in schemas (tables, functions, etc.) can be schema-qualified.
objectType Changes to this property will trigger replacement. String
The PostgreSQL object type to apply this security label to.
label string
The value of the security label.
labelProvider Changes to this property will trigger replacement. string
The name of the provider with which this label is to be associated.
objectName Changes to this property will trigger replacement. string
The name of the object to be labeled. Names of objects that reside in schemas (tables, functions, etc.) can be schema-qualified.
objectType Changes to this property will trigger replacement. string
The PostgreSQL object type to apply this security label to.
label str
The value of the security label.
label_provider Changes to this property will trigger replacement. str
The name of the provider with which this label is to be associated.
object_name Changes to this property will trigger replacement. str
The name of the object to be labeled. Names of objects that reside in schemas (tables, functions, etc.) can be schema-qualified.
object_type Changes to this property will trigger replacement. str
The PostgreSQL object type to apply this security label to.
label String
The value of the security label.
labelProvider Changes to this property will trigger replacement. String
The name of the provider with which this label is to be associated.
objectName Changes to this property will trigger replacement. String
The name of the object to be labeled. Names of objects that reside in schemas (tables, functions, etc.) can be schema-qualified.
objectType Changes to this property will trigger replacement. String
The PostgreSQL object type to apply this security label to.

Import

Security label is an attribute that can be added multiple times, so no import is needed, simply apply again.

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
PostgreSQL pulumi/pulumi-postgresql
License
Apache-2.0
Notes
This Pulumi package is based on the postgresql Terraform Provider.