From 307d3bca8f88459a6ec3054141dc86cc728556b1 Mon Sep 17 00:00:00 2001 From: Pawel Date: Mon, 2 Sep 2024 23:39:35 -0700 Subject: [PATCH] fix id for project access token resource --- rollbar/resource_project_access_token.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/rollbar/resource_project_access_token.go b/rollbar/resource_project_access_token.go index d7750e34..a1f5407a 100644 --- a/rollbar/resource_project_access_token.go +++ b/rollbar/resource_project_access_token.go @@ -27,6 +27,7 @@ import ( "fmt" "strconv" "strings" + "time" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -156,15 +157,15 @@ func resourceProjectAccessTokenCreate(ctx context.Context, d *schema.ResourceDat return diag.FromErr(err) } - d.SetId(pat.AccessToken) - + d.SetId(strconv.FormatInt(time.Now().Unix(), 10)) + mustSet(d, "access_token", pat.AccessToken) return resourceProjectAccessTokenRead(ctx, d, m) } func resourceProjectAccessTokenRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics - accessToken := d.Id() + accessToken := d.Get("access_token").(string) projectID := d.Get("project_id").(int) l := log.With(). Str("accessToken", accessToken). @@ -195,7 +196,7 @@ func resourceProjectAccessTokenRead(ctx context.Context, d *schema.ResourceData, } func resourceProjectAccessTokenUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - accessToken := d.Id() + accessToken := d.Get("access_token").(string) projectID := d.Get("project_id").(int) size := d.Get("rate_limit_window_size").(int) count := d.Get("rate_limit_window_count").(int) @@ -220,7 +221,7 @@ func resourceProjectAccessTokenUpdate(ctx context.Context, d *schema.ResourceDat } func resourceProjectAccessTokenDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - accessToken := d.Id() + accessToken := d.Get("access_token").(string) projectID := d.Get("project_id").(int) l := log.With(). @@ -258,6 +259,7 @@ func resourceProjectAccessTokenImporter(_ context.Context, d *schema.ResourceDat Str("access_token", accessToken). Send() mustSet(d, "project_id", projectID) - d.SetId(accessToken) + mustSet(d, "access_token", accessToken) + d.SetId(strconv.FormatInt(time.Now().Unix(), 10)) return []*schema.ResourceData{d}, nil }