Creating route 53 entry for ec2 based on varaible

I am trying to create a route53 entry for ec2 resource if the user supplies the zone name.
So the user calls my module to create one to n ec2 instances. User will provide a variable called ec2_instance variable with various ec2 properties. one such property is Zone name. In case Zone name is provided, i want to create a route 53 entry for the same using the ec2 resource i just created(ip and hostname)