Skip to content

Commit

Permalink
Add NetworkTier for GlobalForwardingRule. (#12474) (#20582)
Browse files Browse the repository at this point in the history
[upstream:dc4d9755cb9288177e0996c1c3b3fa9738ebdf89]

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Dec 4, 2024
1 parent a6bcc04 commit 697a137
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/12474.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
compute: added `network_tier` field to `google_compute_global_forwarding_rule` resource
```
35 changes: 35 additions & 0 deletions google/services/compute/resource_compute_global_forwarding_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,24 @@ be used.
For Private Service Connect forwarding rules that forward traffic to Google
APIs, a network must be provided.`,
},
"network_tier": {
Type: schema.TypeString,
Computed: true,
Optional: true,
ForceNew: true,
ValidateFunc: verify.ValidateEnum([]string{"PREMIUM", "STANDARD", ""}),
Description: `This signifies the networking tier used for configuring
this load balancer and can only take the following values:
'PREMIUM', 'STANDARD'.
For regional ForwardingRule, the valid values are 'PREMIUM' and
'STANDARD'. For GlobalForwardingRule, the valid value is
'PREMIUM'.
If this field is not specified, it is assumed to be 'PREMIUM'.
If 'IPAddress' is specified, this value must be equal to the
networkTier of the Address. Possible values: ["PREMIUM", "STANDARD"]`,
},
"no_automate_dns_zone": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -494,6 +512,12 @@ func resourceComputeGlobalForwardingRuleCreate(d *schema.ResourceData, meta inte
} else if v, ok := d.GetOkExists("target"); !tpgresource.IsEmptyValue(reflect.ValueOf(targetProp)) && (ok || !reflect.DeepEqual(v, targetProp)) {
obj["target"] = targetProp
}
networkTierProp, err := expandComputeGlobalForwardingRuleNetworkTier(d.Get("network_tier"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("network_tier"); !tpgresource.IsEmptyValue(reflect.ValueOf(networkTierProp)) && (ok || !reflect.DeepEqual(v, networkTierProp)) {
obj["networkTier"] = networkTierProp
}
serviceDirectoryRegistrationsProp, err := expandComputeGlobalForwardingRuleServiceDirectoryRegistrations(d.Get("service_directory_registrations"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -725,6 +749,9 @@ func resourceComputeGlobalForwardingRuleRead(d *schema.ResourceData, meta interf
if err := d.Set("target", flattenComputeGlobalForwardingRuleTarget(res["target"], d, config)); err != nil {
return fmt.Errorf("Error reading GlobalForwardingRule: %s", err)
}
if err := d.Set("network_tier", flattenComputeGlobalForwardingRuleNetworkTier(res["networkTier"], d, config)); err != nil {
return fmt.Errorf("Error reading GlobalForwardingRule: %s", err)
}
if err := d.Set("service_directory_registrations", flattenComputeGlobalForwardingRuleServiceDirectoryRegistrations(res["serviceDirectoryRegistrations"], d, config)); err != nil {
return fmt.Errorf("Error reading GlobalForwardingRule: %s", err)
}
Expand Down Expand Up @@ -1082,6 +1109,10 @@ func flattenComputeGlobalForwardingRuleTarget(v interface{}, d *schema.ResourceD
return v
}

func flattenComputeGlobalForwardingRuleNetworkTier(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenComputeGlobalForwardingRuleServiceDirectoryRegistrations(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return v
Expand Down Expand Up @@ -1258,6 +1289,10 @@ func expandComputeGlobalForwardingRuleTarget(v interface{}, d tpgresource.Terraf
return v, nil
}

func expandComputeGlobalForwardingRuleNetworkTier(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandComputeGlobalForwardingRuleServiceDirectoryRegistrations(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
l := v.([]interface{})
req := make([]interface{}, 0, len(l))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ resource "google_compute_global_forwarding_rule" "default" {
target = google_compute_target_http_proxy.default.id
port_range = "80"
load_balancing_scheme = "EXTERNAL_MANAGED"
network_tier = "PREMIUM"
}
resource "google_compute_target_http_proxy" "default" {
Expand Down
14 changes: 14 additions & 0 deletions website/docs/r/compute_global_forwarding_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ resource "google_compute_global_forwarding_rule" "default" {
target = google_compute_target_http_proxy.default.id
port_range = "80"
load_balancing_scheme = "EXTERNAL_MANAGED"
network_tier = "PREMIUM"
}
resource "google_compute_target_http_proxy" "default" {
Expand Down Expand Up @@ -1348,6 +1349,19 @@ The following arguments are supported:
However, a subnetwork must be specified if the network is in custom subnet
mode or when creating external forwarding rule with IPv6.

* `network_tier` -
(Optional)
This signifies the networking tier used for configuring
this load balancer and can only take the following values:
`PREMIUM`, `STANDARD`.
For regional ForwardingRule, the valid values are `PREMIUM` and
`STANDARD`. For GlobalForwardingRule, the valid value is
`PREMIUM`.
If this field is not specified, it is assumed to be `PREMIUM`.
If `IPAddress` is specified, this value must be equal to the
networkTier of the Address.
Possible values are: `PREMIUM`, `STANDARD`.

* `service_directory_registrations` -
(Optional)
Service Directory resources to register this forwarding rule with.
Expand Down

0 comments on commit 697a137

Please sign in to comment.