async function changeRecord()

in source/aws-bootstrap-kit/lib/dns/delegation-record-handler/index.ts [79:117]


async function changeRecord(params: ChangeRecordParams) {
    const {
        route53,
        targetHostedZoneId,
        recordName,
        toDelegateNameServers,
        changeAction,
    } = params;

    const resourceRecords: ResourceRecords = toDelegateNameServers.map(
        (nameServer: string) => {
            return { Value: nameServer };
        }
    );

    try {
        const response = await route53
            .changeResourceRecordSets({
                HostedZoneId: targetHostedZoneId,
                ChangeBatch: {
                    Changes: [
                        {
                            Action: changeAction,
                            ResourceRecordSet: {
                                Name: recordName,
                                Type: "NS",
                                TTL: 300,
                                ResourceRecords: resourceRecords,
                            },
                        },
                    ],
                },
            })
            .promise();
        console.log("response = ", response.ChangeInfo.Id);
    } catch (e) {
        throw e;
    }
}