github.com/StackExchange/dnscontrol/v4@v4.11.0/documentation/provider/route53.md (about) 1 ## Configuration 2 3 To use this provider, add an entry to `creds.json` with `TYPE` set to `ROUTE53` 4 along with API credentials. 5 6 Example: 7 8 {% code title="creds.json" %} 9 ```json 10 { 11 "r53_main": { 12 "TYPE": "ROUTE53", 13 "DelegationSet": "optional-delegation-set-id", 14 "KeyId": "your-aws-key", 15 "SecretKey": "your-aws-secret-key", 16 "Token": "optional-sts-token" 17 } 18 } 19 ``` 20 {% endcode %} 21 22 Alternatively you can also use environment variables. This is discouraged unless your environment provides them already. 23 24 ```shell 25 export AWS_ACCESS_KEY_ID=XXXXXXXXX 26 export AWS_SECRET_ACCESS_KEY=YYYYYYYYY 27 export AWS_SESSION_TOKEN=ZZZZZZZZ 28 ``` 29 30 {% code title="creds.json" %} 31 ```json 32 { 33 "r53_main": { 34 "TYPE": "ROUTE53", 35 "KeyId": "$AWS_ACCESS_KEY_ID", 36 "SecretKey": "$AWS_SECRET_ACCESS_KEY" 37 } 38 } 39 ``` 40 {% endcode %} 41 42 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: 43 44 ```shell 45 export AWS_PROFILE=ZZZZZZZZ 46 ``` 47 48 and provide a minimal entry in `creds.json`: 49 50 Example: 51 52 {% code title="creds.json" %} 53 ```json 54 { 55 "r53_main": { 56 "TYPE": "ROUTE53" 57 } 58 } 59 ``` 60 {% endcode %} 61 62 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). 63 64 ## Metadata 65 This provider does not recognize any special metadata fields unique to route 53. 66 67 ## Usage 68 An example configuration: 69 70 {% code title="dnsconfig.js" %} 71 ```javascript 72 var REG_NONE = NewRegistrar("none"); 73 var DSP_R53 = NewDnsProvider("r53_main"); 74 75 D("example.com", REG_NONE, DnsProvider(DSP_R53), 76 A("test", "1.2.3.4"), 77 END); 78 ``` 79 {% endcode %} 80 81 ## Split horizon 82 83 This provider supports split horizons using the [`R53_ZONE()`](../language-reference/record-modifiers/R53_ZONE.md) domain function. 84 85 In this example the domain `testzone.net` appears in the same account twice, 86 each with different zone IDs specified using [`R53_ZONE()`](../language-reference/record-modifiers/R53_ZONE.md). 87 88 {% code title="dnsconfig.js" %} 89 ```javascript 90 var REG_NONE = NewRegistrar("none"); 91 var DSP_R53 = NewDnsProvider("r53_main"); 92 93 D("testzone.net!private", REG_NONE, 94 DnsProvider(DSP_R53), 95 R53_ZONE("Z111111111JCCCP1V7UW"), 96 TXT("me", "private testzone.net"), 97 END); 98 99 D("testzone.net!public", REG_NONE, 100 DnsProvider(DSP_R53), 101 R53_ZONE("Z222222222INNG98SHJQ2"), 102 TXT("me", "public testzone.net"), 103 END); 104 ``` 105 {% endcode %} 106 107 ## Activation 108 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`. 109 110 You can apply the `AmazonRoute53FullAccess` policy however this includes access to many other areas of AWS. The minimum permissions required are as follows: 111 112 ```json 113 { 114 "Version": "2012-10-17", 115 "Statement": [ 116 { 117 "Effect": "Allow", 118 "Action": [ 119 "route53:CreateHostedZone", 120 "route53:GetHostedZone", 121 "route53:ListHostedZones", 122 "route53:ChangeResourceRecordSets", 123 "route53:ListResourceRecordSets", 124 "route53:UpdateHostedZoneComment" 125 ], 126 "Resource": "*" 127 } 128 ] 129 } 130 ``` 131 132 If Route53 is also your registrar, you will need `route53domains:UpdateDomainNameservers` and `route53domains:GetDomainDetail` as well and possibly others. 133 134 ## New domains 135 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. 136 137 ## Delegation Sets 138 Creation of new delegation sets are not supported by this code. However, if you have a delegation set already created, ala: 139 140 ```shell 141 aws route53 create-reusable-delegation-set --caller-reference "foo" 142 { 143 "Location": "https://route53.amazonaws.com/2013-04-01/delegationset/12312312123", 144 "DelegationSet": { 145 "Id": "/delegationset/12312312123", 146 "CallerReference": "foo", 147 "NameServers": [ 148 "ns-1056.awsdns-04.org", 149 "ns-215.awsdns-26.com", 150 "ns-1686.awsdns-18.co.uk", 151 "ns-970.awsdns-57.net" 152 ] 153 } 154 } 155 ``` 156 157 You can then reference the DelegationSet.Id in your `r53_main` block (with your other credentials) to have all created domains placed in that 158 delegation set. Note that you you only want the portion of the `Id` after the `/delegationset/` (the `12312312123` in the example above). 159 160 > Delegation sets only apply during `create-domains` at the moment. Further work needs to be done to have them apply during `push`. 161 162 ## Caveats 163 164 ### Route53 errors if it is not the DnsProvider 165 166 This code may not function properly if a domain has R53 as a Registrar 167 but not as a DnsProvider. The situation is described in 168 [PR#155](https://github.com/StackExchange/dnscontrol/pull/155). 169 170 In this situation you will see a message like: (This output assumes the `--full` flag) 171 172 173 ```text 174 ----- Registrar: r53_main 175 Error getting corrections: AccessDeniedException: User: arn:aws:iam::868399730840:user/dnscontrol is not authorized to perform: route53domains:GetDomainDetail 176 status code: 400, request id: 48b534a1-7902-11e7-afa6-a3fffd2ce139 177 Done. 1 corrections. 178 ``` 179 180 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. 181 182 ### Bug when converting new zones 183 184 You will see some weirdness if: 185 186 1. A CNAME was created using the web UI 187 2. The CNAME's target does NOT end with a dot. 188 189 What you will see: When DNSControl tries to update such records, R53 190 only updates the first one. For example if DNSControl is updating 3 191 such records, you will need to run `dnscontrol push` three times for 192 all three records to update. Each time DNSControl is sending three 193 modify requests but only the first is executed. After all such 194 records are modified by DNSControl, everything works as expected. 195 196 We believe this is a bug with R53. 197 198 This is only a problem for users converting old zones to DNSControl. 199 200 {% hint style="info" %} 201 **NOTE**: When converting zones that include such records, the `get-zones` 202 command will generate `CNAME()` records without the trailing dot. You 203 should manually add the dot. Run `dnscontrol preview` as normal to 204 check your work. However when you run `dnscontrol push` you'll find 205 you have to run it multiple times, each time one of those corrections 206 executes and the others do not. Once all such records are replaced 207 this problem disappears. 208 {% endhint %} 209 210 More info is available in [#891](https://github.com/StackExchange/dnscontrol/issues/891). 211 212 213 ## Error messages 214 215 ### Creds key mismatch 216 217 ```shell 218 dnscontrol preview 219 Creating r53 dns provider: NoCredentialProviders: no valid providers in chain. Deprecated. 220 For verbose messaging see aws.Config.CredentialsChainVerboseErrors 221 ``` 222 223 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 224 that the string `r53_main` is specified in `NewDnsProvider("r53_main")` and that is the exact key used in the creds file above. 225 226 ### Invalid KeyId 227 228 ```shell 229 dnscontrol preview 230 Creating r53_main dns provider: InvalidClientTokenId: The security token included in the request is invalid. 231 status code: 403, request id: 8c006a24-e7df-11e7-9162-01963394e1df 232 ``` 233 234 This means the KeyId is unknown to AWS. 235 236 ### Invalid SecretKey 237 238 ```shell 239 dnscontrol preview 240 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. 241 status code: 403, request id: 9171d89a-e7df-11e7-8586-cbea3ea4e710 242 ``` 243 244 This means the SecretKey is incorrect. It may be a quoting issue. 245 246 ### Incomplete Signature 247 248 ```shell 249 dnscontrol preview 250 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'. 251 status code: 403, request id: 12a34b5c-d678-9e01-f2gh-3456i7jk89lm 252 ``` 253 254 This means a space is present in one or more of the credential values.