Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make forwarding rule service_label and service_name GA #3333

Merged
merged 1 commit into from
Mar 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions google/resource_compute_forwarding_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ func resourceComputeForwardingRule() *schema.Resource {
ForceNew: true,
DiffSuppressFunc: compareSelfLinkOrResourceName,
},
"service_label": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validateGCPName,
},
"subnetwork": {
Type: schema.TypeString,
Computed: true,
Expand All @@ -145,6 +151,10 @@ func resourceComputeForwardingRule() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"service_name": {
Type: schema.TypeString,
Computed: true,
},
"project": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -247,6 +257,12 @@ func resourceComputeForwardingRuleCreate(d *schema.ResourceData, meta interface{
} else if v, ok := d.GetOkExists("network_tier"); !isEmptyValue(reflect.ValueOf(networkTierProp)) && (ok || !reflect.DeepEqual(v, networkTierProp)) {
obj["networkTier"] = networkTierProp
}
serviceLabelProp, err := expandComputeForwardingRuleServiceLabel(d.Get("service_label"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("service_label"); !isEmptyValue(reflect.ValueOf(serviceLabelProp)) && (ok || !reflect.DeepEqual(v, serviceLabelProp)) {
obj["serviceLabel"] = serviceLabelProp
}
regionProp, err := expandComputeForwardingRuleRegion(d.Get("region"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -363,6 +379,12 @@ func resourceComputeForwardingRuleRead(d *schema.ResourceData, meta interface{})
if err := d.Set("network_tier", flattenComputeForwardingRuleNetworkTier(res["networkTier"], d)); err != nil {
return fmt.Errorf("Error reading ForwardingRule: %s", err)
}
if err := d.Set("service_label", flattenComputeForwardingRuleServiceLabel(res["serviceLabel"], d)); err != nil {
return fmt.Errorf("Error reading ForwardingRule: %s", err)
}
if err := d.Set("service_name", flattenComputeForwardingRuleServiceName(res["serviceName"], d)); err != nil {
return fmt.Errorf("Error reading ForwardingRule: %s", err)
}
if err := d.Set("region", flattenComputeForwardingRuleRegion(res["region"], d)); err != nil {
return fmt.Errorf("Error reading ForwardingRule: %s", err)
}
Expand Down Expand Up @@ -550,6 +572,14 @@ func flattenComputeForwardingRuleNetworkTier(v interface{}, d *schema.ResourceDa
return v
}

func flattenComputeForwardingRuleServiceLabel(v interface{}, d *schema.ResourceData) interface{} {
return v
}

func flattenComputeForwardingRuleServiceName(v interface{}, d *schema.ResourceData) interface{} {
return v
}

func flattenComputeForwardingRuleRegion(v interface{}, d *schema.ResourceData) interface{} {
if v == nil {
return v
Expand Down Expand Up @@ -671,6 +701,10 @@ func expandComputeForwardingRuleNetworkTier(v interface{}, d TerraformResourceDa
return v, nil
}

func expandComputeForwardingRuleServiceLabel(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandComputeForwardingRuleRegion(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
f, err := parseGlobalFieldValue("regions", v.(string), "project", d, config, true)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions google/resource_compute_forwarding_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ resource "google_compute_forwarding_rule" "foobar2" {
backend_service = "${google_compute_region_backend_service.foobar-bs.self_link}"
ports = ["80"]
network = "${google_compute_network.foobar.self_link}"
service_label = "foobar"
}
`, serviceName, checkName, networkName, ruleName1, networkName, ruleName2)
}
Expand Down
17 changes: 17 additions & 0 deletions website/docs/r/compute_forwarding_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,19 @@ The following arguments are supported:
take the following values: PREMIUM or STANDARD. If this field is not
specified, it is assumed to be PREMIUM.

* `service_label` -
(Optional)
An optional prefix to the service name for this Forwarding Rule.
If specified, will be the first label of the fully qualified service
name.
The label must be 1-63 characters long, and comply with RFC1035.
Specifically, the label must be 1-63 characters long and match the
regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first
character must be a lowercase letter, and all following characters
must be a dash, lowercase letter, or digit, except the last
character, which cannot be a dash.
This field is only used for internal load balancing.

* `region` -
(Optional)
A reference to the region where the regional forwarding rule resides.
Expand All @@ -213,6 +226,10 @@ In addition to the arguments listed above, the following computed attributes are

* `creation_timestamp` -
Creation timestamp in RFC3339 text format.

* `service_name` -
The internal fully qualified service name for this Forwarding Rule.
This field is only used for internal load balancing.
* `self_link` - The URI of the created resource.


Expand Down