-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for network rules #2482
Comments
Hey @Relativity74205. Thanks for reaching out to us. We have adding the missing GA features on our roadmap: https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#our-roadmap. We'll make sure to take care of it then. |
@sfc-gh-asawicki Thanks for the info. |
@Relativity74205, we are always open to contributions. Some topics need to be addressed first:
From our side, the best course of action would be:
How does it sound? |
Hi @sfc-gh-asawicki, |
There is no issue on GH for this yet. I will create one, and I will let you know its number. |
Hey @Relativity74205, I created a feature request for SDK part: #2514, so you'll be able to track the progress. |
<!-- Feel free to delete comments as you fill this in --> Implements: #2514 Adds network rule to the sdk which is needed for #2482. <!-- summary of changes --> ## Test Plan * [x] unit and integration tests ## References <!-- issues documentation links, etc --> * [Create network rules](https://docs.snowflake.com/en/sql-reference/sql/create-network-rule)
Hey @Relativity74205. We have merged the SDK part of the network rules. |
Sorry to chime in, I am on 0.87.0 but do not see a |
Hey @wietze. Please check the comment: #2482 (comment). Only the SDK part was implemented, not the resource itself. |
@sfc-gh-asawicki Thanks for the info and the implementation of the SDK. I have started to implement the network rules. However, it seems to me, that the network policies SDK needs to be updated first. |
@Relativity74205 We created a new GH issue, so you'll be able to track the progress - #2593 |
@sfc-gh-jcieslak Thanks a lot! |
@sfc-gh-jcieslak I noticed, that the headline of #2593 is wrong. Not the network rules SDK but the network policy SDK has to be updated. And do you have perhaps an ETA, when the SDK will be updated? |
Hey @Relativity74205. We should have it as part of the next week's release. |
Hey @Relativity74205. The issue #2593 was completed in #2647. Let us know if you need anything more from us :) |
@sfc-gh-asawicki Thanks for the update. On the first glance, everything looks good, I will be working now on the network rules. :) |
@sfc-gh-asawicki I started to implement it and have encountered some issues/questions. A WIP PR can be found here: #2746. Please note, that there are many todos there, among other things tests, docs, etc. are missing. However, before I finish the PR, I wanted to clarify the following: My questions/issues:
|
Hey @Relativity74205. The SDK is created based on the Snowflake docs, so:
There is no UNSET listed in https://docs.snowflake.com/en/sql-reference/sql/alter-network-policy#syntax. There is, however, a REMOVE/ADD pair that can be utilized to "unset". Does the UNSET work by hand in a worksheet for any of those lists? If so, this may mean that the docs are incomplete.
It is implemented in the SDK (https://docs.snowflake.com/en/sql-reference/sql/alter-network-rule#syntax):
As I understand, it would be a duplication of Snowflake logic that would be coupled closely with any changes happening on the Snowflake side. In such cases we currently have an approach to leave the validation to Snowflake, so it the first version I would prefer not to have this additional logic. |
@sfc-gh-asawicki Thanks for the fast reply.
Totally missed that, somehow. It works, thanks.
The UNSET is mentioned in the parameters section, however, only with regards to Comments and Tags. Interestingly, it works on all other parameters when writing the SQL commands manually. Currently, I am not sure, how to implement the removal of all entries for an ip_list/rule_list. Is it possible to access the old values in the UpdateContext? Then I could create a remove command.
Yes, that would be a duplication of Snowflake logic and my first idea was also not to duplicate the logic. However, from a user perspective of the snowflake provider, it is a big downside if a wrong configuration of the ressource is not noticed during the plan phase only during the apply phase. |
This is what I meant by potentially incomplete documentation. I will reach out to the team responsible for this command internally and confirm if it works by accident or is it just the incomplete documentation.
Given the current implementation of the SDK, you have multiple options:
This set is not meant to be used with an empty list (this is true for other objects in the SDK too).
Yes, this is a downside. But other option, when all the changes, not only the validations, but other parts of Snowflake logic would be migrated to the provider, and would have to be synchronized in every stable version of the provider almost instantly, and would require constant migrations from the users are not appealing. We think it would be unmanageable, both for us and for our users, so for V1 we won't do such validations (with exceptions ofc). |
Good points. I will then remove the
Thanks. I would be also interested in the answer ;) |
@sfc-gh-asawicki Sorry to bother you again. Implementing addition and removal of network rules to the network policy worked, also the removal of all network rules. |
Hey @Relativity74205, I am off today, but I handed this topic to @sfc-gh-jcieslak and @sfc-gh-jmichalak; they will get in touch with you (I think the |
Hi @Relativity74205 I confirmed with network policy team that UNSET for other fields is just undocumented. I'm taking care of it in SDK, will keep you updated on this change. |
@sfc-gh-jmichalak |
@Relativity74205 I merged #2759. Now, UNSET and empty SET are supported for the remaining network policy fields, so you can remove all IPs and network rules easily. Let us know if you need anything :) |
Hi @sfc-gh-jmichalak , I am now nearly finished (PR: #2746). I have still to add the docs and the tests (will do it in the next days). |
resolves #2482 <!-- summary of changes --> - adds network rules - adds network rule lists to network policies - fixes network policies ## Test Plan <!-- detail ways in which this PR has been tested or needs to be tested --> * [x] acceptance tests <!-- add more below if you think they are relevant --> * [ ] … ## References <!-- issues documentation links, etc --> * --------- Co-authored-by: Arkadius Schuchhardt <[email protected]> Co-authored-by: Artur Sawicki <[email protected]>
Terraform CLI and Provider Versions
Terraform v1.5.7
Providor v0.85.0
Use Cases or Problem Statement
The old way of assigning IPs directly to a network policy is deprecated by Snowflake. The new way is to define network rules (see e.g. here https://docs.snowflake.com/en/sql-reference/sql/create-network-rule) and to assign them to network policies (see https://docs.snowflake.com/en/sql-reference/sql/alter-network-policy).
Proposal
Add a snowflake_network_rule resource and modify snowflake_network_policy resource.
How much impact is this issue causing?
Medium
Additional Information
No response
The text was updated successfully, but these errors were encountered: