2017-01-12 04:02:45 +08:00
## Configuration
2022-05-09 02:41:33 +08:00
To use this provider, add an entry to `creds.json` with `TYPE` set to `ROUTE53`
along with API credentials.
Example:
2017-01-12 04:02:45 +08:00
2023-03-03 05:17:27 +08:00
{% code title="creds.json" %}
2022-02-18 01:22:31 +08:00
```json
2017-01-12 04:02:45 +08:00
{
2022-05-09 02:41:33 +08:00
"r53_main": {
"TYPE": "ROUTE53",
"DelegationSet": "optional-delegation-set-id",
"KeyId": "your-aws-key",
"SecretKey": "your-aws-secret-key",
"Token": "optional-sts-token"
}
2017-01-12 04:02:45 +08:00
}
2022-02-18 01:22:31 +08:00
```
2023-03-03 05:17:27 +08:00
{% endcode %}
2017-01-12 04:02:45 +08:00
2022-05-09 02:41:33 +08:00
Alternatively you can also use environment variables. This is discouraged unless your environment provides them already.
2017-10-24 21:44:23 +08:00
2023-01-20 20:56:20 +08:00
```shell
2022-02-18 01:22:31 +08:00
export AWS_ACCESS_KEY_ID=XXXXXXXXX
export AWS_SECRET_ACCESS_KEY=YYYYYYYYY
export AWS_SESSION_TOKEN=ZZZZZZZZ
2017-10-24 21:44:23 +08:00
```
2017-01-12 04:02:45 +08:00
2023-03-03 05:17:27 +08:00
{% code title="creds.json" %}
2022-02-18 01:22:31 +08:00
```json
2018-09-05 21:07:28 +08:00
{
2022-05-09 02:41:33 +08:00
"r53_main": {
"KeyId": "$AWS_ACCESS_KEY_ID",
"SecretKey": "$AWS_SECRET_ACCESS_KEY",
"TYPE": "ROUTE53"
}
2018-09-05 21:07:28 +08:00
}
2022-02-18 01:22:31 +08:00
```
2023-03-03 05:17:27 +08:00
{% endcode %}
2018-09-05 21:07:28 +08:00
2022-05-09 02:41:33 +08:00
Alternatively, this provider supports [named profiles ](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html ). In that case export the following variable:
2019-12-04 23:17:28 +08:00
2023-01-20 20:56:20 +08:00
```shell
2022-02-18 01:22:31 +08:00
export AWS_PROFILE=ZZZZZZZZ
2019-12-04 23:17:28 +08:00
```
2022-11-01 06:09:43 +08:00
and provide a minimal entry in `creds.json` :
2021-09-23 23:12:55 +08:00
2022-05-09 02:41:33 +08:00
Example:
2021-09-23 23:12:55 +08:00
2023-03-03 05:17:27 +08:00
{% code title="creds.json" %}
2021-09-23 23:12:55 +08:00
```json
{
2022-05-09 02:41:33 +08:00
"r53_main": {
"TYPE": "ROUTE53"
}
2021-09-23 23:12:55 +08:00
}
```
2023-03-03 05:17:27 +08:00
{% endcode %}
2021-09-23 23:12:55 +08:00
2017-10-24 21:44:23 +08:00
You can find some other ways to authenticate to Route53 in the [go sdk configuration ](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html ).
## Metadata
2017-01-12 04:02:45 +08:00
This provider does not recognize any special metadata fields unique to route 53.
## Usage
2023-03-11 21:42:01 +08:00
An example configuration:
2017-01-12 04:02:45 +08:00
2023-03-11 21:42:01 +08:00
{% code title="dnsconfig.js" %}
2023-01-20 20:56:20 +08:00
```javascript
2022-05-09 02:41:33 +08:00
var REG_NONE = NewRegistrar("none");
var DSP_R53 = NewDnsProvider("r53_main");
2017-01-12 04:02:45 +08:00
2022-05-09 02:41:33 +08:00
D("example.tld", REG_NONE, DnsProvider(DSP_R53),
A("test", "1.2.3.4")
2017-01-12 04:02:45 +08:00
);
2022-02-18 01:22:31 +08:00
```
2023-03-11 21:42:01 +08:00
{% endcode %}
2017-01-12 04:02:45 +08:00
## Activation
2020-01-19 02:31:10 +08:00
DNSControl depends on a standard [AWS access key ](https://aws.amazon.com/developers/access-keys/ ) with permission to list, create and update hosted zones. If you do not have the permissions required you will receive the following error message `Check your credentials, your not authorized to perform actions on Route 53 AWS Service` .
You can apply the `AmazonRoute53FullAccess` policy however this includes access to many other areas of AWS. The minimum permissions required are as follows:
2022-02-18 01:22:31 +08:00
```json
2020-01-19 02:31:10 +08:00
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"route53:CreateHostedZone",
"route53:GetHostedZone",
"route53:ListHostedZones",
"route53:ChangeResourceRecordSets",
"route53:ListResourceRecordSets",
"route53:UpdateHostedZoneComment"
],
"Resource": "*"
}
]
}
2022-02-18 01:22:31 +08:00
```
2020-01-19 02:31:10 +08:00
If Route53 is also your registrar, you will need `route53domains:UpdateDomainNameservers` and `route53domains:GetDomainDetail` as well and possibly others.
2017-05-03 21:32:47 +08:00
## New domains
2019-02-20 01:30:39 +08:00
If a domain does not exist in your Route53 account, DNSControl will *not* automatically add it with the `push` command. You can do that either manually via the control panel, or via the command `dnscontrol create-domains` command.
## Delegation Sets
2020-01-19 02:31:10 +08:00
Creation of new delegation sets are not supported by this code. However, if you have a delegation set already created, ala:
2019-02-20 01:30:39 +08:00
2023-01-20 20:56:20 +08:00
```shell
2022-02-18 01:22:31 +08:00
aws route53 create-reusable-delegation-set --caller-reference "foo"
2019-02-20 01:30:39 +08:00
{
"Location": "https://route53.amazonaws.com/2013-04-01/delegationset/12312312123",
"DelegationSet": {
"Id": "/delegationset/12312312123",
"CallerReference": "foo",
"NameServers": [
"ns-1056.awsdns-04.org",
"ns-215.awsdns-26.com",
"ns-1686.awsdns-18.co.uk",
"ns-970.awsdns-57.net"
]
}
}
```
You can then reference the DelegationSet.Id in your `r53_main` block (with your other credentials) to have all created domains placed in that
delegation set. Note that you you only want the portion of the `Id` after the `/delegationset/` (the `12312312123` in the example above).
2020-01-19 02:31:10 +08:00
> Delegation sets only apply during `create-domains` at the moment. Further work needs to be done to have them apply during `push`.
2017-08-05 23:01:08 +08:00
## Caveats
2020-10-10 21:02:31 +08:00
### Route53 errors if it is not the DnsProvider
2017-08-05 23:01:08 +08:00
This code may not function properly if a domain has R53 as a Registrar
but not as a DnsProvider. The situation is described in
[PR#155 ](https://github.com/StackExchange/dnscontrol/pull/155 ).
2023-03-07 04:23:06 +08:00
In this situation you will see a message like: (This output assumes the `--full` flag)
2022-08-21 08:59:02 +08:00
2017-08-05 23:01:08 +08:00
2022-02-18 01:22:31 +08:00
```text
2017-12-23 21:03:05 +08:00
----- Registrar: r53_main
2017-08-05 23:01:08 +08:00
Error getting corrections: AccessDeniedException: User: arn:aws:iam::868399730840:user/dnscontrol is not authorized to perform: route53domains:GetDomainDetail
status code: 400, request id: 48b534a1-7902-11e7-afa6-a3fffd2ce139
Done. 1 corrections.
```
2022-05-09 02:41:33 +08:00
If this happens to you, we'd appreciate it if you could help us fix the code. In the meanwhile, you can give the account additional IAM permissions so that it can do DNS-related actions, or simply use `NewRegistrar(..., "NONE")` for now.
2017-12-23 21:03:05 +08:00
2020-10-10 21:02:31 +08:00
### Bug when converting new zones
You will see some weirdness if:
1. A CNAME was created using the web UI
2. The CNAME's target does NOT end with a dot.
2022-10-31 01:56:45 +08:00
What you will see: When DNSControl tries to update such records, R53
2020-10-10 21:02:31 +08:00
only updates the first one. For example if DNSControl is updating 3
such records, you will need to run `dnscontrol push` three times for
all three records to update. Each time DNSControl is sending three
modify requests but only the first is executed. After all such
records are modified by DNSControl, everything works as expected.
We believe this is a bug with R53.
This is only a problem for users converting old zones to DNSControl.
2023-01-20 20:56:20 +08:00
{% hint style="info" %}
**NOTE**: When converting zones that include such records, the `get-zones`
2020-10-10 21:02:31 +08:00
command will generate `CNAME()` records without the trailing dot. You
should manually add the dot. Run `dnscontrol preview` as normal to
check your work. However when you run `dnscontrol push` you'll find
you have to run it multiple times, each time one of those corrections
executes and the others do not. Once all such records are replaced
this problem disappears.
2023-01-20 20:56:20 +08:00
{% endhint %}
2020-10-10 21:02:31 +08:00
2023-01-10 07:05:41 +08:00
More info is available in [#891 ](https://github.com/StackExchange/dnscontrol/issues/891 ).
2020-10-10 21:02:31 +08:00
2017-12-23 21:03:05 +08:00
## Error messages
### Creds key mismatch
2023-01-20 20:56:20 +08:00
```shell
2022-02-18 01:22:31 +08:00
dnscontrol preview
2017-12-23 21:03:05 +08:00
Creating r53 dns provider: NoCredentialProviders: no valid providers in chain. Deprecated.
2022-10-28 04:17:19 +08:00
For verbose messaging see aws.Config.CredentialsChainVerboseErrors
2017-12-23 21:03:05 +08:00
```
2022-11-01 06:09:43 +08:00
This means that the `creds.json` entry isn't found. Either there is no entry, or the entry name doesn't match the first parameter in the `NewDnsProvider()` call. In the above example, note
2022-05-09 02:41:33 +08:00
that the string `r53_main` is specified in `NewDnsProvider("r53_main")` and that is the exact key used in the creds file above.
2017-12-23 21:03:05 +08:00
### Invalid KeyId
2023-01-20 20:56:20 +08:00
```shell
2022-02-18 01:22:31 +08:00
dnscontrol preview
2017-12-23 21:03:05 +08:00
Creating r53_main dns provider: InvalidClientTokenId: The security token included in the request is invalid.
2022-10-28 04:17:19 +08:00
status code: 403, request id: 8c006a24-e7df-11e7-9162-01963394e1df
2017-12-23 21:03:05 +08:00
```
This means the KeyId is unknown to AWS.
### Invalid SecretKey
2023-01-20 20:56:20 +08:00
```shell
2022-02-18 01:22:31 +08:00
dnscontrol preview
2017-12-23 21:03:05 +08:00
Creating r53_main dns provider: SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
2022-10-28 04:17:19 +08:00
status code: 403, request id: 9171d89a-e7df-11e7-8586-cbea3ea4e710
2017-12-23 21:03:05 +08:00
```
This means the SecretKey is incorrect. It may be a quoting issue.
2020-01-19 02:31:10 +08:00
### Incomplete Signature
2023-01-20 20:56:20 +08:00
```shell
2022-02-18 01:22:31 +08:00
dnscontrol preview
2020-01-19 02:31:10 +08:00
IncompleteSignature: 'ABCDEFGHIJKLMNOPQRST/20200118/us-east-1/route53/aws4_request' not a valid key=value pair (missing equal-sign) in Authorization header: 'AWS4-HMAC-SHA256 Credential= ABCDEFGHIJKLMNOPQRST/20200118/us-east-1/route53/aws4_request, SignedHeaders=host;x-amz-date, Signature=571c0b13205669a338f0fb9f351dc03c7016c8737c738081bc885c68378ad877'.
status code: 403, request id: 12a34b5c-d678-9e01-f2gh-3456i7jk89lm
```
This means a space is present in one or more of the credential values.