[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

asked 4 years ago928 views
1 Answer
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!

answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions