'AWS Route53 - Adding Simple Record

I am able to add "Weighted" A records for the AWS Route53 using the API, using [Weight: aws.Int64(weight)], it works great using the code below. But how to add "Simple" A record - I did not see an option for Simple?

    params := &route53.ChangeResourceRecordSetsInput{
    ChangeBatch: &route53.ChangeBatch{ // Required
        Changes: []*route53.Change{ // Required
            { // Required
                Action: aws.String("UPSERT"), // Required
                ResourceRecordSet: &route53.ResourceRecordSet{ // Required
                    Name: aws.String(name), // Required
                    Type: aws.String("A"),  // Required
                    ResourceRecords: []*route53.ResourceRecord{
                        { // Required
                            Value: aws.String(target), // Required
                        },
                    },
                    TTL: aws.Int64(TTL),
                    //Region: aws.String("us-east-1"),
                    Weight:        aws.Int64(weight),
                    SetIdentifier: aws.String("-"),
                },
            },
        },
        Comment: aws.String("Sample update."),
    },
    HostedZoneId: aws.String(zoneId), // Required
}


Solution 1:[1]

A 'Simple' record is just a phrasing inside the Web Console. Just leave the record without any Weight or Latency flag and it will be a standard DNS record inside Route53.

See the type ResourceRecordSet documentation, required fields are marked. The rest, like Weight are optional!

https://docs.aws.amazon.com/sdk-for-go/api/service/route53/#ResourceRecordSet

Pretty much the same as using the CLI (https://aws.amazon.com/premiumsupport/knowledge-center/simple-resource-record-route53-cli/), just port the same fields to the Go struct.

Solution 2:[2]

after a couple of hours of searching that lead nowhere, I found that using the aws-sdk-go-v2 works well for adding a simple record, trying to not add a weight or latency flag will only result in an error while using the version 1 of the SDK, so I did this and worked fine:

cfg, err := config.LoadDefaultConfig(context.TODO())
if err != nil {
    // handle error
    return err
}

client := route53.NewFromConfig(cfg)

params := &route53.ChangeResourceRecordSetsInput{
    ChangeBatch: &types.ChangeBatch{
        Changes: []types.Change{
            {
                Action: types.ChangeActionUpsert,
                ResourceRecordSet: &types.ResourceRecordSet{
                    Name: aws.String(name),
                    Type: types.RRTypeCname,
                    ResourceRecords: []types.ResourceRecord{
                        {
                            Value: aws.String(target),
                        },
                    },
                    TTL: aws.Int64(60),
                },
            },
        },
    },
    HostedZoneId: aws.String(zoneId),
}

output, err := client.ChangeResourceRecordSets(context.TODO(), params)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 f7o
Solution 2 4C1D0_B1N4R10