Skip to content

Commit

Permalink
Network Connectivity Spoke (GoogleCloudPlatform#5586)
Browse files Browse the repository at this point in the history
  • Loading branch information
c2thorn authored and lcaggio committed Mar 16, 2022
1 parent 0f1989c commit cab8023
Show file tree
Hide file tree
Showing 14 changed files with 4,918 additions and 3,048 deletions.
2 changes: 1 addition & 1 deletion mmv1/third_party/terraform/go.mod.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/hashicorp/terraform-provider-google<%= "-" + version unless ve

require (
cloud.google.com/go/bigtable v1.10.1
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220106225628-959dba9ad83c
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220114025148-a9879027a727
github.com/apparentlymart/go-cidr v1.1.0
github.com/client9/misspell v0.3.4
github.com/davecgh/go-spew v1.1.1
Expand Down
8 changes: 6 additions & 2 deletions mmv1/third_party/terraform/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 h1:sHglBQTwgx+rW
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211215020606-79616333f950 h1:pJAaEIUF6dSY6hRyiHpSlSHgvyaCv478IUVZR6t2OIU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211215020606-79616333f950/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220106225628-959dba9ad83c h1:eSQGB4tXlzv8Z/LXRoP3Ja6dHMSIv/z4Qw+5VT6WaB8=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220106225628-959dba9ad83c/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220110205338-bb0f55721bc4 h1:q6pEOs1blrAzT4w9oWV9BlgAaNXEytrOTORhYxIBQEQ=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220110205338-bb0f55721bc4/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220114025148-a9879027a727 h1:+s/Q1OtaOX8y10li7GLqeBx6e4jd3aF/YlLhXWG9Y9g=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220114025148-a9879027a727/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
Expand Down Expand Up @@ -1441,5 +1447,3 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220106225628-959dba9ad83c h1:eSQGB4tXlzv8Z/LXRoP3Ja6dHMSIv/z4Qw+5VT6WaB8=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220106225628-959dba9ad83c/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
4 changes: 2 additions & 2 deletions mmv1/third_party/terraform/utils/config.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ type Config struct {
CloudResourceManagerBasePath string
EventarcBasePath string
GkeHubBasePath string
ContainerAzureBasePath string
ContainerAwsBasePath string
ContainerAzureBasePath string
ContainerAwsBasePath string
NetworkConnectivityBasePath string
OrgPolicyBasePath string
RecaptchaEnterpriseBasePath string
Expand Down
1 change: 1 addition & 0 deletions mmv1/third_party/terraform/utils/provider.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ end # products.each do
"google_monitoring_monitored_project": resourceMonitoringMonitoredProject(),
<% end -%>
"google_network_connectivity_hub": resourceNetworkConnectivityHub(),
"google_network_connectivity_spoke": resourceNetworkConnectivitySpoke(),
"google_org_policy_policy": resourceOrgPolicyPolicy(),
"google_os_config_os_policy_assignment": resourceOsConfigOsPolicyAssignment(),
<% if version == 'private' -%>
Expand Down
2 changes: 1 addition & 1 deletion tpgtools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.16

require (
bitbucket.org/creachadair/stringset v0.0.9
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220106225628-959dba9ad83c
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220114025148-a9879027a727
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/hashicorp/errwrap v1.0.0
github.com/hashicorp/hcl v1.0.0
Expand Down
4 changes: 4 additions & 0 deletions tpgtools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220106225628-959dba9ad83c h1:eSQGB4tXlzv8Z/LXRoP3Ja6dHMSIv/z4Qw+5VT6WaB8=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220106225628-959dba9ad83c/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220110205338-bb0f55721bc4 h1:q6pEOs1blrAzT4w9oWV9BlgAaNXEytrOTORhYxIBQEQ=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220110205338-bb0f55721bc4/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220114025148-a9879027a727 h1:+s/Q1OtaOX8y10li7GLqeBx6e4jd3aF/YlLhXWG9Y9g=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220114025148-a9879027a727/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

resource "google_compute_network" "network" {
name = "{{network}}"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "subnetwork" {
name = "{{subnet}}"
ip_cidr_range = "10.0.0.0/28"
region = "{{region}}"
network = google_compute_network.network.self_link
}

resource "google_compute_instance" "instance" {
name = "{{instance}}"
machine_type = "e2-medium"
can_ip_forward = true
zone = "{{zone}}"

boot_disk {
initialize_params {
image = "projects/debian-cloud/global/images/debian-10-buster-v20210817"
}
}

network_interface {
subnetwork = google_compute_subnetwork.subnetwork.name
network_ip = "10.0.0.2"
access_config {
network_tier = "PREMIUM"
}
}
}

resource "google_network_connectivity_hub" "basic_hub" {
name = "{{hub}}"
description = "A sample hub"
labels = {
label-two = "value-one"
}
}

resource "google_network_connectivity_spoke" "primary" {
name = "{{name}}"
location = "{{region}}"
description = "A sample spoke with a linked routher appliance instance"
labels = {
label-one = "value-one"
}
hub = google_network_connectivity_hub.basic_hub.id
linked_router_appliance_instances {
instances {
virtual_machine = google_compute_instance.instance.self_link
ip_address = "10.0.0.2"
}
site_to_site_data_transfer = true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
updates:
- resource: router_appliance_update.tf.tmpl
variables:
- name: "project"
type: "project"
- name: "region"
type: "region"
- name: "zone"
type: "zone"
- name: "name"
type: "resource_name"
- name: "hub"
type: "resource_name"
- name: "network"
type: "resource_name"
- name: "subnet"
type: "resource_name"
- name: "instance"
type: "resource_name"
- name: "instance2"
type: "resource_name"
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

resource "google_compute_network" "network" {
name = "{{network}}"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "subnetwork" {
name = "{{subnet}}"
ip_cidr_range = "10.0.0.0/28"
region = "{{region}}"
network = google_compute_network.network.self_link
}

resource "google_compute_instance" "instance" {
name = "{{instance}}"
machine_type = "e2-medium"
can_ip_forward = true
zone = "{{zone}}"

boot_disk {
initialize_params {
image = "projects/debian-cloud/global/images/debian-10-buster-v20210817"
}
}

network_interface {
subnetwork = google_compute_subnetwork.subnetwork.name
network_ip = "10.0.0.2"
access_config {
network_tier = "PREMIUM"
}
}
}

resource "google_network_connectivity_hub" "basic_hub" {
name = "{{hub}}"
description = "A sample hub"
labels = {
label-two = "value-one"
}
}

resource "google_network_connectivity_spoke" "primary" {
name = "{{name}}"
location = "{{region}}"
description = "An UPDATED sample spoke with a linked routher appliance instance"
labels = {
label-two = "value-two"
}
hub = google_network_connectivity_hub.basic_hub.id
linked_router_appliance_instances {
instances {
virtual_machine = google_compute_instance.instance.self_link
ip_address = "10.0.0.2"
}
site_to_site_data_transfer = true
}
}
Empty file.
2 changes: 1 addition & 1 deletion tpgtools/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ func (r *Resource) loadDCLSamples() []Sample {
if !versionMatch {
continue
} else if !strings.EqualFold(primaryResourceName.titlecase(), resourceType.titlecase()) {
glog.Errorf("skipping %s since no match with %s.", primaryResourceName, resourceType)
// This scenario will occur for product folders with multiple resources
continue
}

Expand Down
Loading

0 comments on commit cab8023

Please sign in to comment.