Shiyas
Shiyas

Reputation: 710

Check Cognito Domain prefix availability using SDK

Im creating Cognito userpool and Userpool Clientapp using SDK. before creating these I"ll have to check whether given domain prefixes available or not. How do I check domain prefix availability using sdk

Upvotes: 3

Views: 473

Answers (1)

Tomasz
Tomasz

Reputation: 717

I don't think there's an API for that in the SDK, but you can just query the DNS to check if an alias is available:

The domain is:

<custom-prefix>.auth.<region>.amazoncognito.com

If DNS responds with an A record it means that the name is not available.

For example, user-pool in Sydney region is not available:

$ dig A user-pool.auth.ap-southeast-2.amazoncognito.com

; <<>> DiG 9.10.6 <<>> A user-pool.auth.ap-southeast-2.amazoncognito.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18440
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;user-pool.auth.ap-southeast-2.amazoncognito.com. IN A

;; ANSWER SECTION:
user-pool.auth.ap-southeast-2.amazoncognito.com. 44 IN A 13.54.55.18
user-pool.auth.ap-southeast-2.amazoncognito.com. 44 IN A 3.24.31.222
user-pool.auth.ap-southeast-2.amazoncognito.com. 44 IN A 52.64.160.14

;; Query time: 183 msec
;; SERVER: 192.168.3.6#53(192.168.3.6)
;; WHEN: Mon May 18 17:37:55 AEST 2020
;; MSG SIZE  rcvd: 124

Upvotes: 3

Related Questions