<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Terraform - how to add new host or network objects to existing group in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Terraform-how-to-add-new-host-or-network-objects-to-existing/m-p/117640#M5822</link>
    <description>&lt;P&gt;Hi&amp;nbsp;CheckMates.&lt;/P&gt;&lt;P&gt;We are investigating the possibilities for using Terraform integration to automate management of firewall policies, and we are running into an unexpected issue.&lt;/P&gt;&lt;P&gt;It is relatively straight forward to prepare Check Point management and Terraform to work together, and we can create and modify&amp;nbsp; new objects, add new hosts and network objects to new groups etc.&amp;nbsp;The issue is, that it is only possible to mange objects created by Terraform, and not existing objects.&lt;/P&gt;&lt;P&gt;Our use case is, that we will create a simple group with SmartConsole and use this object in a firewall rule. With Terraform we will create new host or network objects and add these to the existing group. This is not working, and it looks like a problem with UUID's for the objects.&lt;/P&gt;&lt;P&gt;We are using the checkpoint provider for terraform (&lt;A href="https://registry.terraform.io/providers/CheckPointSW/checkpoint/latest" target="_blank"&gt;https://registry.terraform.io/providers/CheckPointSW/checkpoint/latest&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What have we tried out:&lt;/P&gt;&lt;P&gt;Experimenting with the checkpoint provider, reading the provider documentation &amp;amp; code and the API documentation, we tried out following terraform configuration:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;terraform&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; required_providers&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; checkpoint&amp;nbsp;=&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; version&amp;nbsp;=&amp;nbsp;"&amp;gt;=1.4.0"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; source&amp;nbsp;=&amp;nbsp;"CheckPointSW/checkpoint"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;"checkpoint"&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; server&amp;nbsp;=&amp;nbsp;""&lt;/P&gt;&lt;P&gt;&amp;nbsp; username&amp;nbsp;=&amp;nbsp;""&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; password&amp;nbsp;=&amp;nbsp;""&lt;/P&gt;&lt;P&gt;&amp;nbsp; context&amp;nbsp;=&amp;nbsp;"web_api"&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;resource "checkpoint_management_network" "service_subnet1" {&lt;/P&gt;&lt;P&gt;&amp;nbsp; name = "net-192.168.2.0-m24"&lt;/P&gt;&lt;P&gt;&amp;nbsp; subnet4 = "198.168.2.0"&lt;/P&gt;&lt;P&gt;&amp;nbsp; mask_length4 = 24&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;resource "checkpoint_management_network" "service_subnet2" {&lt;/P&gt;&lt;P&gt;&amp;nbsp; name = "net-192.168.3.0-m24"&lt;/P&gt;&lt;P&gt;&amp;nbsp; subnet4 = "198.168.3.0"&lt;/P&gt;&lt;P&gt;&amp;nbsp; mask_length4 = 24&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;resource "checkpoint_management_group" "group" {&lt;/P&gt;&lt;P&gt;&amp;nbsp; name = "terraformtestgroup" # We would like to create this group directly in checkpoint, and update it using terraform&lt;/P&gt;&lt;P&gt;&amp;nbsp; members = [ checkpoint_management_network.service_subnet1.name, checkpoint_management_network.service_subnet2.name ]&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then we run publish using the provided excutable to publish the session.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anybody out there suggest a solution to our issue? Or do anyone know who in Check Point to contact for Terraform issues?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Peter Sode&lt;/P&gt;&lt;P&gt;Dubex, Denmark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 04 May 2021 13:09:57 GMT</pubDate>
    <dc:creator>Peter_Janum_Sod</dc:creator>
    <dc:date>2021-05-04T13:09:57Z</dc:date>
    <item>
      <title>Terraform - how to add new host or network objects to existing group</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Terraform-how-to-add-new-host-or-network-objects-to-existing/m-p/117640#M5822</link>
      <description>&lt;P&gt;Hi&amp;nbsp;CheckMates.&lt;/P&gt;&lt;P&gt;We are investigating the possibilities for using Terraform integration to automate management of firewall policies, and we are running into an unexpected issue.&lt;/P&gt;&lt;P&gt;It is relatively straight forward to prepare Check Point management and Terraform to work together, and we can create and modify&amp;nbsp; new objects, add new hosts and network objects to new groups etc.&amp;nbsp;The issue is, that it is only possible to mange objects created by Terraform, and not existing objects.&lt;/P&gt;&lt;P&gt;Our use case is, that we will create a simple group with SmartConsole and use this object in a firewall rule. With Terraform we will create new host or network objects and add these to the existing group. This is not working, and it looks like a problem with UUID's for the objects.&lt;/P&gt;&lt;P&gt;We are using the checkpoint provider for terraform (&lt;A href="https://registry.terraform.io/providers/CheckPointSW/checkpoint/latest" target="_blank"&gt;https://registry.terraform.io/providers/CheckPointSW/checkpoint/latest&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What have we tried out:&lt;/P&gt;&lt;P&gt;Experimenting with the checkpoint provider, reading the provider documentation &amp;amp; code and the API documentation, we tried out following terraform configuration:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;terraform&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; required_providers&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; checkpoint&amp;nbsp;=&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; version&amp;nbsp;=&amp;nbsp;"&amp;gt;=1.4.0"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; source&amp;nbsp;=&amp;nbsp;"CheckPointSW/checkpoint"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;"checkpoint"&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; server&amp;nbsp;=&amp;nbsp;""&lt;/P&gt;&lt;P&gt;&amp;nbsp; username&amp;nbsp;=&amp;nbsp;""&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; password&amp;nbsp;=&amp;nbsp;""&lt;/P&gt;&lt;P&gt;&amp;nbsp; context&amp;nbsp;=&amp;nbsp;"web_api"&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;resource "checkpoint_management_network" "service_subnet1" {&lt;/P&gt;&lt;P&gt;&amp;nbsp; name = "net-192.168.2.0-m24"&lt;/P&gt;&lt;P&gt;&amp;nbsp; subnet4 = "198.168.2.0"&lt;/P&gt;&lt;P&gt;&amp;nbsp; mask_length4 = 24&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;resource "checkpoint_management_network" "service_subnet2" {&lt;/P&gt;&lt;P&gt;&amp;nbsp; name = "net-192.168.3.0-m24"&lt;/P&gt;&lt;P&gt;&amp;nbsp; subnet4 = "198.168.3.0"&lt;/P&gt;&lt;P&gt;&amp;nbsp; mask_length4 = 24&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;resource "checkpoint_management_group" "group" {&lt;/P&gt;&lt;P&gt;&amp;nbsp; name = "terraformtestgroup" # We would like to create this group directly in checkpoint, and update it using terraform&lt;/P&gt;&lt;P&gt;&amp;nbsp; members = [ checkpoint_management_network.service_subnet1.name, checkpoint_management_network.service_subnet2.name ]&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then we run publish using the provided excutable to publish the session.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anybody out there suggest a solution to our issue? Or do anyone know who in Check Point to contact for Terraform issues?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Peter Sode&lt;/P&gt;&lt;P&gt;Dubex, Denmark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 13:09:57 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Terraform-how-to-add-new-host-or-network-objects-to-existing/m-p/117640#M5822</guid>
      <dc:creator>Peter_Janum_Sod</dc:creator>
      <dc:date>2021-05-04T13:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: Terraform - how to add new host or network objects to existing group</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Terraform-how-to-add-new-host-or-network-objects-to-existing/m-p/117746#M5828</link>
      <description>&lt;P&gt;Hi Peter,&lt;/P&gt;
