|  | 
| 1 | 1 | ###################################### | 
| 2 | 2 | #            Terraform               # | 
| 3 | 3 | ###################################### | 
| 4 |  | - | 
|  | 4 | +# This module enforces Snowflake security by creating a POLICIES database, | 
|  | 5 | +# defining strong default password/authentication policies for different user types, | 
|  | 6 | +# setting Okta-only auth as the default (when enabled), and provisioning a Sentinel | 
|  | 7 | +# legacy service user with the required role grants. | 
| 5 | 8 | ############################ | 
| 6 | 9 | #         Providers        # | 
| 7 | 10 | ############################ | 
| @@ -118,3 +121,25 @@ resource "snowflake_account_authentication_policy_attachment" "default_policy" { | 
| 118 | 121 |   provider                   = snowflake.accountadmin | 
| 119 | 122 |   authentication_policy      = snowflake_authentication_policy.odi_okta_only[0].fully_qualified_name // using the first and only instance that gets created | 
| 120 | 123 | } | 
|  | 124 | + | 
|  | 125 | +# Create a sentinel service user with password authentication (legacy service user) | 
|  | 126 | +resource "snowflake_legacy_service_user" "sentinel" { | 
|  | 127 | +  provider = snowflake.useradmin | 
|  | 128 | +  name     = "SENTINEL_SVC_USER" | 
|  | 129 | +  comment  = "Service user for Sentinel" | 
|  | 130 | +  lifecycle { | 
|  | 131 | +    ignore_changes = [rsa_public_key] | 
|  | 132 | +  } | 
|  | 133 | + | 
|  | 134 | +  # Use the input variable here | 
|  | 135 | +  default_warehouse = var.logging_warehouse_name | 
|  | 136 | +  # Use the input variable here | 
|  | 137 | +  default_role      = var.logger_role_name | 
|  | 138 | +} | 
|  | 139 | + | 
|  | 140 | +resource "snowflake_grant_account_role" "logger_to_sentinel" { | 
|  | 141 | +  provider  = snowflake.useradmin | 
|  | 142 | +  # Use the input variable here | 
|  | 143 | +  role_name = var.logger_role_name | 
|  | 144 | +  user_name = snowflake_legacy_service_user.sentinel.name | 
|  | 145 | +} | 
0 commit comments