Skip to content

getindata/terraform-snowflake-resource-monitor

Repository files navigation

Snowflake Resource Monitor Terraform Module

Snowflake Terraform

License Release

We help companies turn their data into assets


Terraform module for Snowflake Resource Monitor management

  • Creates Snowflake Resource Monitor
  • Can create custom Snowflake Roles with role-to-role, role-to-user assignments
  • Can create a set of default, functional roles to simplify access management:
    • ADMIN - full access
    • MODIFY - abillity to modify resource monitor
    • MONITOR - abillity to monitor resource monitor

USAGE

module "resource_monitors" {
  source = "getindata/resource-monitor/snowflake"

  name = "example_resource_monitor"

  credit_quota = 50

  notify_triggers            = [50, 80, 90]
  suspend_triggers           = [100]
  suspend_immediate_triggers = [110]

  set_for_account = true
}

EXAMPLES

Breaking changes in v4.x of the module

Due to replacement of nulllabel (context.tf) with context provider, some breaking changes were introduced in v4.0.0 version of this module.

List of code and variable (API) changes:

  • Removed context.tf file (a single-file module with additional variables), which implied a removal of all its variables (except name):
    • descriptor_formats
    • label_value_case
    • label_key_case
    • id_length_limit
    • regex_replace_chars
    • label_order
    • additional_tag_map
    • tags
    • labels_as_tags
    • attributes
    • delimiter
    • stage
    • environment
    • tenant
    • namespace
    • enabled
    • context
  • Remove support enabled flag - that might cause some backward compatibility issues with terraform state (please take into account that proper move clauses were added to minimize the impact), but proceed with caution
  • Additional context provider configuration
  • New variables were added, to allow naming configuration via context provider:
    • context_templates
    • name_schema

Additionally, due to breaking changes introduced in snowflake terraform provider v0.96.0 (snowflake_resource_monitor resource):

  • Removal of set_for_account variable / flag (will be settable on account resource)
  • Removal of warehouses variable (will be settable on warehouse resource)

Inputs

Name Description Type Default Required
context_templates Map of context templates used for naming conventions - this variable supersedes naming_scheme.properties and naming_scheme.delimiter configuration map(string) {} no
create_default_roles Whether the default roles should be created bool false no
credit_quota The number of credits allocated monthly to the resource monitor. number null no
end_timestamp The date and time when the resource monitor suspends the assigned warehouses. string null no
frequency The frequency interval at which the credit usage resets to 0. If you set a frequency for a resource monitor, you must also set START_TIMESTAMP. string null no
name Name of the resource string n/a yes
name_scheme Naming scheme configuration for the resource. This configuration is used to generate names using context provider:
- properties - list of properties to use when creating the name - is superseded by var.context_templates
- delimiter - delimited used to create the name from properties - is superseded by var.context_templates
- context_template_name - name of the context template used to create the name
- replace_chars_regex - regex to use for replacing characters in property-values created by the provider - any characters that match the regex will be removed from the name
- extra_values - map of extra label-value pairs, used to create a name
object({
properties = optional(list(string), ["environment", "name"])
delimiter = optional(string, "_")
context_template_name = optional(string, "snowflake-resource-monitor")
replace_chars_regex = optional(string, "[^a-zA-Z0-9_]")
extra_values = optional(map(string))
})
{} no
notify_triggers A list of percentage thresholds at which to send an alert to subscribed users. list(number) null no
notify_users Specifies the list of users to receive email notifications on resource monitors. list(string) null no
roles Roles created on the Resource Monitor level
map(object({
name_scheme = optional(object({
properties = optional(list(string))
delimiter = optional(string)
context_template_name = optional(string)
replace_chars_regex = optional(string)
extra_labels = optional(map(string))
}))
comment = optional(string)
role_ownership_grant = optional(string)
granted_roles = optional(list(string))
granted_to_roles = optional(list(string))
granted_to_users = optional(list(string))
resource_monitor_grants = optional(object({
all_privileges = optional(bool)
with_grant_option = optional(bool, false)
privileges = optional(list(string))
}))
}))
{} no
start_timestamp The date and time when the resource monitor starts monitoring credit usage for the assigned warehouses. string null no
suspend_immediate_trigger The number that represents the percentage threshold at which to immediately suspend all warehouses. number null no
suspend_trigger The number that represents the percentage threshold at which to suspend all warehouses. number null no

Modules

Name Source Version
roles_deep_merge Invicton-Labs/deepmerge/null 0.1.5
snowflake_custom_role getindata/role/snowflake 3.0.1
snowflake_default_role getindata/role/snowflake 3.0.1

Outputs

Name Description
credit_quota The number of credits allocated monthly to the resource monitor
end_timestamp The date and time when the resource monitor suspends the assigned warehouses
frequency The frequency interval at which the credit usage resets to 0
name Name of resource monitor
notify_triggers A list of percentage thresholds at which to send an alert to subscribed users
notify_users A list of users to receive email notifications on resource monitors
roles Access roles created for resource monitor
start_timestamp The date and time when the resource monitor starts monitoring credit usage
suspend_immediate_triggers A list of percentage thresholds at which to immediately suspend all warehouses
suspend_triggers A list of percentage thresholds at which to suspend all warehouses

Providers

Name Version
context >=0.4.0
snowflake >= 0.96

Requirements

Name Version
terraform >= 1.3
context >=0.4.0
snowflake >= 0.96

Resources

Name Type
snowflake_resource_monitor.this resource
context_label.this data source

CONTRIBUTING

Contributions are very welcomed!

Start by reviewing contribution guide and our code of conduct. After that, start coding and ship your changes by creating a new PR.

LICENSE

Apache 2 Licensed. See LICENSE for full details.

AUTHORS

Made with contrib.rocks.

About

Terraform module that can create and manage Snowflake Resource Monitors.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages