-
Notifications
You must be signed in to change notification settings - Fork 48
Allow specifying private end port & public end port for port forward rules #204
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
Conversation
eae02c6
to
9ab257d
Compare
a71ba2e
to
fc43f6c
Compare
fc43f6c
to
843a461
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for port range forwarding in CloudStack by introducing optional end port parameters for both private and public ports. Previously, the port forward resource only supported single port forwarding.
Key changes:
- Added
private_end_port
andpublic_end_port
as optional fields to enable port range forwarding - Updated the resource creation logic to set end ports when specified
- Modified the read operation to handle port ranges properly
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
website/docs/r/port_forward.html.markdown | Updated documentation to describe new optional end port fields and clarified existing port field descriptions |
cloudstack/resource_cloudstack_port_forward.go | Added schema definitions for end port fields and implemented logic to handle port ranges in create and read operations |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, tested manually
resource "cloudstack_port_forward" "head_node_ssh" {
ip_address_id = "20a23048-a6e8-4db9-a3c1-3966043838ff"
forward {
protocol = "tcp"
private_port = "22"
private_end_port = "24"
public_port = "22"
public_end_port = "24"
virtual_machine_id = "3d8b9cf8-44ed-4066-9e62-2f0b67560d0b"
}
}
terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# cloudstack_port_forward.head_node_ssh will be created
+ resource "cloudstack_port_forward" "head_node_ssh" {
+ id = (known after apply)
+ ip_address_id = "20a23048-a6e8-4db9-a3c1-3966043838ff"
+ managed = false
+ forward {
+ private_end_port = 24
+ private_port = 22
+ protocol = "tcp"
+ public_end_port = 24
+ public_port = 22
+ uuid = (known after apply)
+ virtual_machine_id = "3d8b9cf8-44ed-4066-9e62-2f0b67560d0b"
# (1 unchanged attribute hidden)
}
}
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
cloudstack_port_forward.head_node_ssh: Creating...
cloudstack_port_forward.head_node_ssh: Creation complete after 5s [id=20a23048-a6e8-4db9-a3c1-3966043838ff]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
╭─ ~/Desktop/cloudstack-India-demo/cloudstack-terraform copy ✔ ╱ 10s ╱ Azure subscription 1 ╱ 02:30:48 PM
╰─ terraform destroy
cloudstack_port_forward.head_node_ssh: Refreshing state... [id=20a23048-a6e8-4db9-a3c1-3966043838ff]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
- destroy
Terraform will perform the following actions:
# cloudstack_port_forward.head_node_ssh will be destroyed
- resource "cloudstack_port_forward" "head_node_ssh" {
- id = "20a23048-a6e8-4db9-a3c1-3966043838ff" -> null
- ip_address_id = "20a23048-a6e8-4db9-a3c1-3966043838ff" -> null
- managed = false -> null
- forward {
- private_end_port = 24 -> null
- private_port = 22 -> null
- protocol = "tcp" -> null
- public_end_port = 24 -> null
- public_port = 22 -> null
- uuid = "cc13cd3e-5283-405f-938c-e656290fc362" -> null
- virtual_machine_id = "3d8b9cf8-44ed-4066-9e62-2f0b67560d0b" -> null
# (1 unchanged attribute hidden)
}
}
Plan: 0 to add, 0 to change, 1 to destroy.
Do you really want to destroy all resources?
Terraform will destroy all your managed infrastructure, as shown above.
There is no undo. Only 'yes' will be accepted to confirm.
Enter a value: yes
cloudstack_port_forward.head_node_ssh: Destroying... [id=20a23048-a6e8-4db9-a3c1-3966043838ff]
cloudstack_port_forward.head_node_ssh: Destruction complete after 5s
Destroy complete! Resources: 1 destroyed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clgtm
Fixes #157