1. Packages
  2. HashiCorp Vault Provider
  3. API Docs
  4. PasswordPolicy
HashiCorp Vault v6.6.0 published on Thursday, Mar 13, 2025 by Pulumi

vault.PasswordPolicy

Explore with Pulumi AI

Provides a resource to manage Password Policies

Note this feature is available only Vault 1.5+

Example Usage

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

const alphanumeric = new vault.PasswordPolicy("alphanumeric", {
    name: "alphanumeric",
    policy: `    length = 20
    rule "charset" {
      charset = "abcdefghijklmnopqrstuvwxyz0123456789"
    }
`,
});
Copy
import pulumi
import pulumi_vault as vault

alphanumeric = vault.PasswordPolicy("alphanumeric",
    name="alphanumeric",
    policy="""    length = 20
    rule "charset" {
      charset = "abcdefghijklmnopqrstuvwxyz0123456789"
    }
""")
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := vault.NewPasswordPolicy(ctx, "alphanumeric", &vault.PasswordPolicyArgs{
			Name:   pulumi.String("alphanumeric"),
			Policy: pulumi.String("    length = 20\n    rule \"charset\" {\n      charset = \"abcdefghijklmnopqrstuvwxyz0123456789\"\n    }\n"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Vault = Pulumi.Vault;

return await Deployment.RunAsync(() => 
{
    var alphanumeric = new Vault.PasswordPolicy("alphanumeric", new()
    {
        Name = "alphanumeric",
        Policy = @"    length = 20
    rule ""charset"" {
      charset = ""abcdefghijklmnopqrstuvwxyz0123456789""
    }
",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vault.PasswordPolicy;
import com.pulumi.vault.PasswordPolicyArgs;
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 alphanumeric = new PasswordPolicy("alphanumeric", PasswordPolicyArgs.builder()
            .name("alphanumeric")
            .policy("""
    length = 20
    rule "charset" {
      charset = "abcdefghijklmnopqrstuvwxyz0123456789"
    }
            """)
            .build());

    }
}
Copy
resources:
  alphanumeric:
    type: vault:PasswordPolicy
    properties:
      name: alphanumeric
      policy: |2
            length = 20
            rule "charset" {
              charset = "abcdefghijklmnopqrstuvwxyz0123456789"
            }
Copy

Create PasswordPolicy Resource

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

Constructor syntax

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

@overload
def PasswordPolicy(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   policy: Optional[str] = None,
                   name: Optional[str] = None,
                   namespace: Optional[str] = None)
func NewPasswordPolicy(ctx *Context, name string, args PasswordPolicyArgs, opts ...ResourceOption) (*PasswordPolicy, error)
public PasswordPolicy(string name, PasswordPolicyArgs args, CustomResourceOptions? opts = null)
public PasswordPolicy(String name, PasswordPolicyArgs args)
public PasswordPolicy(String name, PasswordPolicyArgs args, CustomResourceOptions options)
type: vault:PasswordPolicy
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. PasswordPolicyArgs
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. PasswordPolicyArgs
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. PasswordPolicyArgs
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. PasswordPolicyArgs
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. PasswordPolicyArgs
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 passwordPolicyResource = new Vault.PasswordPolicy("passwordPolicyResource", new()
{
    Policy = "string",
    Name = "string",
    Namespace = "string",
});
Copy
example, err := vault.NewPasswordPolicy(ctx, "passwordPolicyResource", &vault.PasswordPolicyArgs{
	Policy:    pulumi.String("string"),
	Name:      pulumi.String("string"),
	Namespace: pulumi.String("string"),
})
Copy
var passwordPolicyResource = new PasswordPolicy("passwordPolicyResource", PasswordPolicyArgs.builder()
    .policy("string")
    .name("string")
    .namespace("string")
    .build());
Copy
password_policy_resource = vault.PasswordPolicy("passwordPolicyResource",
    policy="string",
    name="string",
    namespace="string")
Copy
const passwordPolicyResource = new vault.PasswordPolicy("passwordPolicyResource", {
    policy: "string",
    name: "string",
    namespace: "string",
});
Copy
type: vault:PasswordPolicy
properties:
    name: string
    namespace: string
    policy: string
Copy

PasswordPolicy 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 PasswordPolicy resource accepts the following input properties:

Policy This property is required. string
String containing a password policy.
Name Changes to this property will trigger replacement. string
The name of the password policy.
Namespace Changes to this property will trigger replacement. 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.
Policy This property is required. string
String containing a password policy.
Name Changes to this property will trigger replacement. string
The name of the password policy.
Namespace Changes to this property will trigger replacement. 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.
policy This property is required. String
String containing a password policy.
name Changes to this property will trigger replacement. String
The name of the password policy.
namespace Changes to this property will trigger replacement. 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.
policy This property is required. string
String containing a password policy.
name Changes to this property will trigger replacement. string
The name of the password policy.
namespace Changes to this property will trigger replacement. 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.
policy This property is required. str
String containing a password policy.
name Changes to this property will trigger replacement. str
The name of the password policy.
namespace Changes to this property will trigger replacement. 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.
policy This property is required. String
String containing a password policy.
name Changes to this property will trigger replacement. String
The name of the password policy.
namespace Changes to this property will trigger replacement. 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.

Outputs

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

Get an existing PasswordPolicy 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?: PasswordPolicyState, opts?: CustomResourceOptions): PasswordPolicy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        name: Optional[str] = None,
        namespace: Optional[str] = None,
        policy: Optional[str] = None) -> PasswordPolicy
func GetPasswordPolicy(ctx *Context, name string, id IDInput, state *PasswordPolicyState, opts ...ResourceOption) (*PasswordPolicy, error)
public static PasswordPolicy Get(string name, Input<string> id, PasswordPolicyState? state, CustomResourceOptions? opts = null)
public static PasswordPolicy get(String name, Output<String> id, PasswordPolicyState state, CustomResourceOptions options)
resources:  _:    type: vault:PasswordPolicy    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:
Name Changes to this property will trigger replacement. string
The name of the password policy.
Namespace Changes to this property will trigger replacement. 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.
Policy string
String containing a password policy.
Name Changes to this property will trigger replacement. string
The name of the password policy.
Namespace Changes to this property will trigger replacement. 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.
Policy string
String containing a password policy.
name Changes to this property will trigger replacement. String
The name of the password policy.
namespace Changes to this property will trigger replacement. 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.
policy String
String containing a password policy.
name Changes to this property will trigger replacement. string
The name of the password policy.
namespace Changes to this property will trigger replacement. 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.
policy string
String containing a password policy.
name Changes to this property will trigger replacement. str
The name of the password policy.
namespace Changes to this property will trigger replacement. 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.
policy str
String containing a password policy.
name Changes to this property will trigger replacement. String
The name of the password policy.
namespace Changes to this property will trigger replacement. 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.
policy String
String containing a password policy.

Import

Password policies can be imported using the name, e.g.

$ pulumi import vault:index/passwordPolicy:PasswordPolicy alphanumeric alphanumeric
Copy

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

Package Details

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