diff --git a/mmv1/products/compute/api.yaml b/mmv1/products/compute/api.yaml index daf42c41828e..ded641cade85 100644 --- a/mmv1/products/compute/api.yaml +++ b/mmv1/products/compute/api.yaml @@ -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: | @@ -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' @@ -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: @@ -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 @@ -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 @@ -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 diff --git a/mmv1/products/compute/terraform.yaml b/mmv1/products/compute/terraform.yaml index 51ac0481af45..5492d625078c 100644 --- a/mmv1/products/compute/terraform.yaml +++ b/mmv1/products/compute/terraform.yaml @@ -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 @@ -795,6 +801,13 @@ 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 @@ -802,8 +815,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides 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. diff --git a/mmv1/templates/terraform/examples/global_address_private_services_connect.tf.erb b/mmv1/templates/terraform/examples/global_address_private_services_connect.tf.erb new file mode 100644 index 000000000000..be16bbc4059f --- /dev/null +++ b/mmv1/templates/terraform/examples/global_address_private_services_connect.tf.erb @@ -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" +} \ No newline at end of file diff --git a/mmv1/templates/terraform/examples/global_forwarding_rule_private_services_connect.tf.erb b/mmv1/templates/terraform/examples/global_forwarding_rule_private_services_connect.tf.erb new file mode 100644 index 000000000000..3c45ddf31299 --- /dev/null +++ b/mmv1/templates/terraform/examples/global_forwarding_rule_private_services_connect.tf.erb @@ -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" +} \ No newline at end of file diff --git a/mmv1/third_party/terraform/utils/common_diff_suppress.go.erb b/mmv1/third_party/terraform/utils/common_diff_suppress.go.erb index 719873af7e45..95eb343d8ba5 100644 --- a/mmv1/third_party/terraform/utils/common_diff_suppress.go.erb +++ b/mmv1/third_party/terraform/utils/common_diff_suppress.go.erb @@ -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) +} \ No newline at end of file