is it possible to extract the expiry date from certificate.pem file in terraform
Terraform itself does not have any built-in support for reading or writing TLS certificates, but this sort of thing can potentially be handled by providers.
hashicorp/tls provider has a data source
tls_certificate which seems like it might help you to achieve your goal. I believe the
not_after attribute of its result is effectively the certificate’s expiration time.