mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
Removes redundant ARN parsing
This commit is contained in:
@@ -37,7 +37,8 @@ func validateKMSKeyID(path cty.Path, s string) (diags tfdiags.Diagnostics) {
|
||||
}
|
||||
|
||||
func validateKMSKeyARN(path cty.Path, s string) (diags tfdiags.Diagnostics) {
|
||||
if _, err := arn.Parse(s); err != nil {
|
||||
parsedARN, err := arn.Parse(s)
|
||||
if err != nil {
|
||||
diags = diags.Append(tfdiags.AttributeValue(
|
||||
tfdiags.Error,
|
||||
"Invalid KMS Key ARN",
|
||||
@@ -47,7 +48,7 @@ func validateKMSKeyARN(path cty.Path, s string) (diags tfdiags.Diagnostics) {
|
||||
return diags
|
||||
}
|
||||
|
||||
if !isKeyARN(s) {
|
||||
if !isKeyARN(parsedARN) {
|
||||
diags = diags.Append(tfdiags.AttributeValue(
|
||||
tfdiags.Error,
|
||||
"Invalid KMS Key ARN",
|
||||
@@ -60,13 +61,8 @@ func validateKMSKeyARN(path cty.Path, s string) (diags tfdiags.Diagnostics) {
|
||||
return diags
|
||||
}
|
||||
|
||||
func isKeyARN(s string) bool {
|
||||
parsedARN, err := arn.Parse(s)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return keyIdFromARNResource(parsedARN.Resource) != ""
|
||||
func isKeyARN(arn arn.ARN) bool {
|
||||
return keyIdFromARNResource(arn.Resource) != ""
|
||||
}
|
||||
|
||||
func keyIdFromARNResource(s string) string {
|
||||
|
||||
Reference in New Issue
Block a user