Skip to content

Commit 737af88

Browse files
committed
init/updateGCPTerraformModules: 1.2.0
Signed-off-by: FTNT-HQCM <hq-devops-admin@fortinet.com>
1 parent 635a91b commit 737af88

File tree

18 files changed

+239
-105
lines changed

18 files changed

+239
-105
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
## 1.2.0 (January 31, 2025)
2+
3+
IMPROVEMENTS:
4+
5+
* Module `fgt_single`:
6+
* Changed the default value `licensing->fortiflex_token` from 0 to "" (empty string).
7+
* Module `fgt_asg_with_function`:
8+
* Improved the primary FGT reselection logic in function script.
9+
* The deprecated parameter `cloud_function->print_debug_msg` has been removed, please use `cloud_function->logging_level`.
10+
* Added a new static route to the FGTs' configuration that routes data destined for `cloud_function.function_ip_range` to port `cloud_function.cloud_func_interface`.
11+
* Added new variable `autoscaler->scale_in_control_sec`. When the FortiGate group scales down, Google Cloud will delete at most one FGT every 'scale_in_control_sec' seconds.
12+
* Supported connecting with the Vault server to read secret data. Added 3 new internal variables `VAULT_SERVER`, `VAULT_ROLE`, and `VAULT_PATH` in the Cloud Function.
13+
* Added `count` to some resources related to the `fgt_password`. Some resources are moved, but the functions remain unchanged. E.g., `google_secret_manager_secret_iam_member.instance_password` has moved to `google_secret_manager_secret_iam_member.instance_password[0]`.
14+
* Added new variable `special_behavior` for customized functionality. Do not use it unless explicitly instructed by the developer.
15+
* Example `autoscale_fgt_lb_sandwich`:
16+
* Supported everything changed in Module `fgt_asg_with_function`.
17+
* By default, this example does not specify the FortiGate hostname. The new variable `fgt_hostname` can set the hostname of all FGTs in the autoscale group. If this variable is not specified, the hostname of the FGT will be its serial number.
18+
* Added a new static route to the FGTs' configuration that routes data destined for `cloud_function.function_ip_range` to port1.
19+
* Example `autoscale_fgt_as_hub`:
20+
* Supported everything changed in Module `fgt_asg_with_function`.
21+
* By default, this example does not specify the FortiGate hostname. The new variable `fgt_hostname` can set the hostname of all FGTs in the autoscale group. If this variable is not specified, the hostname of the FGT will be its serial number.
22+
* To use existing ILB, you can specify the ILB IP without creating a new ILB by specifying `network_interfaces->additional_variables->ilb_ip`. For example: `network_interfaces = [{network_name="example-network", subnet_name="example-subnet", additional_variables={ilb_ip="10.0.0.100"}}]`. This script will configure the FGT's interface to support ILB. You need to manually add the FGT instance group as the backend of the existing ILB in Google Cloud after the deployment of this example project.
23+
24+
125
## 1.1.0 (Nov 1, 2024)
226

327
FEATURES:

