Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
Add a resource mapping for google_compute_global_address (#5475) (#405)
Browse files Browse the repository at this point in the history
* Add a resource mapping for google_compute_global_address

* add test data files

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Nov 24, 2021
1 parent bb9f17c commit 9c79072
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 3 deletions.
1 change: 1 addition & 0 deletions converters/google/resources/resource_converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func ResourceConverters() map[string][]ResourceConverter {
"google_compute_firewall": {resourceConverterComputeFirewall()},
"google_compute_disk": {resourceConverterComputeDisk()},
"google_compute_forwarding_rule": {resourceConverterComputeForwardingRule()},
"google_compute_global_address": {resourceConverterComputeGlobalAddress()},
"google_compute_global_forwarding_rule": {resourceConverterComputeGlobalForwardingRule()},
"google_compute_instance": {resourceConverterComputeInstance()},
"google_compute_network": {resourceConverterComputeNetwork()},
Expand Down
1 change: 1 addition & 0 deletions test/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func TestCLI(t *testing.T) {
{name: "example_compute_disk"},
{name: "example_compute_disk_empty_image"},
{name: "example_compute_firewall"},
{name: "example_compute_global_address"},
{name: "example_compute_global_forwarding_rule"},
{name: "example_compute_network"},
{name: "example_compute_snapshot"},
Expand Down
1 change: 1 addition & 0 deletions test/read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func TestReadPlannedAssetsCoverage(t *testing.T) {
{name: "example_compute_disk"},
{name: "example_compute_disk_empty_image"},
{name: "example_compute_firewall"},
{name: "example_compute_global_address"},
{name: "example_compute_global_forwarding_rule"},
{name: "example_compute_network"},
{name: "example_compute_snapshot"},
Expand Down
17 changes: 17 additions & 0 deletions testdata/templates/example_compute_global_address.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"name": "//compute.googleapis.com/projects/{{.Provider.project}}/global/addresses/global-appserver-ip",
"asset_type": "compute.googleapis.com/GlobalAddress",
"ancestry_path": "{{.Ancestry}}/project/{{.Provider.project}}",
"resource": {
"version": "v1",
"discovery_document_uri": "https://www.googleapis.com/discovery/v1/apis/compute/v1/rest",
"discovery_name": "GlobalAddress",
"parent": "//cloudresourcemanager.googleapis.com/projects/{{.Provider.project}}",
"data": {
"addressType": "EXTERNAL",
"name": "global-appserver-ip"
}
}
}
]
32 changes: 32 additions & 0 deletions testdata/templates/example_compute_global_address.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright 2021 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.
*/

terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "~> {{.Provider.version}}"
}
}
}

provider "google" {
{{if .Provider.credentials }}credentials = "{{.Provider.credentials}}"{{end}}
}

resource "google_compute_global_address" "default" {
name = "global-appserver-ip"
}
92 changes: 92 additions & 0 deletions testdata/templates/example_compute_global_address.tfplan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"format_version": "0.2",
"terraform_version": "1.0.10",
"planned_values": {
"root_module": {
"resources": [
{
"address": "google_compute_global_address.default",
"mode": "managed",
"type": "google_compute_global_address",
"name": "default",
"provider_name": "registry.terraform.io/hashicorp/google",
"schema_version": 0,
"values": {
"address_type": null,
"description": null,
"ip_version": null,
"name": "global-appserver-ip",
"network": null,
"prefix_length": null,
"purpose": null,
"timeouts": null
},
"sensitive_values": {}
}
]
}
},
"resource_changes": [
{
"address": "google_compute_global_address.default",
"mode": "managed",
"type": "google_compute_global_address",
"name": "default",
"provider_name": "registry.terraform.io/hashicorp/google",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"address_type": null,
"description": null,
"ip_version": null,
"name": "global-appserver-ip",
"network": null,
"prefix_length": null,
"purpose": null,
"timeouts": null
},
"after_unknown": {
"address": true,
"creation_timestamp": true,
"id": true,
"project": true,
"self_link": true
},
"before_sensitive": false,
"after_sensitive": {}
}
}
],
"configuration": {
"provider_config": {
"google": {
"name": "google",
"expressions": {
"project": {
"constant_value": "{{.Provider.project}}"
}
}
}
},
"root_module": {
"resources": [
{
"address": "google_compute_global_address.default",
"mode": "managed",
"type": "google_compute_global_address",
"name": "default",
"provider_config_key": "google",
"expressions": {
"name": {
"constant_value": "global-appserver-ip"
}
},
"schema_version": 0
}
]
}
}
}
22 changes: 19 additions & 3 deletions testdata/templates/full_sql_database_instance.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@
},
"settings": {
"activationPolicy": "test-activation_policy",

"availabilityType": "REGIONAL",
"backupConfiguration": {
"binaryLogEnabled": true,
"enabled": true,
"startTime": "42:42",
"location": "us"
"location": "us",
"startTime": "42:42"
},
"dataDiskSizeGb": "42",
"dataDiskType": "test-disk_type",
Expand Down Expand Up @@ -86,6 +85,23 @@
}
}
},
{
"name": "//compute.googleapis.com/projects/{{.Provider.project}}/global/addresses/private-ip-address",
"asset_type": "compute.googleapis.com/GlobalAddress",
"ancestry_path": "{{.Ancestry}}/project/{{.Provider.project}}",
"resource": {
"version": "v1",
"discovery_document_uri": "https://www.googleapis.com/discovery/v1/apis/compute/v1/rest",
"discovery_name": "GlobalAddress",
"parent": "//cloudresourcemanager.googleapis.com/projects/{{.Provider.project}}",
"data": {
"addressType": "INTERNAL",
"name": "private-ip-address",
"prefixLength": 16,
"purpose": "VPC_PEERING"
}
}
},
{
"name": "//compute.googleapis.com/projects/{{.Provider.project}}/global/networks/private-network",
"asset_type": "compute.googleapis.com/Network",
Expand Down

0 comments on commit 9c79072

Please sign in to comment.