Skip to content

Commit 075a0c9

Browse files
committed
capi aws: append random string in caller ref
CallerReference needs to be a unique string. We include the infra id, which is unique, in case that is helpful for human debugging. A random string of an arbitrary length is appended in case the infra id is reused which is generally not supposed to happen but does in some edge cases.
1 parent 972c722 commit 075a0c9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pkg/asset/installconfig/aws/route53.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
awss "github.com/aws/aws-sdk-go/aws/session"
1313
"github.com/aws/aws-sdk-go/service/route53"
1414
"github.com/sirupsen/logrus"
15+
"k8s.io/apimachinery/pkg/util/rand"
1516
"k8s.io/apimachinery/pkg/util/sets"
1617
"k8s.io/apimachinery/pkg/util/validation/field"
1718

@@ -247,8 +248,14 @@ func (c *Client) CreateHostedZone(ctx context.Context, input *HostedZoneInput) (
247248
cfg := GetR53ClientCfg(c.ssn, input.Role)
248249
svc := route53.New(c.ssn, cfg)
249250

251+
// CallerReference needs to be a unique string. We include the infra id,
252+
// which is unique, in case that is helpful for human debugging. A random
253+
// string of an arbitrary length is appended in case the infra id is reused
254+
// which is generally not supposed to happen but does in some edge cases.
255+
callerRef := aws.String(fmt.Sprintf("%s-%s", input.InfraID, rand.String(5)))
256+
250257
res, err := svc.CreateHostedZoneWithContext(ctx, &route53.CreateHostedZoneInput{
251-
CallerReference: aws.String(input.InfraID),
258+
CallerReference: callerRef,
252259
Name: aws.String(input.Name),
253260
HostedZoneConfig: &route53.HostedZoneConfig{
254261
PrivateZone: aws.Bool(true),

0 commit comments

Comments
 (0)