-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Relocate Valid4ByteAsn function to common lib, add to CloudWAN Network Policy Doc Data Source #27305
Relocate Valid4ByteAsn function to common lib, add to CloudWAN Network Policy Doc Data Source #27305
Changes from 3 commits
3533a1d
a828943
4f9aebd
3f5165b
434ff35
0de69f8
2cf8aac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:note | ||
Add plan-time validation for `aws_networkmanager_core_network_policy_document.core_network_configuration.edge_locations[].asn` | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,27 @@ var accountIDRegexp = regexp.MustCompile(`^(aws|aws-managed|\d{12})$`) | |
var partitionRegexp = regexp.MustCompile(`^aws(-[a-z]+)*$`) | ||
var regionRegexp = regexp.MustCompile(`^[a-z]{2}(-[a-z]+)+-\d$`) | ||
|
||
func Valid4ByteASN(v interface{}, k string) (ws []string, errors []error) { | ||
stringValue := strconv.Itoa(v.(int)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gdavison Can you see any concerns with the 32-bit BSD build on this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ASN numbers are 32-bit unsigned values, so this will fail for any values between |
||
|
||
return Valid4ByteASNString(stringValue, k) | ||
} | ||
|
||
func Valid4ByteASNString(v interface{}, k string) (ws []string, errors []error) { | ||
value := v.(string) | ||
|
||
asn, err := strconv.ParseInt(value, 10, 64) | ||
if err != nil { | ||
errors = append(errors, fmt.Errorf("%q (%q) must be a 64-bit integer", k, v)) | ||
return | ||
} | ||
|
||
if asn < 0 || asn > 4294967295 { | ||
errors = append(errors, fmt.Errorf("%q (%q) must be in the range 0 to 4294967295", k, v)) | ||
} | ||
return | ||
} | ||
|
||
func ValidARN(v interface{}, k string) (ws []string, errors []error) { | ||
value := v.(string) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be changed to a
schema.TypeString
, which will be handled internally as anint64
. We can take advantage of the Terraform parser which will allow some string values, such as numbers and boolean values to omit the quotes