Skip to content

Commit

Permalink
Update route53 examples
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisguest75 committed Jun 21, 2023
1 parent 472b6b6 commit 756fa64
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion 33_awscli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ SSM [SSM.md](./SSM.md)

## Route53

Route 53 [Route53.md](./Route53.md)
Route 53 [Route53.md](./ROUTE_53.md)

## Lambda

Expand Down
38 changes: 27 additions & 11 deletions 33_awscli/Route53.md → 33_awscli/ROUTE_53.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
# Route53
# ROUTE53

```sh
# get hosted zones public and private for a domain
aws route53 list-hosted-zones-by-name --dns-name "mydomain.com."
Demonstrate some common tasks with DNS in route53.

## Hosted Zones

aws route53 list-hosted-zones-by-name --dns-name "mydomain.com." --query "HostedZones[*].{name: Name, id: Id }" | jq -r ".[].id"
Get the hosted zones for an account.

```sh
aws route53 list-hosted-zones-by-name | jq -c ".HostedZones[] | [.Name, .Id, .ResourceRecordSetCount]"

# without jq
aws route53 list-hosted-zones-by-name --dns-name "mydomain.com." --query "HostedZones[*].{id: Id }" --output text
aws route53 list-hosted-zones-by-name --dns-name "mydomain.com." --query "HostedZones[*].{id: Id, name: Name, ResourceRecordSetCount: ResourceRecordSetCount }" --output table
```

## Record Sets

```sh
aws route53 list-resource-record-sets --hosted-zone-id "/hostedzone/id"

# format as table
aws route53 list-resource-record-sets --hosted-zone-id "/hostedzone/id" --query 'ResourceRecordSets[*].{name:Name, type:Type, TTL: TTL}' --output table
aws route53 list-resource-record-sets --hosted-zone-id "/hostedzone/id" --query 'ResourceRecordSets[*].{name:Name, type:Type, TTL: TTL, PTR: ResourceRecords[0].Value, Target: AliasTarget.DNSName}' --output table

# get the record as json for specfic entry
aws route53 list-resource-record-sets --hosted-zone-id "/hostedzone/id" --query "ResourceRecordSets[?Name == 'myrecord.mydomain.com']"

# list records (myrecord.mydomain.com)
while IFS=, read -r hostedid
do
echo "${hostedid}"
aws route53 list-resource-record-sets --hosted-zone-id "${hostedid}" | jq ".ResourceRecordSets[].Name" | grep myrecord
aws route53 list-resource-record-sets --hosted-zone-id "${hostedid}" | jq ".ResourceRecordSets[].Name"
done < <(aws route53 list-hosted-zones-by-name --dns-name "mydomain.com." --query "HostedZones[*].{id: Id }" --output text)

# get the record as json
aws route53 list-resource-record-sets --hosted-zone-id "/hostedzone/id" --query "ResourceRecordSets[?Name == 'myrecord.mydomain.com']"
```

## Modification

The record will need to look like this to remove it [change-resource-record-sets](https://docs.aws.amazon.com/cli/latest/reference/route53/change-resource-record-sets.html)

```json
Expand Down Expand Up @@ -48,9 +63,10 @@ The record will need to look like this to remove it [change-resource-record-sets
```

```sh
#
# modify
aws route53 change-resource-record-sets --cli-input-json file://record.json

# check stastus
aws route53 get-change --id /change/C3RJ6YPQRNEZJA
```

0 comments on commit 756fa64

Please sign in to comment.