Hey guys, I know this was a while back now it came up on another project I was working on recently. Extending on Art's answer - I think the most complete way to manage publish or install actions is using the helper utilities that come with the Check Point Terraform provider (https://github.com/CheckPointSW/terraform-provider-checkpoint/tree/master/commands). They're mention on the overview page but not in the context of how to use them in a TF module.
First - you need install Go on the machine you're deploying from. Then, clone or download the code from the link above and change to the commands > publish directory.
Run 'go build publish.go' and it will compile a binary in the current directory named 'publish'. Move this to a directory in your path and check it runs by running 'publish' (it will error, but that's fine at this point).
Then in your TF module, use this as a framework:
terraform {
required_providers {
checkpoint = {
source = "CheckPointSW/checkpoint"
version = "1.5.0"
}
}
}
provider "checkpoint" {
server = "YOUR.MGMT.IP.HERE"
username = "YOURUSER"
password = "YOURPASSWORD"
context = "web_api"
}
resource "checkpoint_management_host" host1 {
name = "myhost1"
ipv4_address = "10.20.30.40"
color = "blue"
provisioner "local-exec" {
when = destroy
command = "publish"
}
}
resource "checkpoint_management_publish" pub1{
depends_on = [ checkpoint_management_host.host1 ]
triggers = [ timestamp() ]
}
You will also need to set environment variables CHECKPOINT_SERVER, CHECKPOINT_USERNAME and CHECKPOINT_PASSWORD for the publish command to connect to your management server.
The module above has a publish 'resource' with dependencies of the host. This makes sure that the publish action happens after the host is added and you'll need to add dependencies on policy elements if you want to have an embedded publish action like this.
For destroy actions - the local-exec provisioner within the host is called and executes the 'publish' binary which uses the session ID file in the Terraform module directory for the SID to publish.
That's a lot of words for something which is actually pretty simple and in testing, works well!