diff --git a/tailscale/resource_tailnet_key.go b/tailscale/resource_tailnet_key.go index 9e91515c..6841ad78 100644 --- a/tailscale/resource_tailnet_key.go +++ b/tailscale/resource_tailnet_key.go @@ -56,6 +56,16 @@ func resourceTailnetKey() *schema.Resource { Description: "The expiry of the key in seconds", ForceNew: true, }, + "created_at": { + Type: schema.TypeString, + Description: "The creation timestamp of the key in RFC3339 format", + Computed: true, + }, + "expires_at": { + Type: schema.TypeString, + Description: "The expiry timestamp of the key in RFC3339 format", + Computed: true, + }, }, } } @@ -93,6 +103,14 @@ func resourceTailnetKeyCreate(ctx context.Context, d *schema.ResourceData, m int return diagnosticsError(err, "Failed to set key") } + if err = d.Set("created_at", key.Created.Format(time.RFC3339)); err != nil { + return diagnosticsError(err, "Failed to set created_at") + } + + if err = d.Set("expires_at", key.Expires.Format(time.RFC3339)); err != nil { + return diagnosticsError(err, "Failed to set expires_at") + } + return nil } @@ -134,5 +152,13 @@ func resourceTailnetKeyRead(ctx context.Context, d *schema.ResourceData, m inter return diagnosticsError(err, "failed to set ephemeral") } + if err = d.Set("created_at", key.Created.Format(time.RFC3339)); err != nil { + return diagnosticsError(err, "Failed to set created_at") + } + + if err = d.Set("expires_at", key.Expires.Format(time.RFC3339)); err != nil { + return diagnosticsError(err, "Failed to set expires_at") + } + return nil }