Using Slingshot with Terraform

Using Slingshot with Terraform

by Jared Parks

What is Terraform?

Terraform allows you to manage Snowflake objects (like users, roles, databases, schemas, and warehouses) as code. This means you can define your Snowflake infrastructure in configuration files, version control it, and apply changes consistently and repeatably. It enables infrastructure as code (IaC) for Snowflake, automating the provisioning and management of your data platform.

Terraform and Slingshot

Currently, Slingshot’s architecture and operational methods are not designed to directly integrate with Terraform’s infrastructure-as-code approach for managing Snowflake objects. Slingshot manages Snowflake configurations through its internal processes, which do not expose the necessary APIs or hooks for Terraform to programmatically define, provision, or modify these resources. Therefore, using both tools to manage the same Snowflake environment would lead to conflicts and inconsistencies, as each tool would overwrite or fail to recognize changes made by the other.

Disable Terraform object synchronizations

In order to use Slingshot, a customer will need to disable the sync on the warehouse or other object that Slingshot is trying to manage. This can be done by following these steps:

  1. Locate the Snowflake resource block in your Terraform configuration: Open the .tf file where your Snowflake object (e.g., snowflake_warehouse) is defined.
  2. Add or modify the lifecycle block: Inside the resource block, add a lifecycle block if one doesn’t exist, and within it, set ignore_changes = all.
resource "snowflake_warehouse" "my_warehouse" {
  name = "MY_WAREHOUSE"
  // other warehouse configurations

  lifecycle {
    ignore_changes = all
  }
}
  1. Run terraform plan: Execute terraform plan in your terminal from the directory containing your Terraform configuration. This will show you the proposed changes. You should see a message indicating that the warehouse will no longer be managed by Terraform for any future changes.
  2. Run terraform apply: If the plan looks correct, execute terraform apply to apply the changes. This will update Terraform’s state file to reflect that it should ignore future changes to this specific resource.

After these steps, Terraform will stop attempting to sync or modify the specified Snowflake object. Slingshot can then manage this object without conflicts.