diff --git a/newrelic/resource_helpers_synthetics.go b/newrelic/resource_helpers_synthetics.go index b50005cd84..51a9136bc8 100644 --- a/newrelic/resource_helpers_synthetics.go +++ b/newrelic/resource_helpers_synthetics.go @@ -3,6 +3,7 @@ package newrelic import ( "encoding/base64" "fmt" + "strconv" "strings" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -473,3 +474,23 @@ var syntheticsMonitorTagKeyToSchemaAttrMap = map[string]string{ "deviceOrientation": "device_orientation", "deviceType": "device_type", } + +func getCertCheckMonitorValuesFromEntityTags(tags []entities.EntityTag) (domain string, daysUntilExpiration int) { + domain = "" + daysUntilExpiration = 0 + + for _, tag := range tags { + + if tag.Key == "domain" { + domain = tag.Values[0] + } + + if tag.Key == "daysUntilExpiration" { + // Parse string to integer + days := tag.Values[0] + daysUntilExpiration, _ = strconv.Atoi(days) + } + } + + return domain, daysUntilExpiration +} diff --git a/newrelic/resource_newrelic_synthetics_cert_check_monitor.go b/newrelic/resource_newrelic_synthetics_cert_check_monitor.go index 4935469b53..2f25ee591c 100644 --- a/newrelic/resource_newrelic_synthetics_cert_check_monitor.go +++ b/newrelic/resource_newrelic_synthetics_cert_check_monitor.go @@ -220,6 +220,12 @@ func resourceNewRelicSyntheticsCertCheckMonitorRead(ctx context.Context, d *sche _ = d.Set("runtime_type_version", runtimeTypeVersion) } + domain, daysUntilExpiration := getCertCheckMonitorValuesFromEntityTags(entity.GetTags()) + if domain != "" && daysUntilExpiration != 0 { + _ = d.Set("domain", domain) + _ = d.Set("certificate_expiration", daysUntilExpiration) + } + } return diag.FromErr(err)