Skip to content

Commit

Permalink
Reduce number of generated resources to 4:
Browse files Browse the repository at this point in the history
google_compute_region_backend_service
google_compute_backend_service
google_compute_forwarding_rule
google_compute_region_health_check
  • Loading branch information
amirkaromashkin committed Oct 27, 2023
1 parent 210ca9d commit c4e3924
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 69 deletions.
21 changes: 11 additions & 10 deletions mmv1/third_party/cai2hcl/services/compute/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,33 @@ import (

var forwardingRuleMatchers = []matchers.ConverterMatcher{
matchers.ByAssetName(ComputeForwardingRuleAssetNameRegex, "google_compute_forwarding_rule"),
matchers.ByAssetName(ComputeGlobalForwardingRuleAssetNameRegex, "google_compute_global_forwarding_rule"),
}

var backendServiceMatchers = []matchers.ConverterMatcher{
matchers.ByAssetName(ComputeRegionBackendServiceAssetNameRegex, "google_compute_region_backend_service"),
matchers.ByAssetName(ComputeBackendServiceAssetNameRegex, "google_compute_backend_service"),
}

var healthCheckMatchers = []matchers.ConverterMatcher{
matchers.ByAssetName(ComputeRegionHealthCheckAssetNameRegex, "google_compute_region_health_check"),
}

var UberConverter = common.UberConverter{
ConverterByAssetType: map[string]string{
ComputeInstanceAssetType: "google_compute_instance",
ComputeHealthCheckAssetType: "google_compute_health_check",
ComputeInstanceAssetType: "google_compute_instance",
},
ConverterMatchersByAssetType: map[string][]matchers.ConverterMatcher{
ComputeForwardingRuleAssetType: forwardingRuleMatchers,
ComputeGlobalForwardingRuleAssetType: forwardingRuleMatchers,

ComputeBackendServiceAssetType: backendServiceMatchers,
ComputeRegionBackendServiceAssetType: backendServiceMatchers,
ComputeBackendServiceAssetType: backendServiceMatchers,

ComputeRegionHealthCheckAssetType: healthCheckMatchers,
ComputeForwardingRuleAssetType: forwardingRuleMatchers,
},
Converters: common.CreateConverterMap(map[string]common.ConverterFactory{
"google_compute_instance": NewComputeInstanceConverter,
"google_compute_health_check": NewComputeHealthCheckConverter,
"google_compute_forwarding_rule": NewComputeForwardingRuleConverter,
"google_compute_global_forwarding_rule": NewComputeGlobalForwardingRuleConverter,
"google_compute_region_backend_service": NewComputeRegionBackendServiceConverter,
"google_compute_backend_service": NewComputeBackendServiceConverter,
"google_compute_forwarding_rule": NewComputeForwardingRuleConverter,
"google_compute_region_health_check": NewComputeRegionHealthCheckConverter,
}),
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

[
{
"name": "//compute.googleapis.com/projects/myproj/regions/us-central1/healthChecks/hc-1",
"asset_type": "compute.googleapis.com/RegionHealthCheck",
"ancestry_path": "organizations/123/folders/456/project/myproj",
"resource": {
"version": "v1",
"discovery_document_uri": "https://www.googleapis.com/discovery/v1/apis/compute/v1/rest",
"discovery_name": "RegionHealthCheck",
"parent": "//cloudresourcemanager.googleapis.com/projects/myproj",
"data": {
"checkIntervalSec": 5,
"description": "",
"healthyThreshold": 2,
"name": "hc",
"region": "projects/cn-fe-playground/regions/us-central1",
"tcpHealthCheck": {
"port": 80,
"proxyHeader": "NONE"
},
"timeoutSec": 5,
"type": "TCP",
"unhealthyThreshold": 2
}
}
},
{
"name": "//compute.googleapis.com/projects/myproj/regions/us-central1/healthChecks/hc-1",
"asset_type": "compute.googleapis.com/RegionHealthCheck",
"ancestry_path": "organizations/123/folders/456/project/myproj",
"resource": {
"version": "v1",
"discovery_document_uri": "https://www.googleapis.com/discovery/v1/apis/compute/v1/rest",
"discovery_name": "RegionHealthCheck",
"parent": "//cloudresourcemanager.googleapis.com/projects/myproj",
"data": {
"checkIntervalSec": 5,
"description": "descr",
"healthyThreshold": 2,
"name": "hc",
"region": "projects/cn-fe-playground/regions/us-central1",
"tcpHealthCheck": {
"port": 8,
"proxyHeader": "PROXY_V1",
"request": "a",
"response": "b"
},
"timeoutSec": 5,
"type": "TCP",
"unhealthyThreshold": 2
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
resource "google_compute_region_health_check" "hc" {
check_interval_sec = 5
healthy_threshold = 2

log_config {
enable = false
}

name = "hc"
region = "us-central1"

tcp_health_check {
port = 80
proxy_header = "NONE"
}

timeout_sec = 5
type = "TCP"
unhealthy_threshold = 2
}

resource "google_compute_region_health_check" "hc" {
check_interval_sec = 5
description = "descr"
healthy_threshold = 2

log_config {
enable = false
}

name = "hc"
region = "us-central1"

tcp_health_check {
port = 8
proxy_header = "PROXY_V1"
request = "a"
response = "b"
}

timeout_sec = 5
type = "TCP"
unhealthy_threshold = 2
}

0 comments on commit c4e3924

Please sign in to comment.