AWS WAF Restrict request from specific domains

I want to create an AWS WAF with rules which will allow access to only specific domains like example1.com, example2.com to my cloudfront distribution. It can be done using AWS console, there I can specify header, referer, match Type, string to match etc but in terraform I am not able to find any waf resource which can do the things for me although it is available for IP set but I want to use domains. Please help on this.
I am referring below link for my requirement and want to achieve this using Terraform : https://aws.amazon.com/blogs/security/how-to-prevent-hotlinking-by-using-aws-waf-amazon-cloudfront-and-referer-checking/