&lt;P&gt;You can't manage resources in Terraform that aren't created by Terraform, unless you import them first.&lt;/P&gt;
&lt;P&gt;Have a look at&amp;nbsp;&lt;A href="https://www.terraform.io/docs/cli/import/index.html" target="_blank"&gt;https://www.terraform.io/docs/cli/import/index.html&lt;/A&gt;&amp;nbsp;to import the existing group to be managed by Terraform after being created "by other means". The lifecycle argument `prevent_destroy` can be used to safeguard against accidental deletion of the group (&lt;A href="https://www.terraform.io/docs/language/meta-arguments/lifecycle.html#prevent_destroy" target="_blank"&gt;https://www.terraform.io/docs/language/meta-arguments/lifecycle.html#prevent_destroy&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;Having external unmanaged dependencies can be an acceptable temporary solution while you transition your infrastructure to Terraform if you are planning to eventually have everything in Terraform.&lt;/P&gt;
&lt;P&gt;Depending on your overall use-cases, the scenario you are describing here could be a great candidate for a generic DC object as well -&amp;nbsp;&lt;A href="https://sc1.checkpoint.com/documents/R81/WebAdminGuides/EN/CP_R81_SecurityManagement_AdminGuide/Topics-SECMG/Generic-DC-Object.htm" target="_self"&gt;Generic Data Center Object&lt;/A&gt;. This could be as simple as updating a hosted JSON file with a template from inside Terraform. This has the additional benefit that it updates without requiring a policy installation.&lt;/P&gt;
&lt;P&gt;The other option that might be interesting is our integration with Hashicorp Consul:&amp;nbsp;&lt;A href="https://github.com/CheckPointSW/terraform-checkpoint-dynobj-nia" target="_blank"&gt;https://github.com/CheckPointSW/terraform-checkpoint-dynobj-nia&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 13:33:25 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Terraform-how-to-add-new-host-or-network-objects-to-existing/m-p/117746#M5828</guid>
      <dc:creator>Jonas_Rosenboom</dc:creator>
      <dc:date>2021-05-05T13:33:25Z</dc:date>
    </item>
  </channel>
</rss>

