-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add GCP firewall table. Closes #42 * Add docs for GCP compute firewall Co-authored-by: rajeshbal65 <[email protected]>
- Loading branch information
1 parent
2a6fc5e
commit b281950
Showing
18 changed files
with
443 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Table: gcp_compute_firewall | ||
|
||
VPC firewall rules allows or denies connections to or from your virtual machine (VM) instances based on a specified configuration. Enabled VPC firewall rules are always enforced, protecting instances regardless of their configuration and operating system, even if they have not started up. | ||
|
||
### Firewall rules basic info | ||
|
||
```sql | ||
select | ||
name, | ||
id, | ||
description, | ||
direction | ||
from | ||
gcp_compute_firewall; | ||
``` | ||
|
||
|
||
### List of rules which are applied to TCP protocol | ||
|
||
```sql | ||
select | ||
name, | ||
id, | ||
p ->> 'IPProtocol' as ip_protocol, | ||
p ->> 'ports' as ports | ||
from | ||
gcp_compute_firewall, | ||
jsonb_array_elements(allowed) as p | ||
where | ||
p ->> 'IPProtocol' = 'tcp'; | ||
``` | ||
|
||
|
||
### List of disabled rules | ||
|
||
```sql | ||
select | ||
name, | ||
id, | ||
description, | ||
disabled | ||
from | ||
gcp_compute_firewall | ||
where | ||
disabled | ||
``` | ||
|
||
|
||
### List of Egress rules | ||
|
||
```sql | ||
select | ||
name, | ||
id, | ||
direction, | ||
allowed, | ||
denied | ||
from | ||
gcp_compute_firewall | ||
where | ||
direction = 'EGRESS'; | ||
``` |
Empty file.
30 changes: 30 additions & 0 deletions
30
gcp-test/tests/gcp_compute_firewall/test-get-expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[ | ||
{ | ||
"action": "Allow", | ||
"allowed": [ | ||
{ | ||
"IPProtocol": "icmp" | ||
}, | ||
{ | ||
"IPProtocol":"tcp", | ||
"ports":[ | ||
"80", | ||
"8080", | ||
"1000-2000" | ||
] | ||
} | ||
], | ||
"description": "Test firewall rule to verify the table.", | ||
"direction": "INGRESS", | ||
"disabled": false, | ||
"kind": "compute#firewall", | ||
"log_config_enable": false, | ||
"name": "{{ resourceName }}", | ||
"network": "{{ output.network.value }}", | ||
"project": "{{ output.project_id.value }}", | ||
"self_link": "{{ output.self_link.value }}", | ||
"source_tags": [ | ||
"web" | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
select name, direction, description, kind, disabled, self_link, action, project, network, log_config_enable, allowed, source_tags | ||
from gcp.gcp_compute_firewall | ||
where name = '{{ resourceName }}' |
10 changes: 10 additions & 0 deletions
10
gcp-test/tests/gcp_compute_firewall/test-hydrate-expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[ | ||
{ | ||
"action": "Allow", | ||
"description": "Test firewall rule to verify the table.", | ||
"direction": "INGRESS", | ||
"kind": "compute#firewall", | ||
"name": "{{ resourceName }}", | ||
"self_link": "{{ output.self_link.value }}" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
select name, direction, description, kind, action, self_link | ||
from gcp.gcp_compute_firewall | ||
where name = '{{ resourceName }}' |
1 change: 1 addition & 0 deletions
1
gcp-test/tests/gcp_compute_firewall/test-invalid-name-expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
null |
3 changes: 3 additions & 0 deletions
3
gcp-test/tests/gcp_compute_firewall/test-invalid-name-query.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
select name, id, description | ||
from gcp.gcp_compute_firewall | ||
where name = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
{ | ||
"description": "Test firewall rule to verify the table.", | ||
"name": "{{ resourceName }}" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
select name, description | ||
from gcp.gcp_compute_firewall | ||
where title = '{{ resourceName }}' |
1 change: 1 addition & 0 deletions
1
gcp-test/tests/gcp_compute_firewall/test-not-found-expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
select name, id, direction, kind | ||
from gcp.gcp_compute_firewall | ||
where name = 'dummy-{{ resourceName }}' |
8 changes: 8 additions & 0 deletions
8
gcp-test/tests/gcp_compute_firewall/test-turbot-expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[ | ||
{ | ||
"akas": [ | ||
"{{ output.resource_aka.value }}" | ||
], | ||
"title": "{{ resourceName }}" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
select title, akas | ||
from gcp.gcp_compute_firewall | ||
where name = '{{ resourceName }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
|
||
variable "resource_name" { | ||
type = string | ||
default = "turbot-test-20200125-create-update" | ||
description = "Name of the resource used throughout the test." | ||
} | ||
|
||
variable "gcp_project" { | ||
type = string | ||
default = "niteowl-aaa" | ||
description = "GCP project used for the test." | ||
} | ||
|
||
variable "gcp_region" { | ||
type = string | ||
default = "us-east1" | ||
description = "GCP region used for the test." | ||
} | ||
|
||
provider "google" { | ||
project = var.gcp_project | ||
region = var.gcp_region | ||
} | ||
|
||
data "google_client_config" "current" {} | ||
|
||
data "null_data_source" "resource" { | ||
inputs = { | ||
scope = "gcp://cloudresourcemanager.googleapis.com/projects/${data.google_client_config.current.project}" | ||
} | ||
} | ||
|
||
resource "google_compute_network" "named_test_resource" { | ||
name = var.resource_name | ||
} | ||
|
||
resource "google_compute_firewall" "named_test_resource" { | ||
name = var.resource_name | ||
network = google_compute_network.named_test_resource.name | ||
description = "Test firewall rule to verify the table." | ||
|
||
allow { | ||
protocol = "icmp" | ||
} | ||
|
||
allow { | ||
protocol = "tcp" | ||
ports = ["80", "8080", "1000-2000"] | ||
} | ||
|
||
source_tags = ["web"] | ||
} | ||
|
||
output "resource_aka" { | ||
value = "gcp://compute.googleapis.com/${google_compute_firewall.named_test_resource.id}" | ||
} | ||
|
||
output "resource_name" { | ||
value = var.resource_name | ||
} | ||
|
||
output "resource_id" { | ||
value = google_compute_firewall.named_test_resource.id | ||
} | ||
|
||
output "self_link" { | ||
value = google_compute_firewall.named_test_resource.self_link | ||
} | ||
|
||
output "network" { | ||
value = google_compute_network.named_test_resource.self_link | ||
} | ||
|
||
output "project_id" { | ||
value = var.gcp_project | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.