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

Forwardingrule ip address #2620

Merged
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
32 changes: 14 additions & 18 deletions products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides
default_from_api: true
IPAddress: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
validation: !ruby/object:Provider::Terraform::Validation
function: 'validateIpAddress'
description: |
The IP address that this forwarding rule is serving on behalf of.

Expand All @@ -554,15 +556,11 @@ overrides: !ruby/object:Overrides::ResourceOverrides
internal IP address will be automatically allocated from the IP range
of the subnet or network configured for this forwarding rule.

~> **NOTE** The address should be specified as a literal IP address,
e.g. `100.1.2.3` to avoid a permanent diff, as the server returns the
IP address regardless of the input value.

The server accepts a literal IP address or a URL reference to an existing
Address resource. The following examples are all valid but only the first
will prevent a permadiff. If you are using `google_compute_address` or
similar, interpolate using `.address` instead of `.self_link` or similar
to prevent a diff on re-apply.
An address must be specified by a literal IP address. ~> **NOTE**: While
the API allows you to specify various resource paths for an address resource
instead, Terraform requires this to specifically be an IP address to
avoid needing to fetching the IP address from resource paths on refresh
or unnecessary diffs.
IPProtocol: !ruby/object:Overrides::Terraform::PropertyOverride
diff_suppress_func: 'caseDiffSuppress'
default_from_api: true
Expand Down Expand Up @@ -637,6 +635,8 @@ 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'
description: |
The IP address that this forwarding rule is serving on behalf of.

Expand All @@ -657,15 +657,11 @@ overrides: !ruby/object:Overrides::ResourceOverrides
internal IP address will be automatically allocated from the IP range
of the subnet or network configured for this forwarding rule.

~> **NOTE** The address should be specified as a literal IP address,
e.g. `100.1.2.3` to avoid a permanent diff, as the server returns the
IP address regardless of the input value.

The server accepts a literal IP address or a URL reference to an existing
Address resource. The following examples are all valid but only the first
will prevent a permadiff. If you are using `google_compute_address` or
similar, interpolate using `.address` instead of `.self_link` or similar
to prevent a diff on re-apply.
An address must be specified by a literal IP address. ~> **NOTE**: While
the API allows you to specify various resource paths for an address resource
instead, Terraform requires this to specifically be an IP address to
avoid needing to fetching the IP address from resource paths on refresh
or unnecessary diffs.
IPProtocol: !ruby/object:Overrides::Terraform::PropertyOverride
diff_suppress_func: 'caseDiffSuppress'
default_from_api: true
Expand Down
8 changes: 8 additions & 0 deletions third_party/terraform/utils/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@ func validateNonNegativeDuration() schema.SchemaValidateFunc {
}
}

func validateIpAddress(i interface{}, val string) ([]string, []error) {
ip := net.ParseIP(i.(string))
if ip == nil {
return nil, []error{fmt.Errorf("could not parse %q to IP address", val)}
}
return nil, nil
}

// StringNotInSlice returns a SchemaValidateFunc which tests if the provided value
// is of type string and that it matches none of the element in the invalid slice.
// if ignorecase is true, case is ignored.
Expand Down