1. Packages
  2. HashiCorp Vault
  3. API Docs
  4. database
  5. SecretBackendRole
HashiCorp Vault v6.0.0 published on Monday, Mar 25, 2024 by Pulumi

vault.database.SecretBackendRole

Explore with Pulumi AI

vault logo
HashiCorp Vault v6.0.0 published on Monday, Mar 25, 2024 by Pulumi

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as vault from "@pulumi/vault";
    
    const db = new vault.Mount("db", {
        path: "postgres",
        type: "database",
    });
    const postgres = new vault.database.SecretBackendConnection("postgres", {
        backend: db.path,
        allowedRoles: [
            "dev",
            "prod",
        ],
        postgresql: {
            connectionUrl: "postgres://username:password@host:port/database",
        },
    });
    const role = new vault.database.SecretBackendRole("role", {
        backend: db.path,
        dbName: postgres.name,
        creationStatements: ["CREATE ROLE \"{{name}}\" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}';"],
    });
    
    import pulumi
    import pulumi_vault as vault
    
    db = vault.Mount("db",
        path="postgres",
        type="database")
    postgres = vault.database.SecretBackendConnection("postgres",
        backend=db.path,
        allowed_roles=[
            "dev",
            "prod",
        ],
        postgresql=vault.database.SecretBackendConnectionPostgresqlArgs(
            connection_url="postgres://username:password@host:port/database",
        ))
    role = vault.database.SecretBackendRole("role",
        backend=db.path,
        db_name=postgres.name,
        creation_statements=["CREATE ROLE \"{{name}}\" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}';"])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-vault/sdk/v6/go/vault"
    	"github.com/pulumi/pulumi-vault/sdk/v6/go/vault/database"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		db, err := vault.NewMount(ctx, "db", &vault.MountArgs{
    			Path: pulumi.String("postgres"),
    			Type: pulumi.String("database"),
    		})
    		if err != nil {
    			return err
    		}
    		postgres, err := database.NewSecretBackendConnection(ctx, "postgres", &database.SecretBackendConnectionArgs{
    			Backend: db.Path,
    			AllowedRoles: pulumi.StringArray{
    				pulumi.String("dev"),
    				pulumi.String("prod"),
    			},
    			Postgresql: &database.SecretBackendConnectionPostgresqlArgs{
    				ConnectionUrl: pulumi.String("postgres://username:password@host:port/database"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = database.NewSecretBackendRole(ctx, "role", &database.SecretBackendRoleArgs{
    			Backend: db.Path,
    			DbName:  postgres.Name,
    			CreationStatements: pulumi.StringArray{
    				pulumi.String("CREATE ROLE \"{{name}}\" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}';"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Vault = Pulumi.Vault;
    
    return await Deployment.RunAsync(() => 
    {
        var db = new Vault.Mount("db", new()
        {
            Path = "postgres",
            Type = "database",
        });
    
        var postgres = new Vault.Database.SecretBackendConnection("postgres", new()
        {
            Backend = db.Path,
            AllowedRoles = new[]
            {
                "dev",
                "prod",
            },
            Postgresql = new Vault.Database.Inputs.SecretBackendConnectionPostgresqlArgs
            {
                ConnectionUrl = "postgres://username:password@host:port/database",
            },
        });
    
        var role = new Vault.Database.SecretBackendRole("role", new()
        {
            Backend = db.Path,
            DbName = postgres.Name,
            CreationStatements = new[]
            {
                "CREATE ROLE \"{{name}}\" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}';",
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.vault.Mount;
    import com.pulumi.vault.MountArgs;
    import com.pulumi.vault.database.SecretBackendConnection;
    import com.pulumi.vault.database.SecretBackendConnectionArgs;
    import com.pulumi.vault.database.inputs.SecretBackendConnectionPostgresqlArgs;
    import com.pulumi.vault.database.SecretBackendRole;
    import com.pulumi.vault.database.SecretBackendRoleArgs;
    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 db = new Mount("db", MountArgs.builder()        
                .path("postgres")
                .type("database")
                .build());
    
            var postgres = new SecretBackendConnection("postgres", SecretBackendConnectionArgs.builder()        
                .backend(db.path())
                .allowedRoles(            
                    "dev",
                    "prod")
                .postgresql(SecretBackendConnectionPostgresqlArgs.builder()
                    .connectionUrl("postgres://username:password@host:port/database")
                    .build())
                .build());
    
            var role = new SecretBackendRole("role", SecretBackendRoleArgs.builder()        
                .backend(db.path())
                .dbName(postgres.name())
                .creationStatements("CREATE ROLE \"{{name}}\" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}';")
                .build());
    
        }
    }
    
    resources:
      db:
        type: vault:Mount
        properties:
          path: postgres
          type: database
      postgres:
        type: vault:database:SecretBackendConnection
        properties:
          backend: ${db.path}
          allowedRoles:
            - dev
            - prod
          postgresql:
            connectionUrl: postgres://username:password@host:port/database
      role:
        type: vault:database:SecretBackendRole
        properties:
          backend: ${db.path}
          dbName: ${postgres.name}
          creationStatements:
            - CREATE ROLE "{{name}}" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}';
    

    Create SecretBackendRole Resource

    new SecretBackendRole(name: string, args: SecretBackendRoleArgs, opts?: CustomResourceOptions);
    @overload
    def SecretBackendRole(resource_name: str,
                          opts: Optional[ResourceOptions] = None,
                          backend: Optional[str] = None,
                          creation_statements: Optional[Sequence[str]] = None,
                          credential_config: Optional[Mapping[str, Any]] = None,
                          credential_type: Optional[str] = None,
                          db_name: Optional[str] = None,
                          default_ttl: Optional[int] = None,
                          max_ttl: Optional[int] = None,
                          name: Optional[str] = None,
                          namespace: Optional[str] = None,
                          renew_statements: Optional[Sequence[str]] = None,
                          revocation_statements: Optional[Sequence[str]] = None,
                          rollback_statements: Optional[Sequence[str]] = None)
    @overload
    def SecretBackendRole(resource_name: str,
                          args: SecretBackendRoleArgs,
                          opts: Optional[ResourceOptions] = None)
    func NewSecretBackendRole(ctx *Context, name string, args SecretBackendRoleArgs, opts ...ResourceOption) (*SecretBackendRole, error)
    public SecretBackendRole(string name, SecretBackendRoleArgs args, CustomResourceOptions? opts = null)
    public SecretBackendRole(String name, SecretBackendRoleArgs args)
    public SecretBackendRole(String name, SecretBackendRoleArgs args, CustomResourceOptions options)
    
    type: vault:database:SecretBackendRole
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args SecretBackendRoleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args SecretBackendRoleArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args SecretBackendRoleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SecretBackendRoleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args SecretBackendRoleArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    SecretBackendRole Resource Properties

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

    Inputs

    The SecretBackendRole resource accepts the following input properties:

    Backend string
    The unique name of the Vault mount to configure.
    CreationStatements List<string>
    The database statements to execute when creating a user.
    DbName string
    The unique name of the database connection to use for the role.
    CredentialConfig Dictionary<string, object>

    Specifies the configuration for the given credential_type.

    The following options are available for each credential_type value:

    CredentialType string
    Specifies the type of credential that will be generated for the role. Options include: password, rsa_private_key, client_certificate. See the plugin's API page for credential types supported by individual databases.
    DefaultTtl int
    The default number of seconds for leases for this role.
    MaxTtl int
    The maximum number of seconds for leases for this role.
    Name string
    A unique name to give the role.
    Namespace string
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    RenewStatements List<string>
    The database statements to execute when renewing a user.
    RevocationStatements List<string>
    The database statements to execute when revoking a user.
    RollbackStatements List<string>
    The database statements to execute when rolling back creation due to an error.
    Backend string
    The unique name of the Vault mount to configure.
    CreationStatements []string
    The database statements to execute when creating a user.
    DbName string
    The unique name of the database connection to use for the role.
    CredentialConfig map[string]interface{}

    Specifies the configuration for the given credential_type.

    The following options are available for each credential_type value:

    CredentialType string
    Specifies the type of credential that will be generated for the role. Options include: password, rsa_private_key, client_certificate. See the plugin's API page for credential types supported by individual databases.
    DefaultTtl int
    The default number of seconds for leases for this role.
    MaxTtl int
    The maximum number of seconds for leases for this role.
    Name string
    A unique name to give the role.
    Namespace string
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    RenewStatements []string
    The database statements to execute when renewing a user.
    RevocationStatements []string
    The database statements to execute when revoking a user.
    RollbackStatements []string
    The database statements to execute when rolling back creation due to an error.
    backend String
    The unique name of the Vault mount to configure.
    creationStatements List<String>
    The database statements to execute when creating a user.
    dbName String
    The unique name of the database connection to use for the role.
    credentialConfig Map<String,Object>

    Specifies the configuration for the given credential_type.

    The following options are available for each credential_type value:

    credentialType String
    Specifies the type of credential that will be generated for the role. Options include: password, rsa_private_key, client_certificate. See the plugin's API page for credential types supported by individual databases.
    defaultTtl Integer
    The default number of seconds for leases for this role.
    maxTtl Integer
    The maximum number of seconds for leases for this role.
    name String
    A unique name to give the role.
    namespace String
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    renewStatements List<String>
    The database statements to execute when renewing a user.
    revocationStatements List<String>
    The database statements to execute when revoking a user.
    rollbackStatements List<String>
    The database statements to execute when rolling back creation due to an error.
    backend string
    The unique name of the Vault mount to configure.
    creationStatements string[]
    The database statements to execute when creating a user.
    dbName string
    The unique name of the database connection to use for the role.
    credentialConfig {[key: string]: any}

    Specifies the configuration for the given credential_type.

    The following options are available for each credential_type value:

    credentialType string
    Specifies the type of credential that will be generated for the role. Options include: password, rsa_private_key, client_certificate. See the plugin's API page for credential types supported by individual databases.
    defaultTtl number
    The default number of seconds for leases for this role.
    maxTtl number
    The maximum number of seconds for leases for this role.
    name string
    A unique name to give the role.
    namespace string
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    renewStatements string[]
    The database statements to execute when renewing a user.
    revocationStatements string[]
    The database statements to execute when revoking a user.
    rollbackStatements string[]
    The database statements to execute when rolling back creation due to an error.
    backend str
    The unique name of the Vault mount to configure.
    creation_statements Sequence[str]
    The database statements to execute when creating a user.
    db_name str
    The unique name of the database connection to use for the role.
    credential_config Mapping[str, Any]

    Specifies the configuration for the given credential_type.

    The following options are available for each credential_type value:

    credential_type str
    Specifies the type of credential that will be generated for the role. Options include: password, rsa_private_key, client_certificate. See the plugin's API page for credential types supported by individual databases.
    default_ttl int
    The default number of seconds for leases for this role.
    max_ttl int
    The maximum number of seconds for leases for this role.
    name str
    A unique name to give the role.
    namespace str
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    renew_statements Sequence[str]
    The database statements to execute when renewing a user.
    revocation_statements Sequence[str]
    The database statements to execute when revoking a user.
    rollback_statements Sequence[str]
    The database statements to execute when rolling back creation due to an error.
    backend String
    The unique name of the Vault mount to configure.
    creationStatements List<String>
    The database statements to execute when creating a user.
    dbName String
    The unique name of the database connection to use for the role.
    credentialConfig Map<Any>

    Specifies the configuration for the given credential_type.

    The following options are available for each credential_type value:

    credentialType String
    Specifies the type of credential that will be generated for the role. Options include: password, rsa_private_key, client_certificate. See the plugin's API page for credential types supported by individual databases.
    defaultTtl Number
    The default number of seconds for leases for this role.
    maxTtl Number
    The maximum number of seconds for leases for this role.
    name String
    A unique name to give the role.
    namespace String
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    renewStatements List<String>
    The database statements to execute when renewing a user.
    revocationStatements List<String>
    The database statements to execute when revoking a user.
    rollbackStatements List<String>
    The database statements to execute when rolling back creation due to an error.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the SecretBackendRole 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 SecretBackendRole Resource

    Get an existing SecretBackendRole 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?: SecretBackendRoleState, opts?: CustomResourceOptions): SecretBackendRole
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            backend: Optional[str] = None,
            creation_statements: Optional[Sequence[str]] = None,
            credential_config: Optional[Mapping[str, Any]] = None,
            credential_type: Optional[str] = None,
            db_name: Optional[str] = None,
            default_ttl: Optional[int] = None,
            max_ttl: Optional[int] = None,
            name: Optional[str] = None,
            namespace: Optional[str] = None,
            renew_statements: Optional[Sequence[str]] = None,
            revocation_statements: Optional[Sequence[str]] = None,
            rollback_statements: Optional[Sequence[str]] = None) -> SecretBackendRole
    func GetSecretBackendRole(ctx *Context, name string, id IDInput, state *SecretBackendRoleState, opts ...ResourceOption) (*SecretBackendRole, error)
    public static SecretBackendRole Get(string name, Input<string> id, SecretBackendRoleState? state, CustomResourceOptions? opts = null)
    public static SecretBackendRole get(String name, Output<String> id, SecretBackendRoleState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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:
    Backend string
    The unique name of the Vault mount to configure.
    CreationStatements List<string>
    The database statements to execute when creating a user.
    CredentialConfig Dictionary<string, object>

    Specifies the configuration for the given credential_type.

    The following options are available for each credential_type value:

    CredentialType string
    Specifies the type of credential that will be generated for the role. Options include: password, rsa_private_key, client_certificate. See the plugin's API page for credential types supported by individual databases.
    DbName string
    The unique name of the database connection to use for the role.
    DefaultTtl int
    The default number of seconds for leases for this role.
    MaxTtl int
    The maximum number of seconds for leases for this role.
    Name string
    A unique name to give the role.
    Namespace string
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    RenewStatements List<string>
    The database statements to execute when renewing a user.
    RevocationStatements List<string>
    The database statements to execute when revoking a user.
    RollbackStatements List<string>
    The database statements to execute when rolling back creation due to an error.
    Backend string
    The unique name of the Vault mount to configure.
    CreationStatements []string
    The database statements to execute when creating a user.
    CredentialConfig map[string]interface{}

    Specifies the configuration for the given credential_type.

    The following options are available for each credential_type value:

    CredentialType string
    Specifies the type of credential that will be generated for the role. Options include: password, rsa_private_key, client_certificate. See the plugin's API page for credential types supported by individual databases.
    DbName string
    The unique name of the database connection to use for the role.
    DefaultTtl int
    The default number of seconds for leases for this role.
    MaxTtl int
    The maximum number of seconds for leases for this role.
    Name string
    A unique name to give the role.
    Namespace string
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    RenewStatements []string
    The database statements to execute when renewing a user.
    RevocationStatements []string
    The database statements to execute when revoking a user.
    RollbackStatements []string
    The database statements to execute when rolling back creation due to an error.
    backend String
    The unique name of the Vault mount to configure.
    creationStatements List<String>
    The database statements to execute when creating a user.
    credentialConfig Map<String,Object>

    Specifies the configuration for the given credential_type.

    The following options are available for each credential_type value:

    credentialType String
    Specifies the type of credential that will be generated for the role. Options include: password, rsa_private_key, client_certificate. See the plugin's API page for credential types supported by individual databases.
    dbName String
    The unique name of the database connection to use for the role.
    defaultTtl Integer
    The default number of seconds for leases for this role.
    maxTtl Integer
    The maximum number of seconds for leases for this role.
    name String
    A unique name to give the role.
    namespace String
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    renewStatements List<String>
    The database statements to execute when renewing a user.
    revocationStatements List<String>
    The database statements to execute when revoking a user.
    rollbackStatements List<String>
    The database statements to execute when rolling back creation due to an error.
    backend string
    The unique name of the Vault mount to configure.
    creationStatements string[]
    The database statements to execute when creating a user.
    credentialConfig {[key: string]: any}

    Specifies the configuration for the given credential_type.

    The following options are available for each credential_type value:

    credentialType string
    Specifies the type of credential that will be generated for the role. Options include: password, rsa_private_key, client_certificate. See the plugin's API page for credential types supported by individual databases.
    dbName string
    The unique name of the database connection to use for the role.
    defaultTtl number
    The default number of seconds for leases for this role.
    maxTtl number
    The maximum number of seconds for leases for this role.
    name string
    A unique name to give the role.
    namespace string
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    renewStatements string[]
    The database statements to execute when renewing a user.
    revocationStatements string[]
    The database statements to execute when revoking a user.
    rollbackStatements string[]
    The database statements to execute when rolling back creation due to an error.
    backend str
    The unique name of the Vault mount to configure.
    creation_statements Sequence[str]
    The database statements to execute when creating a user.
    credential_config Mapping[str, Any]

    Specifies the configuration for the given credential_type.

    The following options are available for each credential_type value:

    credential_type str
    Specifies the type of credential that will be generated for the role. Options include: password, rsa_private_key, client_certificate. See the plugin's API page for credential types supported by individual databases.
    db_name str
    The unique name of the database connection to use for the role.
    default_ttl int
    The default number of seconds for leases for this role.
    max_ttl int
    The maximum number of seconds for leases for this role.
    name str
    A unique name to give the role.
    namespace str
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    renew_statements Sequence[str]
    The database statements to execute when renewing a user.
    revocation_statements Sequence[str]
    The database statements to execute when revoking a user.
    rollback_statements Sequence[str]
    The database statements to execute when rolling back creation due to an error.
    backend String
    The unique name of the Vault mount to configure.
    creationStatements List<String>
    The database statements to execute when creating a user.
    credentialConfig Map<Any>

    Specifies the configuration for the given credential_type.

    The following options are available for each credential_type value:

    credentialType String
    Specifies the type of credential that will be generated for the role. Options include: password, rsa_private_key, client_certificate. See the plugin's API page for credential types supported by individual databases.
    dbName String
    The unique name of the database connection to use for the role.
    defaultTtl Number
    The default number of seconds for leases for this role.
    maxTtl Number
    The maximum number of seconds for leases for this role.
    name String
    A unique name to give the role.
    namespace String
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    renewStatements List<String>
    The database statements to execute when renewing a user.
    revocationStatements List<String>
    The database statements to execute when revoking a user.
    rollbackStatements List<String>
    The database statements to execute when rolling back creation due to an error.

    Import

    Database secret backend roles can be imported using the backend, /roles/, and the name e.g.

    $ pulumi import vault:database/secretBackendRole:SecretBackendRole example postgres/roles/my-role
    

    Package Details

    Repository
    Vault pulumi/pulumi-vault
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the vault Terraform Provider.
    vault logo
    HashiCorp Vault v6.0.0 published on Monday, Mar 25, 2024 by Pulumi