mirror of https://github.com/kubernetes/kops.git
Ignore white space when validating IAM policy size limits
The AWS documentation [0] mentions: > IAM does not count white space when calculating the size of a policy against these quotas. Therefore we should be excluding white space when performing this validation client-side. [0] https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html#reference_iam-quotas-entity-length
This commit is contained in:
parent
0506b07814
commit
dba112a21f
|
@ -22,6 +22,7 @@ import (
|
|||
"hash/fnv"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
|
@ -296,9 +297,9 @@ func (e *IAMRolePolicy) policyDocumentString() (string, error) {
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
policySize := len(policy)
|
||||
policySize := len(strings.Join(strings.Fields(policy), ""))
|
||||
if policySize > 10240 {
|
||||
return "", fmt.Errorf("policy size was %d. Policy cannot exceed 10240 bytes.", policySize)
|
||||
return "", fmt.Errorf("policy size was %d. Policy cannot exceed 10240 bytes", policySize)
|
||||
}
|
||||
return policy, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue