Skip to content

Commit cffd5e1

Browse files
authored
Update firewall destroy behavior (#330)
### WHY are these changes introduced? Previously when destroying the firewall resource, the servers was updated with a default rule keeping the firewall open. This causes issues for LavinMQ that only support a subset of the pre-defined services. Close: #328 ### WHAT is this pull request doing? - Updates the servers firewall with no rules, firewall gets closed, when destroying this resource. - Updates documentation
1 parent 5beceb0 commit cffd5e1

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

api/security_firewall.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,10 @@ func (api *API) deleteFirewallSettingsWithRetry(ctx context.Context, path string
194194
timeout int) (int, error) {
195195

196196
var (
197-
params [1]map[string]any
197+
params = []map[string]any{}
198198
failed map[string]any
199199
)
200200

201-
// Use default firewall rule and update firewall upon delete.
202-
params[0] = DefaultFirewallSettings()
203201
response, err := api.sling.New().Put(path).BodyJSON(params).Receive(nil, &failed)
204202
if err != nil {
205203
return attempt, err
@@ -229,14 +227,3 @@ func (api *API) deleteFirewallSettingsWithRetry(ctx context.Context, path string
229227
return attempt, fmt.Errorf("failed to reset firewall, status=%d message=%s ",
230228
response.StatusCode, failed)
231229
}
232-
233-
func DefaultFirewallSettings() map[string]any {
234-
defaultRule := map[string]any{
235-
"services": []string{"AMQP", "AMQPS", "STOMP", "STOMPS", "MQTT", "MQTTS", "HTTPS", "STREAM",
236-
"STREAM_SSL"},
237-
"ports": []int{},
238-
"ip": "0.0.0.0/0",
239-
"description": "Default",
240-
}
241-
return defaultRule
242-
}

docs/resources/security_firewall.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ This resource allows you to configure and manage firewall rules for the CloudAMQ
1212
~> **WARNING:** Firewall rules applied with this resource will replace any existing firewall rules.
1313
Make sure all wanted rules are present to not lose them.
1414

15+
-> **NOTE:** From [v1.33.0] when destroying this resource the firewall on the servers will also be
16+
removed. I.e. the firewall will be completely closed.
17+
1518
Only available for dedicated subscription plans.
1619

1720
## Example Usage
1821

1922
```hcl
20-
resource "cloudamqp_security_firewall" "firewall_settings" {
23+
resource "cloudamqp_security_firewall" "this" {
2124
instance_id = cloudamqp_instance.instance.id
2225
2326
rules {
@@ -66,7 +69,7 @@ resource "cloudamqp_instance" "instance" {
6669
tags = ["terraform"]
6770
}
6871
69-
resource "cloudamqp_security_firewall" "firewall_settings" {
72+
resource "cloudamqp_security_firewall" "this" {
7073
instance_id = cloudamqp_instance.instance.id
7174
7275
rules {
@@ -162,6 +165,22 @@ Or use Terraform CLI:
162165

163166
`terraform import cloudamqp_security_firewall.firewall <instance_id>`
164167

168+
## Destroy the resource
169+
170+
From [v1.33.0] when destroying this resource the firewall on the servers will be removed. I.e. the
171+
firewall will be completly closed.
172+
173+
Older version will instead update the firewall with a default rule.
174+
175+
```hcl
176+
rules {
177+
ip = "0.0.0.0/0"
178+
ports = []
179+
services = ["AMQP", "AMQPS", "STOMP", "STOMPS", "MQTT", "MQTTS", "HTTPS", "STREAM", "STREAM_SSL"]
180+
description = "Default"
181+
}
182+
```
183+
165184
## Enable faster instance destroy
166185

167186
When running `terraform destroy` this resource will try configure the firewall with default rules
@@ -226,4 +245,5 @@ The provider from [v1.15.2] will start to warn about using this.
226245
[v1.15.1]: https://github.com/cloudamqp/terraform-provider-cloudamqp/releases/tag/v1.15.1
227246
[v1.15.2]: https://github.com/cloudamqp/terraform-provider-cloudamqp/releases/tag/v1.15.2
228247
[v1.27.0]: https://github.com/cloudamqp/terraform-provider-cloudamqp/releases/tag/v1.27.0
248+
[v1.33.0]: https://github.com/cloudamqp/terraform-provider-cloudamqp/releases/tag/v1.33.0
229249
[VPC GPC peering]: ./vpc_gcp_peering#create-vpc-peering-with-additional-firewall-rules

0 commit comments

Comments
 (0)