Skip to content
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

Add table gcp_compute_ssl_policy. Closes #153 #154

Merged
merged 6 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions docs/tables/gcp_compute_ssl_policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Table: gcp_compute_ssl_policy

Secure Sockets Layer (SSL) policies determine what port Transport Layer Security (TLS)
features clients are permitted to use when connecting to load balancers.

## Examples

### Basic info

```sql
select
name,
id,
self_link,
min_tls_version
from
gcp_compute_ssl_policy;
```

### Get the SSL policy with a minimum TLS version 1.2 with the MODERN profile
Subhajit97 marked this conversation as resolved.
Show resolved Hide resolved

```sql
select
name,
id,
min_tls_version
from
gcp_compute_ssl_policy
where
min_tls_version = 'TLS_1_2'
and profile = 'MODERN';
```

### Get the SSL policy whose Profile set to RESTRICTED
Subhajit97 marked this conversation as resolved.
Show resolved Hide resolved

```sql
select
name,
id,
profile
from
gcp_compute_ssl_policy
where
profile = 'RESTRICTED';
```

### Get the SSL policy with weak cipher suit(s)
Subhajit97 marked this conversation as resolved.
Show resolved Hide resolved

```sql
select
name,
id,
enabled_feature
from
gcp_compute_ssl_policy,
jsonb_array_elements_text(enabled_features) as enabled_feature
where
profile = 'CUSTOM'
and enabled_feature in('TLS_RSA_WITH_AES_128_GCM_SHA256', 'TLS_RSA_WITH_AES_256_GCM_SHA384', 'TLS_RSA_WITH_AES_128_CBC_SHA', 'TLS_RSA_WITH_AES_256_CBC_SHA', 'TLS_RSA_WITH_3DES_EDE_CBC_SHA');
```
Empty file.
25 changes: 25 additions & 0 deletions gcp-test/tests/gcp_compute_ssl_policy/test-get-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[
{
"description": "Test SSL policy to validate the table outcome.",
"enabled_features": [
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
"TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256"
],
"fingerprint": "{{ output.fingerprint.value }}",
"kind": "compute#sslPolicy",
"location": "global",
"min_tls_version": "TLS_1_2",
"name": "{{ resourceName }}",
"profile": "MODERN",
"project": "{{ output.project_id.value }}",
"self_link": "{{ output.self_link.value }}"
}
]
3 changes: 3 additions & 0 deletions gcp-test/tests/gcp_compute_ssl_policy/test-get-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, description, kind, fingerprint, min_tls_version, profile, enabled_features, self_link, project, location
from gcp.gcp_compute_ssl_policy
where name = '{{ resourceName }}';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
null
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, id, description
from gcp.gcp_compute_ssl_policy
where name = '';
6 changes: 6 additions & 0 deletions gcp-test/tests/gcp_compute_ssl_policy/test-list-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"description": "Test SSL policy to validate the table outcome.",
"name": "{{ resourceName }}"
}
]
3 changes: 3 additions & 0 deletions gcp-test/tests/gcp_compute_ssl_policy/test-list-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, description
from gcp.gcp_compute_ssl_policy
where akas::text = '["{{ output.resource_aka.value }}"]';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
null
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, id, kind, description
from gcp.gcp_compute_ssl_policy
where name = 'dummy-{{ resourceName }}';
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"akas": ["{{ output.resource_aka.value }}"],
"title": "{{ resourceName }}"
}
]
3 changes: 3 additions & 0 deletions gcp-test/tests/gcp_compute_ssl_policy/test-turbot-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select title, akas
from gcp.gcp_compute_ssl_policy
where name = '{{ resourceName }}';
1 change: 1 addition & 0 deletions gcp-test/tests/gcp_compute_ssl_policy/variables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
68 changes: 68 additions & 0 deletions gcp-test/tests/gcp_compute_ssl_policy/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

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."
}

variable "gcp_zone" {
type = string
default = "us-east1-b"
}

provider "google" {
project = var.gcp_project
region = var.gcp_region
zone = var.gcp_zone
}

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_ssl_policy" "named_test_resource" {
name = var.resource_name
description = "Test SSL policy to validate the table outcome."
profile = "MODERN"
min_tls_version = "TLS_1_2"
}

output "resource_aka" {
value = "gcp://compute.googleapis.com/${google_compute_ssl_policy.named_test_resource.id}"
}

output "resource_name" {
value = var.resource_name
}

output "resource_id" {
value = google_compute_ssl_policy.named_test_resource.id
}

output "self_link" {
value = google_compute_ssl_policy.named_test_resource.self_link
}

output "fingerprint" {
value = google_compute_ssl_policy.named_test_resource.fingerprint
}

output "project_id" {
value = var.gcp_project
}
1 change: 1 addition & 0 deletions gcp/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func Plugin(ctx context.Context) *plugin.Plugin {
"gcp_compute_region": tableGcpComputeRegion(ctx),
"gcp_compute_router": tableGcpComputeRouter(ctx),
"gcp_compute_snapshot": tableGcpComputeSnapshot(ctx),
"gcp_compute_ssl_policy": tableGcpComputeSslPolicy(ctx),
"gcp_compute_subnetwork": tableGcpComputeSubnetwork(ctx),
"gcp_compute_target_pool": tableGcpComputeTargetPool(ctx),
"gcp_compute_target_vpn_gateway": tableGcpComputeTargetVpnGateway(ctx),
Expand Down
Loading