Skip to content

Commit 5985a0e

Browse files
Authentication Policy Changes / PR Comment updates
1 parent 99247ba commit 5985a0e

File tree

1 file changed

+18
-3
lines changed
  • terraform/snowflake/environments/prd

1 file changed

+18
-3
lines changed

terraform/snowflake/environments/prd/main.tf

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ variable "organization_name" {
1717
type = string
1818
}
1919

20+
variable "okta_integration_name" {
21+
description = "The name of the Okta security integration. If null, the odi_okta_only authentication policy will not be created."
22+
type = string
23+
default = null
24+
}
25+
2026
############################
2127
# Providers #
2228
############################
@@ -125,23 +131,24 @@ resource "snowflake_password_policy" "user_password_policy" {
125131
max_retries = 5
126132
lockout_time_mins = 30
127133
history = 5
128-
max_age_days = 60
129134
or_replace = true # Ensures the policy can be updated without errors
130135
}
131136

132137
# Set the default password policy for the account
133138
resource "snowflake_account_password_policy_attachment" "attachment" {
139+
provider = snowflake.accountadmin
134140
password_policy = snowflake_password_policy.user_password_policy.fully_qualified_name
135141
}
136142

137143
// Defines an authentication policy for ODI human users that enforces Okta-only authentication via SAML.
138144
resource "snowflake_authentication_policy" "odi_okta_only" {
145+
count = var.okta_integration_name == null ? 0 : 1 // meta-argument to conditionally create the resource
139146
provider = snowflake.accountadmin
140147
database = snowflake_database.policies.name # Database name
141148
schema = "PUBLIC" # Schema name
142149
name = "odi_okta_only"
143150
authentication_methods = ["SAML"]
144-
security_integrations = ["OKTAINTEGRATION"] # Okta security integration name
151+
security_integrations = [var.okta_integration_name] # Okta security integration name
145152
comment = "Okta-only authentication policy for ODI human users"
146153
}
147154

@@ -160,6 +167,7 @@ resource "snowflake_authentication_policy" "external_duo_mfa" {
160167

161168
// Defines an authentication policy for admin human users that allows both Okta SAML and password-based authentication with Duo MFA.
162169
resource "snowflake_authentication_policy" "admin_okta_duo" {
170+
count = var.okta_integration_name == null ? 0 : 1 // meta-argument to conditionally create the resource
163171
provider = snowflake.accountadmin
164172
database = snowflake_database.policies.name # Database name
165173
schema = "PUBLIC" # Schema name
@@ -168,7 +176,7 @@ resource "snowflake_authentication_policy" "admin_okta_duo" {
168176
mfa_authentication_methods = ["PASSWORD"]
169177
mfa_enrollment = "REQUIRED"
170178
client_types = ["SNOWFLAKE_UI", "DRIVERS", "SNOWSQL"]
171-
security_integrations = ["OKTAINTEGRATION"] # Okta security integration name
179+
security_integrations = [var.okta_integration_name] # Okta security integration name
172180
comment = "Okta and Duo-MFA authentication policy for admin human users"
173181
}
174182

@@ -193,3 +201,10 @@ resource "snowflake_authentication_policy" "legacy_service_password" {
193201
client_types = ["DRIVERS", "SNOWSQL"]
194202
comment = "Password-only authentication policy for legacy service accounts"
195203
}
204+
205+
# Set odi_okta_only as the default authentication policy for the account
206+
resource "snowflake_account_authentication_policy_attachment" "default_policy" {
207+
count = var.okta_integration_name == null ? 0 : 1
208+
provider = snowflake.accountadmin
209+
authentication_policy = snowflake_authentication_policy.odi_okta_only[0].fully_qualified_name // using the first and only instance that gets created
210+
}

0 commit comments

Comments
 (0)