mindless-route53

low-mental-load API/CLI for AWS Route 53

Usage no npm install needed!

<script type="module">
  import mindlessRoute53 from 'https://cdn.skypack.dev/mindless-route53';
</script>

README

mindless-route53

CircleCI Coverage Status semantic-release Commitizen friendly npm version

low-mental-load API/CLI for AWS Route 53

For our purposes at least, looking up the hosted zone id when upserting a DNS record via script or CLI is a useless waste of time...it can be determined automatically from the DNS name for the record being upserted.

Node.js API

findHostedZones(options)

Finds the properties of the private and public hosted zones whose names are the deepest superdomain of a given DNSName.

options

DNSName (string, required)

the DNSName to search for, which can be either the exact name of the hosted zone or a subdomain.

Route53 (AWS.Route53, optional)

a Route53 client with your desired settings.

Returns

PrivateHostedZone, ?Zone:

The properties of the private hosted zone whose name is the deepest superdomain of the given DNSName, or null if no matching private hosted zone was found.

PublicHostedZone, ?Zone:

The properties of the public hosted zone whose name is the deepest superdomain of the given DNSName, or null if no matching public hosted zone was found.

findHostedZone(options)

Finds the properties of the hosted zone whose name is the deepest superdomain of a given DNSName.

options

DNSName (string, required)

the DNSName to search for, which can be

either the exact name of the hosted zone or a subdomain.

PrivateZone (boolean, optional)

whether to find a private zone

Route53 (AWS.Route53, optional)

a Route53 client with your desired

settings.

Returns

The properties of the hosted zone whose name is the deepest superdomain of the given DNSName.

findHostedZoneId(options)

Like findHostedZoneId(options), but just returns the zone id.

upsertRecordSet(options)

Upserts a single DNS record set.

options

ResourceRecordSet (ResourceRecordSet, optional)

a ResourceRecordSet as accepted by the AWS SDK for upsert (you may provide this or Name/Target/TTL)

Name (string, optional)

the name of the record (required if ResourceRecordSet isn't given)

Target (string | Array<string>, optional)

the IP address value(s) for an A record or DNS name value(s) for a CNAME record (required if ResourceRecordSet isn't given)

TTL (number, optional)

the time to live (required if ResourceRecordSet isn't given)

PrivateZone (boolean, optional)

whether to use the private hosted zone

HostedZone (Zone, optional)

information about the target hosted zone, as returned from findHostedZone or findHostedZones. You can speed up multiple calls to the same hosted zone by pre-fetching the zone info and providing it here.

Comment (string, optional)

a comment for the upsert

Route53 (AWS.Route53, optional)

a Route53 client with your desired

waitForChanges (boolean, optional)

defaults to true. If false, upsertRecordSet will return without waiting for confirmation that the Route53 record changes were successfully executed.

Returns

The result of the AWS.Route53.changeResourceRecordSets call.

upsertPublicAndPrivateRecords(options)

Upserts public and private DNS records for a single hostname.

options

Name (string, required)

the name of the record

TTL (number, required)

the time to live

PrivateTarget (string | Array<string>, required)

the IP address value(s) for an A record or DNS name value(s) for a CNAME record in the private zone.

PublicTarget (string | Array<string>, required)

the IP address value(s) for an A record or DNS name value(s) for a CNAME record in the public zone.

PrivateHostedZone (Zone, optional)

information about the private hosted zone, as returned from findHostedZones. You can speed up multiple calls to the same hosted zones by pre-fetching the zone info and providing it here.

PublicHostedZone (Zone, optional)

information about the public hosted zone, as returned from findHostedZones. You can speed up multiple calls to the same hosted zones by pre-fetching the zone info and providing it here.

Route53 (AWS.Route53, optional)

a Route53 client with your desired

waitForChanges (boolean, optional)

defaults to true. If false, upsertPublicAndPrivateRecords will return without waiting for confirmation that the Route53 record changes were successfully executed.

Returns

The result of the AWS.Route53.changeResourceRecordSets call.

CLI

You can use the mindless-route53 or mroute53 CLI command.

mroute53 upsert

upsert a resource record set

Usage

mroute53 upsert --name <DNS name> --target <target IP(s) or DNS name(s)> --ttl
<time to live> [--private] [--comment <comment>] [--region <AWS region>]

Options

--version      Show version number                                   [boolean]
--help         Show help                                             [boolean]
-n, --name     the DNS name for the record set                        [string]
-t, --target   the target IP address(es) for an A record or DNS name(s) for a
               CNAME record                                            [array]
--ttl          the time-to-live for the record                        [number]
--private      whether to use the private hosted zone
                                                    [boolean] [default: false]
-c, --comment  a comment for the change                               [string]
--region       the AWS region                                         [string]
-q, --quiet    suppress output                                       [boolean]
-v, --verbose  enable verbose output                                 [boolean]