Skip to content

Commit 9b321b3

Browse files
chkp-eddiekchkp-avivmchkp-guybarakchkp-eviatarschkp-yizhako
authored
AWS GWLB add ipv6 support (#9)
* Add new file * Update README.md * README Update * Adding modules for AWS Check Point deployments * Updated user data values * VSECPC-9954 | Adding .gitatributes file * Edit README.md * AWS GWLB add ipv6 support --------- Co-authored-by: avivm <avivm@checkpoint.com> Co-authored-by: guybarak <guybarak@checkpoint.com> Co-authored-by: eviatars <eviatars@checkpoint.com> Co-authored-by: yizhako <yizhako@checkpoint.com>
1 parent 46c6b84 commit 9b321b3

File tree

19 files changed

+167
-79
lines changed

19 files changed

+167
-79
lines changed

modules/autoscale_gwlb/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ module "example_module" {
6666
allow_upload_download = true
6767
enable_cloudwatch = false
6868
gateway_bootstrap_script = "echo 'this is bootstrap script' > /home/admin/bootstrap.txt"
69+
enable_ipv6 = false
6970
}
7071
```
7172

72-
7373
## Inputs
7474

7575
| Name | Description | Type | Allowed Values |
@@ -103,7 +103,7 @@ module "example_module" {
103103
| volume_type | General Purpose SSD Volume Type | string | - gp3<br>- gp2<br>**Default:** gp3 |
104104
| gateway_maintenance_mode_password_hash | (Optional) Maintenance-mode password for recovery purposes. | string | |
105105
security_rules | List of security rules for ingress and egress. | list(object({<br/> direction = string <br/>from_port = any <br/>to_port = any <br/>protocol = any <br/>cidr_blocks = list(any)<br/>})) | **Default:** []|
106-
106+
| enable_ipv6 | Enables dual-stack networking (IPv4 and IPv6) for the GWLB, [Please see version compatibility in the following guide](https://sc1.checkpoint.com/documents/IaaS/WebAdminGuides/EN/CP_CloudGuard_Network_for_AWS_Gateway_Load_Balancer_ASG/Content/Topics-AWS-GWLB-ASG-DG/IPv6-Support.htm) | bool | true/false<br>**Default:** false
107107

108108

109109
## Outputs
@@ -115,6 +115,7 @@ output "instance_public_ip" {
115115
```
116116
| Name | Description |
117117
|------------------------------------------------|-------------------------------------------------------------------|
118+
| 20250508 |Added support for IPv6 traffic settings | |
118119
| autoscale_autoscaling_group_name | The name of the deployed AutoScaling Group |
119120
| autoscale_autoscaling_group_arn | The ARN for the deployed AutoScaling Group |
120121
| autoscale_autoscaling_group_availability_zones | The AZs on which the Autoscaling Group is configured |
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#cloud-config
2+
network:
3+
version: 1
4+
config:
5+
- type: bridge
6+
name: br0
7+
mtu: *eth0-mtu
8+
subnets:
9+
- address: *eth0-private
10+
type: static
11+
gateway: *default-gateway
12+
dns_nameservers:
13+
- *eth0-dns1
14+
bridge_interfaces:
15+
- eth0
16+
kernel_parameters:
17+
sim:
18+
- sim_geneve_enabled=1
19+
- sim_geneve_br_dev=br0
20+
fw:
21+
22+
- fwtls_bridge_mode_inspection=1
23+
- fw_geneve_enabled=1
24+
bootcmd:
25+
- echo "brctl hairpin br0 eth0 on" >> /etc/rc.local
26+
- echo "cpprod_util CPPROD_SetValue \"fw1\" \"AwsGwlb\" 4 1 1" >> /etc/rc.local
27+
- cp /etc/basedb /etc/basedb.bak
28+
- grep -vx "ipv6 t" /etc/basedb.bak | grep -vx "ipv6 f" > /etc/basedb;
29+
- echo "ipv6 t" >> /etc/basedb
30+
- /etc/rc3.d/S07ipv6gen
31+
runcmd:
32+
- |
33+
python3 /etc/cloud_config.py enableCloudWatch=\"${EnableCloudWatch}\" sicKey=\"${SICKey}\" installationType=\"autoscale\" osVersion=\"${OsVersion}\" allowUploadDownload=\"${AllowUploadDownload}\" templateVersion=\"20231012\" templateName=\"autoscale_gwlb\" templateType=\"terraform\" shell=\"${Shell}\" enableInstanceConnect=\"${EnableInstanceConnect}\" passwordHash=\"${PasswordHash}\" MaintenanceModePassword=\"${MaintenanceModePassword}\" bootstrapScript64=\"${BootstrapScript}\"

modules/autoscale_gwlb/main.tf

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,43 @@ resource "aws_security_group" "permissive_sg" {
1010
name_prefix = format("%s_PermissiveSecurityGroup", local.asg_name)
1111
description = "Permissive security group"
1212
vpc_id = var.vpc_id
13-
14-
dynamic "ingress" {
15-
for_each = [for rule in var.security_rules : rule if rule.direction == "ingress"]
16-
content {
17-
from_port = ingress.value.from_port
18-
to_port = ingress.value.to_port
19-
protocol = ingress.value.protocol
20-
cidr_blocks = ingress.value.cidr_blocks
13+
tags = {
14+
Name = format("%s_PermissiveSecurityGroup", local.asg_name)
2115
}
2216
}
2317

24-
dynamic ingress {
25-
for_each = length([for rule in var.security_rules : rule if rule.direction == "ingress"]) == 0 ? [1] : []
26-
content{
18+
resource "aws_vpc_security_group_ingress_rule" "ingress_rule_ipv4" {
19+
security_group_id = aws_security_group.permissive_sg.id
20+
cidr_ipv4 = "0.0.0.0/0"
2721
from_port = 0
22+
ip_protocol = "-1"
2823
to_port = 0
29-
protocol = "-1"
30-
cidr_blocks = ["0.0.0.0/0"]
3124
}
32-
}
3325

34-
dynamic "egress" {
35-
for_each = [for rule in var.security_rules : rule if rule.direction == "egress"]
36-
content {
37-
from_port = egress.value.from_port
38-
to_port = egress.value.to_port
39-
protocol = egress.value.protocol
40-
cidr_blocks = egress.value.cidr_blocks
41-
}
26+
resource "aws_vpc_security_group_egress_rule" "egress_rule_ipv4" {
27+
security_group_id = aws_security_group.permissive_sg.id
28+
cidr_ipv4 = "0.0.0.0/0"
29+
from_port = 0
30+
ip_protocol = "-1"
31+
to_port = 0
32+
}
33+
34+
resource "aws_vpc_security_group_ingress_rule" "ingress_rule_ipv6" {
35+
count = var.enable_ipv6 ? 1 : 0
36+
security_group_id = aws_security_group.permissive_sg.id
37+
cidr_ipv6 = "::/0"
38+
from_port = 0
39+
ip_protocol = "-1"
40+
to_port = 0
4241
}
4342

44-
dynamic egress {
45-
for_each = length([for rule in var.security_rules : rule if rule.direction == "egress"]) == 0 ? [1] : []
46-
content{
43+
resource "aws_vpc_security_group_egress_rule" "egress_rule_ipv6" {
44+
count = var.enable_ipv6 ? 1 : 0
45+
security_group_id = aws_security_group.permissive_sg.id
46+
cidr_ipv6 = "::/0"
4747
from_port = 0
48+
ip_protocol = "-1"
4849
to_port = 0
49-
protocol = "-1"
50-
cidr_blocks = ["0.0.0.0/0"]
51-
}
52-
}
53-
tags = {
54-
Name = format("%s_PermissiveSecurityGroup", local.asg_name)
55-
}
5650
}
5751

5852
resource "aws_launch_template" "asg_launch_template" {
@@ -87,7 +81,7 @@ resource "aws_launch_template" "asg_launch_template" {
8781

8882
description = "Initial template version"
8983

90-
user_data = base64encode(templatefile("${path.module}/asg_userdata.yaml", {
84+
user_data = base64encode(templatefile("${path.module}/${var.enable_ipv6 ? "asg_userdata_ipv6.yaml" : "asg_userdata.yaml"}", {
9185
// script's arguments
9286
PasswordHash = local.gateway_password_hash_base64,
9387
MaintenanceModePassword = local.maintenance_mode_password_hash_base64,
@@ -98,6 +92,7 @@ resource "aws_launch_template" "asg_launch_template" {
9892
AllowUploadDownload = var.allow_upload_download,
9993
BootstrapScript = local.gateway_bootstrap_script64,
10094
OsVersion = local.version_split
95+
enable_ipv6 = var.enable_ipv6
10196
}))
10297
}
10398
resource "aws_autoscaling_group" "asg" {

modules/autoscale_gwlb/output.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ output "autoscale_iam_role_name" {
3939
value = aws_iam_role.role.*.name
4040
}
4141

42+
output "enable_ipv6"{
43+
value = var.enable_ipv6
44+
}

modules/autoscale_gwlb/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,9 @@ variable "security_rules" {
190190
cidr_blocks = list(string)
191191
}))
192192
default = []
193+
}
194+
variable "enable_ipv6" {
195+
type = bool
196+
description = "Enable IPv6 settings of AWS resources."
197+
default = false
193198
}

modules/gwlb/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ module "example_module" {
137137
| volume_type | General Purpose SSD Volume Type | string | - gp3<br>- gp2<br>**Default:** gp3 |
138138
| gateway_maintenance_mode_password_hash | Check Point recommends setting Admin user's password and maintenance-mode password for recovery purposes. For R81.10 and below the Admin user's password is used also as maintenance-mode password. (To generate a password hash use the command "grub2-mkpasswd-pbkdf2" on Linux and paste it here). | string | |
139139
| management_maintenance_mode_password_hash | Check Point recommends setting Admin user's password and maintenance-mode password for recovery purposes. For R81.10 and below the Admin user's password is used also as maintenance-mode password. (To generate a password hash use the command "grub2-mkpasswd-pbkdf2" on Linux and paste it here). | string | |
140+
| enable_ipv6 | Enables dual-stack networking (IPv4 and IPv6) for the GWLB, [Please see version compatibility in the following guide](https://sc1.checkpoint.com/documents/IaaS/WebAdminGuides/EN/CP_CloudGuard_Network_for_AWS_Gateway_Load_Balancer_ASG/Content/Topics-AWS-GWLB-ASG-DG/IPv6-Support.htm) | bool | true/false<br>**Default:** false |
140141

141142
## Outputs
142143
To display the outputs defined by the module, create an `outputs.tf` file with the following structure:
@@ -154,5 +155,5 @@ output "instance_public_ip" {
154155
| gwlb_name | The name of the deployed Gateway Load Balancer |
155156
| gwlb_service_name | The service name for the deployed Gateway Load Balancer |
156157
| gwlb_arn | The arn for the deployed Gateway Load Balancer |
157-
158+
| enable_ipv6 | Dual-stack IPv4/IPv6 compatible |
158159

modules/gwlb/main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ module "gateway_load_balancer" {
1818
target_group_port = 6081
1919
listener_port = 6081
2020
cross_zone_load_balancing = var.enable_cross_zone_load_balancing
21+
enable_ipv6 = var.enable_ipv6
2122
}
2223

2324
resource "aws_vpc_endpoint_service" "gwlb_endpoint_service" {
2425
depends_on = [module.gateway_load_balancer]
2526
gateway_load_balancer_arns = module.gateway_load_balancer[*].load_balancer_arn
2627
acceptance_required = var.connection_acceptance_required
27-
28+
supported_ip_address_types = var.enable_ipv6 ? ["ipv4", "ipv6"] : ["ipv4"]
2829
tags = {
2930
"Name" = "gwlb-endpoint-service-${var.gateway_load_balancer_name}"
3031
}
@@ -58,6 +59,7 @@ module "autoscale_gwlb" {
5859
management_server = var.management_server
5960
configuration_template = var.configuration_template
6061
volume_type = var.volume_type
62+
enable_ipv6 = var.enable_ipv6
6163
}
6264

6365
data "aws_region" "current"{}

modules/gwlb/output.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ output "controller_name" {
1919
}
2020
output "template_name" {
2121
value = var.configuration_template
22+
}
23+
output "enable_ipv6"{
24+
value = var.enable_ipv6
2225
}

modules/gwlb/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,4 +243,9 @@ variable "volume_type" {
243243
type = string
244244
description = "General Purpose SSD Volume Type"
245245
default = "gp3"
246+
}
247+
variable "enable_ipv6" {
248+
type = bool
249+
description = "Enable IPv6 settings of AWS resources."
250+
default = false
246251
}

0 commit comments

Comments
 (0)