Skip to content

Commit

Permalink
Merge pull request #1051 from ialidzhikov/automated-cherry-pick-of-#1…
Browse files Browse the repository at this point in the history
…041-origin-release-1.2

[release-1.2] Automated cherry pick of #1041: hash volume name to get client token
  • Loading branch information
k8s-ci-robot authored Sep 16, 2021
2 parents 5d5e7e2 + c90aba4 commit 361bdef
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package cloud

import (
"context"
"crypto/sha256"
"encoding/hex"
"errors"
"fmt"
"os"
Expand Down Expand Up @@ -320,9 +322,12 @@ func (c *cloud) CreateDisk(ctx context.Context, volumeName string, diskOptions *
}
}

// We hash the volume name to generate a unique token that is less than or equal to 64 characters
clientToken := sha256.Sum256([]byte(volumeName))

requestInput := &ec2.CreateVolumeInput{
AvailabilityZone: aws.String(zone),
ClientToken: aws.String(volumeName),
ClientToken: aws.String(hex.EncodeToString(clientToken[:])),
Size: aws.Int64(capacityGiB),
VolumeType: aws.String(createType),
TagSpecifications: []*ec2.TagSpecification{&tagSpec},
Expand Down

0 comments on commit 361bdef

Please sign in to comment.