Skip to main content

password_policies

Creates, updates, deletes, gets or lists a password_policies resource.

Overview

Namepassword_policies
TypeResource
Idsnowflake.security.password_policies

Fields

The following fields are returned by SELECT queries:

successful

NameDatatypeDescription
namestringName of the password policy (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
database_namestringDatabase in which the password policy is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
schema_namestringSchema in which the password policy is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
commentstringComment for the password policy
created_onstring (date-time)Date and time when the password policy was created.
ownerstringRole that owns the password policy (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
owner_role_typestringThe type of role that owns the password policy
password_historyintegerNumber of distinct passwords that a user must create before re-using a previous password
password_lockout_time_minsintegerPeriod of time for which users will be locked after entering their password incorrectly many times (specified by MAX_RETRIES), in minutes
password_max_age_daysintegerPeriod after which password must be changed, in days.
password_max_lengthintegerMaximum length of new password.
password_max_retriesintegerNumber of attempts users have to enter the correct password before their account is locked.
password_min_age_daysintegerPeriod after a password is changed during which a password cannot be changed again, in days.
password_min_lengthintegerMinimum length of new password.
password_min_lower_case_charsintegerMinimum number of lowercase characters in new password.
password_min_numeric_charsintegerMinimum number of numeric characters in new password.
password_min_special_charsintegerMinimum number of special characters in new password.
password_min_upper_case_charsintegerMinimum number of uppercase characters in new password.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectdatabase_name, schema_name, name, endpointFetch a password policy
listselectdatabase_name, schema_name, endpointlike, startsWith, showLimitList password policies
createinsertdatabase_name, schema_name, endpoint, namecreateModeCreate a password policy
deletedeletedatabase_name, schema_name, name, endpointifExistsDelete a password policy
renameexecdatabase_name, schema_name, name, targetName, endpointifExists, targetDatabase, targetSchemaRename a password policy with a new identifier

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
database_namestringIdentifier (i.e. name) for the database to which the resource belongs. You can use the /api/v2/databases GET request to get a list of available databases.
endpointstringOrganization and account identifier (orgname-accountname) (default: orgname-accountname)
namestringIdentifier (i.e. name) for the resource.
schema_namestringIdentifier (i.e. name) for the schema to which the resource belongs. You can use the /api/v2/databases/{database}/schemas GET request to get a list of available schemas for the specified database.
targetNamestringName of the target resource.
createModestringParameter allowing support for different modes of resource creation. Possible values include: - errorIfExists: Throws an error if you try to create a resource that already exists. - orReplace: Automatically replaces the existing resource with the current one. - ifNotExists: Creates a new resource when an alter is requested for a non-existent resource.
ifExistsbooleanParameter that specifies how to handle the request for a resource that does not exist: - true: The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false: The endpoint throws an error if the resource doesn't exist.
likestringParameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.
showLimitintegerParameter to limit the maximum number of rows returned by a command.
startsWithstringParameter to filter the command output based on the string of characters that appear at the beginning of the object name. Uses case-sensitive pattern matching.
targetDatabasestringDatabase of the target resource. Defaults to the source's database
targetSchemastringSchema of the target resource. Defaults to the source's schema

SELECT examples

Fetch a password policy

SELECT
name,
database_name,
schema_name,
comment,
created_on,
owner,
owner_role_type,
password_history,
password_lockout_time_mins,
password_max_age_days,
password_max_length,
password_max_retries,
password_min_age_days,
password_min_length,
password_min_lower_case_chars,
password_min_numeric_chars,
password_min_special_chars,
password_min_upper_case_chars
FROM snowflake.security.password_policies
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND name = '{{ name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
;

INSERT examples

Create a password policy

INSERT INTO snowflake.security.password_policies (
comment,
password_min_length,
password_max_length,
password_min_upper_case_chars,
password_min_lower_case_chars,
password_min_numeric_chars,
password_min_special_chars,
password_min_age_days,
password_max_age_days,
password_max_retries,
password_lockout_time_mins,
password_history,
name,
database_name,
schema_name,
endpoint,
createMode
)
SELECT
'{{ comment }}',
{{ password_min_length }},
{{ password_max_length }},
{{ password_min_upper_case_chars }},
{{ password_min_lower_case_chars }},
{{ password_min_numeric_chars }},
{{ password_min_special_chars }},
{{ password_min_age_days }},
{{ password_max_age_days }},
{{ password_max_retries }},
{{ password_lockout_time_mins }},
{{ password_history }},
'{{ name }}' /* required */,
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}',
'{{ createMode }}'
RETURNING
status
;

DELETE examples

Delete a password policy

DELETE FROM snowflake.security.password_policies
WHERE database_name = '{{ database_name }}' --required
AND schema_name = '{{ schema_name }}' --required
AND name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}'
;

Lifecycle Methods

Rename a password policy with a new identifier

EXEC snowflake.security.password_policies.rename
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@name='{{ name }}' --required,
@targetName='{{ targetName }}' --required,
@endpoint='{{ endpoint }}' --required,
@ifExists={{ ifExists }},
@targetDatabase='{{ targetDatabase }}',
@targetSchema='{{ targetSchema }}'
;