Snowflake-Labs / terraform-provider-snowflake

Terraform provider for managing Snowflake accounts
https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest
MIT License
549 stars 420 forks source link

Multiple Billing Entities Stops Creation of Organization Accounts #2392

Open mswanson-mastery opened 9 months ago

mswanson-mastery commented 9 months ago

Terraform CLI and Provider Versions

Terraform v1.3.7
on darwin_arm64
+ provider registry.terraform.io/hashicorp/azurerm v3.7.0
+ provider registry.terraform.io/hashicorp/local v2.4.1
+ provider registry.terraform.io/hashicorp/random v3.6.0
+ provider registry.terraform.io/snowflake-labs/snowflake v0.67.0

Your version of Terraform is out of date! The latest version
is 1.7.0. You can update by downloading from https://www.terraform.io/downloads.html

Use Cases or Problem Statement

Last week we had our Snowflake contract enhanced to allow us to create accounts billed to either Azure or AWS. When running a manual terraform apply in our account provisioning project today to set up a new account on Azure, I was met with this error:

╷
│ Error: 042120 (22023): Multiple suitable billing entities exist for the target cloud 'AZURE', please specify the desired billing entity.
│ 
│   with snowflake_account.managed_snowflake_accounts["CLIENT-NAME"],
│   on main.tf line 13, in resource "snowflake_account" "managed_snowflake_accounts":
│   13: resource "snowflake_account" "managed_snowflake_accounts" {
│ 
╵

I don't see any way to get around this, other than a manual account create described here passing in a value for consumption_billing_entity.

consumption_billing_entity does not appear to be an available flag in any of the versions of the Snowflake provider that I've looked at, but I believe that it should be included as an optional flag for snowflake_account.

Proposal

Add optional flag for consumption_billing_entity to allow for more configuration.

How much impact is this issue causing?

Medium

Additional Information

No response

sfc-gh-asawicki commented 9 months ago

Hey @mswanson-mastery. Thanks for reporting the issue.

We have supporting missing parameters on our roadmap https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#19012024-roadmap-overview. I will bump its priority. If it becomes a blocking issue, please use the unsafe execute resource. It has some limitations, so please the docs carefully before using it.

mswanson-mastery commented 9 months ago

Hey there, @sfc-gh-asawicki - thank you for the workaround suggestion! It looks like that's not available on my version of the Snowflake provider (0.67) so any bump in priority would be much appreciated. I am going to attempt to manually create the account in our primary instance of Snowflake and then import it into our State.

Here's the error for reference:

╷
│ Error: Invalid resource type
│ 
│   on main.tf line 57, in resource "snowflake_unsafe_execute" "create_snowflake_account":
│   57: resource "snowflake_unsafe_execute" "create_snowflake_account" {
│ 
│ The provider snowflake-labs/snowflake does not support resource type "snowflake_unsafe_execute".
sfc-gh-asawicki commented 9 months ago

Hey @mswanson-mastery.

Yes, the unsafe execute resource is available from v0.77.0.

I want to remind you that we are in the 0.x.x version. When we introduce the missing parameter you will still have to upgrade to the newest released version since we are not providing changes for older versions (check the disclaimer in our README for more info).

mswanson-mastery commented 9 months ago

@sfc-gh-asawicki - That makes a lot of sense to me, we'll keep an eye out for that feature and plan to upgrade when it becomes available.

For anyone else encountering this issue: Manually creating the account via a CREATE in Snowflake did allow for a seamless import into our existing state, so we do have a workaround that is functional and isn't too much of a lift-and-shift from our standard processes.