Skip to content

Commit

Permalink
updated to mmv1 folder
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardmedia committed Feb 12, 2021
1 parent 60b4fae commit 8bbb9eb
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 6 deletions.
20 changes: 16 additions & 4 deletions mmv1/products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3983,7 +3983,8 @@ objects:
The prefix length of the IP range. If not present, it means the
address field is a single IP address.

This field is not applicable to addresses with addressType=EXTERNAL.
This field is not applicable to addresses with addressType=EXTERNAL,
or addressType=INTERNAL when purpose=PRIVATE_SERVICE_CONNECT
- !ruby/object:Api::Type::Enum
name: 'addressType'
description: |
Expand All @@ -4001,10 +4002,12 @@ objects:
The purpose of the resource. For global internal addresses it can be

* VPC_PEERING - for peer networks
* PRIVATE_SERVICE_CONNECT - for ([Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) only) Private Service Connect networks

This should only be set when using an Internal address.
values:
- :VPC_PEERING
- :PRIVATE_SERVICE_CONNECT
- !ruby/object:Api::Type::ResourceRef
name: 'network'
resource: 'Network'
Expand Down Expand Up @@ -4082,6 +4085,10 @@ objects:
static IP address), with a purpose of GCE_END_POINT and addressType
of INTERNAL.

([Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) only) This must be a URL reference to an existing Address
resource (internal global static IP address), with a purpose of
PRIVATE_SERVICE_CONNECT and addressType of INTERNAL.

An address can be specified either by a literal IP address or a URL
reference to an existing Address resource. The following examples are
all valid:
Expand All @@ -4097,7 +4104,9 @@ objects:
name: 'IPProtocol'
description: |
The IP protocol to which this rule applies. When the load balancing scheme is
INTERNAL_SELF_MANAGED, only TCP is valid.
INTERNAL_SELF_MANAGED, only TCP is valid. This field must not be set if the
global address is configured as a purpose of PRIVATE_SERVICE_CONNECT
and addressType of INTERNAL
values:
- :TCP
- :UDP
Expand Down Expand Up @@ -4136,8 +4145,8 @@ objects:
will be used for External Global Load Balancing (HTTP(S) LB,
External TCP/UDP LB, SSL Proxy)

NOTE: Currently global forwarding rules cannot be used for INTERNAL
load balancing.
([Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) only) Note: This field must be set "" if the global address is
configured as a purpose of PRIVATE_SERVICE_CONNECT and addressType of INTERNAL.
default_value: :EXTERNAL
values:
- :EXTERNAL
Expand Down Expand Up @@ -4260,6 +4269,9 @@ objects:
The forwarded traffic must be of a type appropriate to the target object.
For INTERNAL_SELF_MANAGED load balancing, only HTTP and HTTPS targets
are valid.

([Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) only) For global address with a purpose of PRIVATE_SERVICE_CONNECT and
addressType of INTERNAL, only "all-apis" and "vpc-sc" are valid.
update_verb: :POST
update_url: 'projects/{{project}}/global/forwardingRules/{{name}}/setTarget'
- !ruby/object:Api::Resource
Expand Down
16 changes: 14 additions & 2 deletions mmv1/products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,12 @@ overrides: !ruby/object:Overrides::ResourceOverrides
primary_resource_id: "default"
vars:
global_address_name: "global-appserver-ip"
- !ruby/object:Provider::Terraform::Examples
name: "global_address_private_services_connect"
min_version: beta
primary_resource_id: "default"
vars:
global_address_name: "global-psconnect-ip"
properties:
id: !ruby/object:Overrides::Terraform::PropertyOverride
exclude: true
Expand Down Expand Up @@ -795,15 +801,21 @@ overrides: !ruby/object:Overrides::ResourceOverrides
http_proxy_name: "target-proxy"
backend_service_name: "backend"
igm_name: "igm-internal"
- !ruby/object:Provider::Terraform::Examples
name: "global_forwarding_rule_private_services_connect"
min_version: beta
primary_resource_id: "default"
vars:
global_address_name: "global-psconnect-ip"
forwarding_rule_name: "globalrule"
properties:
creationTimestamp: !ruby/object:Overrides::Terraform::PropertyOverride
exclude: true
id: !ruby/object:Overrides::Terraform::PropertyOverride
exclude: true
IPAddress: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
validation: !ruby/object:Provider::Terraform::Validation
function: 'validateIpAddress'
diff_suppress_func: 'internalIpDiffSuppress'
description: |
The IP address that this forwarding rule is serving on behalf of.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "google_compute_global_address" "default" {
provider = google-beta
name = "<%= ctx[:vars]['global_address_name'] %>"
address_type = "INTERNAL"
purpose = "PRIVATE_SERVICE_CONNECT"
network = data.google_compute_network.network.id
address = "100.100.100.105"
}

data "google_compute_network" "network" {
provider = google-beta
name = "default"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
resource "google_compute_global_address" "default" {
provider = google-beta
name = "<%= ctx[:vars]['global_address_name'] %>"
address_type = "INTERNAL"
purpose = "PRIVATE_SERVICE_CONNECT"
network = data.google_compute_network.network.id
address = "100.100.100.106"
}

resource "google_compute_global_forwarding_rule" "default" {
provider = google-beta
name = "<%= ctx[:vars]['forwarding_rule_name'] %>"
target = "all-apis"
network = data.google_compute_network.network.id
ip_address = google_compute_global_address.default.id
load_balancing_scheme = ""
}

data "google_compute_network" "network" {
provider = google-beta
name = "default"
}
6 changes: 6 additions & 0 deletions mmv1/third_party/terraform/utils/common_diff_suppress.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,9 @@ func timestampDiffSuppress(format string) schema.SchemaDiffSuppressFunc {
return oldT == newT
}
}

// suppress diff when saved is Ipv4 format while new is required a reference
// this happens for an internal ip for Private Services Connect
func internalIpDiffSuppress(_, old, new string, _ *schema.ResourceData) bool {
return (net.ParseIP(old) != nil) && (net.ParseIP(new) == nil)
}

0 comments on commit 8bbb9eb

Please sign in to comment.