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:
- Locate the Snowflake resource block in your Terraform configuration: Open the
.tf
file where your Snowflake object (e.g.,snowflake_warehouse
) is defined. - Add or modify the
lifecycle
block: Inside the resource block, add alifecycle
block if one doesn’t exist, and within it, setignore_changes = all
.
resource "snowflake_warehouse" "my_warehouse" {
name = "MY_WAREHOUSE"
// other warehouse configurations
lifecycle {
ignore_changes = all
}
}
- Run
terraform plan
: Executeterraform 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. - Run
terraform apply
: If the plan looks correct, executeterraform 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.