Unable to get tags properly

The resource already exposes private_ip, public_ip and public_dns. Would those be sufficient to use?

Couldn’t the custom code part be loaded directly using the user-data?
Other options could be use of instance-metadata service so that the instance would write tags itself (requires instance profile and terraform skip additional tags).

Third option could be use of such an solution based on Route 53, Cloudwatch and Lambda.