docs/autoscale_fgt_as_hub.md

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ If you want to deploy more than one examples, please make sure the `prefix` of t
7171
```
7272
fgt_password = "<YOUR-OWN-VALUE>" # Your own value (at least 8 characters), or this terraform project will create one for you. (Username is admin)
7373
machine_type = "n1-standard-4" # The Virtual Machine type to deploy FGT.
74+
# fgt_hostname = "example-hostname" # The hostname of all FGTs in the autoscale group. If not specified, the FGT's hostname will be its serial number.
7475
7576
# FortiGate image.
7677
# You can use "image_type" to deploy the latest public FortiGate image, or use "image_source" to deploy the custom image.
@@ -110,7 +111,7 @@ If `additional_disk` is specified, every FGT will have its own log disk, and the
110111
#### Network Variables:
111112
```
112113
network_interfaces = [
113-
# Port 1 of your FortiGate. This interface has one internal load balancer (ilb), and a route to the ilb.
114+
# Port 1 of your FortiGate. For this interface, this prject creates an internal load balancer (ILB) and a route to the ILB.
114115
{
115116
network_name = "user1-network" # Name of your network.
116117
subnet_name = "user1-subnet" # Name of your subnet.
@@ -120,23 +121,22 @@ network_interfaces = [
120121
# And all traffic to "ip_range_route_to_lb" will be routed to the internal load balancer (ilb) in this subnet.
121122
}
122123
},
123-
# Port 2 of your FortiGate. This interface has one internal load balancer (ilb), and a route to the ilb.
124+
# Port 2 of your FortiGate. For this interface, this prject creates an internal load balancer (ILB). (No route to the ILB).
124125
{
125126
network_name = "user2-network"
126127
subnet_name = "user2-subnet"
127-
internal_lb = {
128-
ip_range_route_to_lb = "10.0.0.0/8"
129-
}
128+
internal_lb = {}
130129
},
131-
# Port 3 of your FortiGate. This interface has one internal load balancer (ilb), and a route to the ilb.
130+
# Port 3 of your FortiGate. No ILB and route to ILB will be created. Using existing ILB instead.
131+
# You need to manually add the FGT instance group as the backend of the existing ILB in Google Cloud after the deployment of this example project.
132132
{
133133
network_name = "user3-network"
134134
subnet_name = "user3-subnet"
135-
internal_lb = {
136-
ip_range_route_to_lb = "10.0.0.0/8"
135+
additional_variables = {
136+
ilb_ip = "10.2.0.100"
137137
}
138138
},
139-
# Port 4 of your FortiGate. This interface doesn't specify "internal_lb", so no ilb and route to ilb will be created.
139+
# Port 4 of your FortiGate. This interface doesn't specify "internal_lb", so no ILB and route to ILB will be created.
140140
{
141141
network_name = "user4-network"
142142
subnet_name = "user4-subnet"
@@ -158,6 +158,8 @@ ha_sync_interface = "port4" # Please make sure you at least have
158158

159159
`network_interfaces[N].internal_lb.ip_range_route_to_lb` helps you to create a route. If it is specified, a route will be created in the subnet `subnet_name` . All traffic to `ip_range_route_to_lb` will be routed to the internal load balancer (ilb) in this subnet.
160160

161+
`network_interfaces[N].additional_variables.ilb_ip`. If you want to use an existing ILB, you can specify this variable without creating a new ILB. This variable will configure the FGT's interface to support ILB. **This variable does not connect the FGT instance group to your existing ILB. You need to manually add the FGT instance group as the backend of the existing ILB in Google Cloud after the deployment of this example project.**
162+
161163
`network_tags` is a list of network tags attached to FortiGates. GCP firewall rules have "target tags", and these firewall rules only apply to instances with the same tag. You can specify the tags here.
162164

163165
`ha_sync_interface` is the port used to sync data between FortiGates. Example values: "port1", "port2", "port3"... If you specified 8 interfaces in `network_interfaces`, then the first interface is "port1", the second one is "port2", the last one is "port8".
@@ -167,8 +169,8 @@ ha_sync_interface = "port4" # Please make sure you at least have
167169
cloud_function = {
168170
cloud_func_interface = "port1" # To communicate with FGTs, the Cloud Function must be connected to the VPC where FGTs also exist.
169171
# By default, this project assumes the Cloud Function connects to the first VPC you specified in "network_interfaces", and configure your FGTs through port1.
170-
# You can also set it to "port2", "port3", ..., "port8" to force the Cloud Function to connect to other VPC and communicate with your FortiGates through that port.
171-
# But you need to specify the corresponding route of FGTs in "config_script" or "config_file" so FGTs can reply to the Cloud Function requests from "cloud_function.function_ip_range".
172+
# You can also set it to "port2", "port3", ..., "port8" to force the Cloud Function to connect to other VPC and communicate with your FortiGates through that port,
173+
# but you need to specify the corresponding route of FGTs in "config_script" or "config_file" so FGTs can reply to the Cloud Function requests from "cloud_function.function_ip_range".
172174
function_ip_range = "192.168.8.0/28" # Cloud function needs to have its own CIDR ip range ending with "/28", which cannot be used by other resources.
173175
license_source = "file" # The source of license if your image_type is "fortigate-xx-byol".
174176
# Possible value: "none", "fortiflex", "file", "file_fortiflex"
@@ -201,7 +203,26 @@ cloud_function = {
201203
Cloud function is used to manage FGT synchronization and inject license into FGT.
202204

203205
`cloud_func_interface` is the interface of the FortiGates communicate with the Cloud Function. The default value is "port1".
204-
By default, this project assumes the Cloud Function connects to the first VPC you specified in `network_interfaces`, and configure your FGTs through "port1". You can also set it to "port2", "port3", ..., "port8" to force the Cloud Function to connect to other VPC and communicate with your FortiGates through that port. If this value is not "port1", you need to specify the corresponding route of FGTs in "config_script" or "config_file" so FGTs can reply to the Cloud Function requests from "cloud_function.function_ip_range".
206+
By default, this project assumes the Cloud Function connects to the first VPC you specified in `network_interfaces`, and configure your FGTs through "port1". You can also set it to "port2", "port3", ..., "port8" to force the Cloud Function to connect to other VPC and communicate with your FortiGates through that port.
207+
If you set `cloud_func_interface = portX` and "portX" is not the default value "port1", you need to specify
208+
```
209+
config_script = <<EOF
210+
# Using following scripts to let FortiGates respond Cloud Function
211+
# "set allowaccess https" is required for interface <portX>.
212+
config system interface
213+
edit <portX>
214+
set allowaccess ping https ssh fgfm probe-response
215+
next
216+
end
217+
config router static
218+
edit 0
219+
set dst <vault of cloud_function.function_ip_range>
220+
set device <portX>
221+
set gateway <gateway of portX>
222+
next
223+
end
224+
EOF
225+
```
205226

206227
`function_ip_range` is used by cloud function. This IP range needs to end with "/28" and cannot be used by any other resources.
207228

@@ -224,8 +245,8 @@ You also need to provide a FortiGate configuration `config` (A digital number).
224245

225246
`additional_variables` specifies additional variables used by Cloud Function. Some variables are too trivial or **not recommended to be changed**. You can specify them here to overwrite the behavior of the Cloud Function for more customization.
226247

227-
- "HA_SYNC_INTERFACE": (default: "port2") The port used for HA synchronization.
228-
- "CLOUD_FUNC_INTERFACE": (default: "port1") Cloud function uses this port to communicate with FortiGates. If CLOUD_FUNC_INTERFACE is not "port1", please also add corresponding route rules in `config_script` (or `config_file`) so FortiGate can respond to the Cloud Function requests.
248+
To get advice on how to specify `additional_variables` to suit your custom needs, please create an GitHub issue at https://github.com/fortinetdev/terraform-google-cloud-modules
249+
229250
- "FIRESTORE_DATABASE": (default: "(default)") The Firestore database that Cloud Function used to store data.
230251

231252
```
@@ -234,8 +255,6 @@ cloud_function = {
234255
235256
# Only set additional_variables when needed.
236257
additional_variables = {
237-
# HA_SYNC_INTERFACE = "port2"
238-
# CLOUD_FUNC_INTERFACE = "port1"
239258
# FIRESTORE_DATABASE = "YOUR-EXISTING-DATABASE-NAME" # Default value is "(default)"
240259
}
241260
}
@@ -254,6 +273,7 @@ autoscaler = {
254273
# check_interval_sec = 30 # How often (in seconds) to send a health check.
255274
# unhealthy_threshold = 10 # A so-far healthy instance will be marked unhealthy after this many consecutive failures.
256275
}
276+
scale_in_control_sec = 300 # When the group scales down, Google Cloud will delete at most one FGT every 'scale_in_control_sec' seconds.
257277
}
258278
```
259279
Autoscaler is used to control when to autoscale and control the number of FortiGate instances.
@@ -268,6 +288,8 @@ Autoscaler is used to control when to autoscale and control the number of FortiG
268288

269289
`autohealing.health_check_port` is the port used for health checks by autohealing and health checks by load balancers.
270290

291+
`scale_in_control_sec` can prevent the aggressive scale down. If `scale_in_control_sec` is not 0, when the group scales down, Google Cloud will delete at most one FGT every 'scale_in_control_sec' seconds. By default, its value is 300.
292+
271293
#### Additional FGT configuration script.
272294

273295
**NOTE: After deploying this terraform project, changing the variable `config_script` (and contents in `config_file`) will not change the FortiGate configuration.**

docs/autoscale_fgt_lb_sandwich.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ If you want to deploy more than one examples, please make sure the `prefix` of t
7070
fgt_password = "<YOUR-OWN-VALUE>" # Your own value (at least 8 characters), or this terraform project will create one for you. (Username is admin)
7171
machine_type = "n1-standard-4" # The Virtual Machine type to deploy FGT.
7272
fgt_has_public_ip = false # If set to true, port1 of all FGTs will have a public IP.
73+
# fgt_hostname = "example-hostname" # The hostname of all FGTs in the autoscale group. If not specified, the FGT's hostname will be its serial number.
7374
7475
# FortiGate image.
7576
# You can use "image_type" to deploy the latest public FortiGate image, or use "image_source" to deploy the custom image.
@@ -177,6 +178,7 @@ cloud_function = {
177178
Cloud function is used to manage FGT synchronization and inject license into FGT.
178179

179180
`function_ip_range` is used by cloud function. This IP range needs to end with "/28" and cannot be used by any other resources.
181+
A static route will be created in the FGT that routes data destined for `cloud_function.function_ip_range` to port1.
180182

181183
`license_source` is the source of your license. If your `image_type` ends with "byol" (bring your own license), you need to specify your license source here. Possible values are
182184
- "none": Don't inject licenses to FGTs.
@@ -187,7 +189,7 @@ Cloud function is used to manage FGT synchronization and inject license into FGT
187189
`autoscale_psksecret` is the secret key used to synchronize information between FortiGates. If not set, this project will randomly generate a 16-character secret key. You can find it in the output.
188190

189191
`logging_level` is used to control the verbosity of logs. Possible values include "NONE", "ERROR", "WARN", "INFO", "DEBUG", and "TRACE". Logs can be viewed in the Google Cloud Logs Explorer. If you set logging_level to "INFO", all logs of "INFO" severity or higher ("INFO", "WARN", "ERROR") will be recorded.
190-
(The previous variable `"print_debug_msg"` has been deprecated, and will be removed in the future.)
192+
(The previous variable `"print_debug_msg"` has been deprecated and removed.)
191193

192194
`fortiflex` is required if your `license_source` is "fortiflex".
193195
The cloud function will retrieve your existing unused FortiFlex entitlements and use them to inject licenses into FortiGates.
@@ -198,6 +200,8 @@ You also need to provide a FortiGate configuration `config` (A digital number).
198200

199201
`additional_variables` specifies additional variables used by Cloud Function. Some variables are too trivial or **not recommended to be changed**. You can specify them here to overwrite the behavior of the Cloud Function for more customization.
200202

203+
To get advice on how to specify `additional_variables` to suit your custom needs, please create an GitHub issue at https://github.com/fortinetdev/terraform-google-cloud-modules
204+
201205
- "HA_SYNC_INTERFACE": (default: "port2") The port used for HA synchronization.
202206
- "CLOUD_FUNC_INTERFACE": (default: "port1") Cloud function uses this port to communicate with FortiGates. If CLOUD_FUNC_INTERFACE is not "port1", please also add corresponding route rules in `config_script` (or `config_file`) so FortiGate can respond to the Cloud Function requests.
203207
- "FIRESTORE_DATABASE": (default: "(default)") The Firestore database that Cloud Function used to store data.
@@ -229,6 +233,7 @@ autoscaler = {
229233
# check_interval_sec = 30 # How often (in seconds) to send a health check.
230234
# unhealthy_threshold = 10 # A so-far healthy instance will be marked unhealthy after this many consecutive failures.
231235
}
236+
scale_in_control_sec = 300 # When the group scales down, Google Cloud will delete at most one FGT every 'scale_in_control_sec' seconds.
232237
}
233238
```
234239
Autoscaler is used to control when to autoscale and control the number of FortiGate instances.
@@ -241,8 +246,9 @@ Autoscaler is used to control when to autoscale and control the number of FortiG
241246

242247
`cpu_utilization` is the autoscaling signal. If CPU utilization is above this value, Google Cloud will create new FGT instances. Google Cloud will also delete idle FGT instances if CPU utilization is low for a long time.
243248

244-
`autohealing.health_check_port` is the port used for health checks by autohealing. Autohealing recreates VM instances if your application cannot be reached by the health check. Set it to 0 to disable autohealing. `load_balancer.health_check_port` is used for the load balancer and it can't be disabled. Normally, `autoscaler.autohealing.health_check_port` and `load_balancer.health_check_port` should have the same port number, and its default is 8008 for FortiGates.
249+
`autohealing.health_check_port` is the port used for health checks by autohealing. Autohealing recreates VM instances if your application cannot be reached by the health check. Set it to 0 to disable autohealing. `load_balancer.health_check_port` is used for the load balancer and it can't be disabled. Normally, `autoscaler.autohealing.health_check_port` and `load_balancer.health_check_port` should have the same port number, and its default is 8008 for FortiGates.
245250

251+
`scale_in_control_sec` can prevent the aggressive scale down. If `scale_in_control_sec` is not 0, when the group scales down, Google Cloud will delete at most one FGT every 'scale_in_control_sec' seconds. By default, its value is 300.
246252

247253
#### Additional FGT configuration script.
248254

0 commit comments

Comments
 (0)