Skip to content

Commit

Permalink
Add forceNew for other field
Browse files Browse the repository at this point in the history
  • Loading branch information
tuteng committed Dec 25, 2023
1 parent a125447 commit f3febe9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
16 changes: 2 additions & 14 deletions cloud/resource_service_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func resourceServiceAccount() *schema.Resource {
return &schema.Resource{
CreateContext: resourceServiceAccountCreate,
ReadContext: resourceServiceAccountRead,
UpdateContext: resourceServiceAccountUpdate,
DeleteContext: resourceServiceAccountDelete,
Importer: &schema.ResourceImporter{
StateContext: func(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
Expand All @@ -35,11 +34,13 @@ func resourceServiceAccount() *schema.Resource {
Type: schema.TypeString,
Required: true,
Description: descriptions["organization"],
ForceNew: true,
},
"name": {
Type: schema.TypeString,
Optional: true,
Description: descriptions["name"],
ForceNew: true,
},
"admin": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -149,16 +150,3 @@ func resourceServiceAccountDelete(ctx context.Context, d *schema.ResourceData, m
_ = d.Set("name", "")
return nil
}

func resourceServiceAccountUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
err := resourceServiceAccountRead(ctx, d, meta)
if err.HasError() {
return diag.FromErr(fmt.Errorf("ERROR_UPDATE_SERVICE_ACCOUNT: %s", err[0].Summary))
}
namespace := d.Get("organization").(string)
name := d.Get("name").(string)
_ = d.Set("name", name)
_ = d.Set("organization", namespace)
d.SetId(fmt.Sprintf("%s/%s", namespace, name))
return resourceServiceAccountRead(ctx, d, meta)
}
12 changes: 11 additions & 1 deletion examples/serivceaccounts/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,20 @@ provider "streamnative" {

resource "streamnative_service_account" "test-admin-a" {
organization = "sndev"
name = "test-admin-a"
name = "test-admin-j"
admin = false
}

resource "streamnative_service_account" "test-admin-c" {
organization = "sndev"
name = "test-admin-n"
admin = true
}

output "service_account_id" {
value = streamnative_service_account.test-admin-a
}

output "service_account_id-2" {
value = streamnative_service_account.test-admin-c
}

0 comments on commit f3febe9

Please sign in to comment.