Skip to content

Instantly share code, notes, and snippets.

@russelldavies
Created July 26, 2020 12:03
Show Gist options
  • Save russelldavies/c36c4919c666d08d5d5af5e8b079e026 to your computer and use it in GitHub Desktop.
Save russelldavies/c36c4919c666d08d5d5af5e8b079e026 to your computer and use it in GitHub Desktop.
AWS Route 53 and API Gateway Dynamic DNS
---
swagger: "2.0"
info:
version: "2020-07-26T11:46:42Z"
title: "DynamicDNS"
host: "ddns.example.com"
schemes:
- "https"
paths:
/{zone_id}:
get:
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- name: "zone_id"
in: "path"
required: true
type: "string"
responses:
200:
description: "200 response"
schema:
$ref: "#/definitions/Empty"
x-amazon-apigateway-integration:
credentials: "arn:aws:iam::ACCOUNT_NUMBER:role/DynamicDNS"
uri: "arn:aws:apigateway:eu-west-1:route53:path/2013-04-01/hostedzone/{hosted_zone_id}/rrset/"
responses:
default:
statusCode: "200"
requestParameters:
integration.request.path.hosted_zone_id: "method.request.path.zone_id"
integration.request.header.Content-Type: "'application/xml'"
requestTemplates:
application/json: "<ChangeResourceRecordSetsRequest xmlns=\"https://route53.amazonaws.com/doc/2013-04-01/\"\
>\n <ChangeBatch>\n <Changes>\n <Change>\n \
\ <Action>UPSERT</Action>\n <ResourceRecordSet>\n\
\ <Name>$input.params('hostname')</Name>\n \
\ <Type>A</Type>\n <TTL>60</TTL>\n \
\ <ResourceRecords>\n <ResourceRecord>\n\
\ <Value>$context.identity.sourceIp</Value>\n\
\ </ResourceRecord>\n </ResourceRecords>\n\
\ </ResourceRecordSet>\n </Change>\n \
\ </Changes>\n </ChangeBatch>\n</ChangeResourceRecordSetsRequest>"
passthroughBehavior: "never"
httpMethod: "POST"
type: "aws"
definitions:
Empty:
type: "object"
title: "Empty Schema"
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"route53:ChangeResourceRecordSets"
],
"Resource": [
"arn:aws:route53:::hostedzone/*"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment