[aws-sdk-go-v2] Route53: Unable to create NS record for subdomain

0

Hi! I've been trying to do the following against Route53 with the v2 SDK for golang ...

  1. Create a Hosted Zone for a subdomain ("subdomain1.app.example.com")
  2. Add NS record for subdomain1 to the parent Hosted Zone ("app.example.com")

Creating the Hosted Zone for the subdomain is no problem but adding the NS record fails with the following error message:
InvalidInput: Invalid request: Expected exactly one of (Weight, Region, Failover, GeoLocation, or MultiValueAnswer), but found none in Change with (Action=UPSERT, Name=subdomain1.apps.example.com., Type=NS, SetIdentifier=Upsert NS record)

If I use the AWS Management Console to add the NS record, I do not need to specify any of the above (Weight, Region, Failover etc) and it works great. What is the proper way of adding an NS record to a Hosted Zone? Can't find any examples out there for NS records.
Here's the code snippet I'm working with:

params := route53.ChangeResourceRecordSetsInput{  
    ChangeBatch: &types.ChangeBatch{  
        Changes: \[]types.Change{  
            {  
                Action: types.ChangeActionUpsert,  
                ResourceRecordSet: &types.ResourceRecordSet{  
                    Name:            "subdomain1.app.example.com",  
                    Type:            types.RRTypeNs,  
                    ResourceRecords: \[]types.ResourceRecord{  
                        ... values goes here ...  
                    },  
                    TTL:             aws.Int64(300),  
                    SetIdentifier:   aws.String("Upsert NS record"),  
                },  
            },  
        },  
        Comment: aws.String("Upserting NS record in parent zone"),  
    },  
    HostedZoneId: aws.String("<id of parent zone app.example.com>"),  
}  
res, err := r.Route53.ChangeResourceRecordSets(ctx, &params)  

r.Route53 is the route53.Client ...

Any help would be much appreciated!

Edited by: kristofferahl on Jan 29, 2021 12:47 AM

질문됨 3년 전792회 조회
1개 답변
0

Solved it by removing this line: SetIdentifier: aws.String("Upsert NS record")
As NS records are a simple record type, you should not be specifying a SetIdentifier. My bad!

답변함 3년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