Skip to content

Commit

Permalink
Merge pull request #1322 from GoogleCloudPlatform/jccb/fw-tests
Browse files Browse the repository at this point in the history
Add inventories to net-vpc-firewall tests
  • Loading branch information
juliocc authored Apr 12, 2023
2 parents a504738 + eca0a95 commit 23302b1
Show file tree
Hide file tree
Showing 17 changed files with 410 additions and 320 deletions.
14 changes: 7 additions & 7 deletions modules/net-vpc-firewall/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module "firewall" {
admin_ranges = ["10.0.0.0/8"]
}
}
# tftest modules=1 resources=4
# tftest modules=1 resources=4 inventory=basic.yaml
```

### Custom rules
Expand Down Expand Up @@ -77,7 +77,7 @@ module "firewall" {
}
}
}
# tftest modules=1 resources=9
# tftest modules=1 resources=9 inventory=custom-rules.yaml
```

### Controlling or turning off default rules
Expand All @@ -103,7 +103,7 @@ module "firewall" {
ssh_tags = ["ssh-default"]
}
}
# tftest modules=1 resources=3
# tftest modules=1 resources=3 inventory=custom-ssh-default-rule.yaml
```

#### Disabling predefined rules
Expand All @@ -119,7 +119,7 @@ module "firewall" {
ssh_ranges = []
}
}
# tftest modules=1 resources=2
# tftest modules=1 resources=2 inventory=no-ssh-default-rules.yaml
```

Or the entire set of rules can be disabled via the `disabled` attribute:
Expand All @@ -133,7 +133,7 @@ module "firewall" {
disabled = true
}
}
# tftest modules=0 resources=0
# tftest modules=0 resources=0 inventory=no-default-rules.yaml
```

### Including source & destination ranges
Expand Down Expand Up @@ -163,7 +163,7 @@ module "firewall" {
}
}
}
# tftest modules=1 resources=2
# tftest modules=1 resources=2 inventory=local-ranges.yaml
```

### Rules Factory
Expand All @@ -181,7 +181,7 @@ module "firewall" {
}
default_rules_config = { disabled = true }
}
# tftest modules=1 resources=3 files=lbs,cidrs
# tftest modules=1 resources=3 files=lbs,cidrs inventory=factory.yaml
```

```yaml
Expand Down
4 changes: 0 additions & 4 deletions tests/modules/net_vpc_firewall/auto-rules.tfvars

This file was deleted.

44 changes: 0 additions & 44 deletions tests/modules/net_vpc_firewall/auto-rules.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions tests/modules/net_vpc_firewall/common.tfvars

This file was deleted.

33 changes: 0 additions & 33 deletions tests/modules/net_vpc_firewall/custom-rules.tfvars

This file was deleted.

83 changes: 0 additions & 83 deletions tests/modules/net_vpc_firewall/custom-rules.yaml

This file was deleted.

25 changes: 0 additions & 25 deletions tests/modules/net_vpc_firewall/data/firewall/load_balancers.yaml

This file was deleted.

98 changes: 98 additions & 0 deletions tests/modules/net_vpc_firewall/examples/basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

values:
module.firewall.google_compute_firewall.allow-admins[0]:
allow:
- ports: []
protocol: all
deny: []
disabled: null
log_config: []
name: my-network-ingress-admins
network: my-network
priority: 1000
project: my-project
source_ranges:
- 10.0.0.0/8
source_service_accounts: null
source_tags: null
target_service_accounts: null
target_tags: null
module.firewall.google_compute_firewall.allow-tag-http[0]:
allow:
- ports:
- '80'
protocol: tcp
deny: []
disabled: null
log_config: []
name: my-network-ingress-tag-http
network: my-network
priority: 1000
project: my-project
source_ranges:
- 130.211.0.0/22
- 209.85.152.0/22
- 209.85.204.0/22
- 35.191.0.0/16
source_service_accounts: null
source_tags: null
target_service_accounts: null
target_tags:
- http-server
module.firewall.google_compute_firewall.allow-tag-https[0]:
allow:
- ports:
- '443'
protocol: tcp
deny: []
disabled: null
log_config: []
name: my-network-ingress-tag-https
network: my-network
priority: 1000
project: my-project
source_ranges:
- 130.211.0.0/22
- 209.85.152.0/22
- 209.85.204.0/22
- 35.191.0.0/16
source_service_accounts: null
source_tags: null
target_service_accounts: null
target_tags:
- https-server
module.firewall.google_compute_firewall.allow-tag-ssh[0]:
allow:
- ports:
- '22'
protocol: tcp
deny: []
disabled: null
log_config: []
name: my-network-ingress-tag-ssh
network: my-network
priority: 1000
project: my-project
source_ranges:
- 35.235.240.0/20
source_service_accounts: null
source_tags: null
target_service_accounts: null
target_tags:
- ssh

counts:
google_compute_firewall: 4
Loading

0 comments on commit 23302b1

Please sign in to comment.