Skip to content

Commit

Permalink
Expose created_at and expired_at timestamps for Tailnet Keys.
Browse files Browse the repository at this point in the history
  • Loading branch information
CathalMullan authored and knyar committed Aug 17, 2023
1 parent e2961ac commit 90d52a2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tailscale/resource_tailnet_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
}
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

0 comments on commit 90d52a2

Please sign in to comment.