@@ -32,28 +32,22 @@ func ResourceSnapshot() *schema.Resource {
3232 },
3333 SchemaVersion : 0 ,
3434 Schema : map [string ]* schema.Schema {
35- "id " : {
35+ "name " : {
3636 Type : schema .TypeString ,
37+ Optional : true ,
3738 Computed : true ,
38- Description : "Unique identifier of the snapshot" ,
39+ Description : "Name of the snapshot" ,
3940 },
4041 "instance_id" : {
4142 Type : schema .TypeString ,
4243 Required : true ,
4344 Description : "The ID of the instance from which the snapshot was created" ,
4445 },
45- "name" : {
46- Type : schema .TypeString ,
47- Optional : true ,
48- Computed : true ,
49- Description : "Name of the snapshot" ,
50- },
5146 "instance_name" : {
5247 Type : schema .TypeString ,
5348 Computed : true ,
5449 Description : "Name of the instance from which the snapshot was created" ,
5550 },
56-
5751 "size" : {
5852 Type : schema .TypeInt ,
5953 Computed : true ,
@@ -134,7 +128,6 @@ func ResourceSnapshotRead(ctx context.Context, d *schema.ResourceData, m interfa
134128 if err != nil {
135129 return diag .FromErr (err )
136130 }
137- _ = d .Set ("id" , snapshot .ID )
138131 _ = d .Set ("instance_id" , zonal .NewIDString (zone , snapshot .InstanceID ))
139132 _ = d .Set ("name" , snapshot .Name )
140133 _ = d .Set ("instance_name" , snapshot .InstanceName )
@@ -164,19 +157,26 @@ func ResourceSnapshotUpdate(ctx context.Context, d *schema.ResourceData, m inter
164157 Region : region ,
165158 }
166159
160+ hasChanged := false
161+
167162 if d .HasChange ("name" ) {
168163 newName := types .ExpandOrGenerateString (d .Get ("name" ), "snapshot" )
169164 updateReq .Name = & newName
165+ hasChanged = true
170166 }
171167
172168 if d .HasChange ("expires_at" ) {
173169 updateReq .ExpiresAt = types .ExpandTimePtr (d .Get ("expires_at" ))
170+ hasChanged = true
174171 }
175172
176- _ , err = mongodbAPI .UpdateSnapshot (updateReq )
177- if err != nil {
178- return diag .FromErr (err )
173+ if hasChanged {
174+ _ , err = mongodbAPI .UpdateSnapshot (updateReq )
175+ if err != nil {
176+ return diag .FromErr (err )
177+ }
179178 }
179+
180180 instanceID := locality .ExpandID (d .Get ("instance_id" ).(string ))
181181
182182 _ , err = waitForSnapshot (ctx , mongodbAPI , region , instanceID , snapshotID , d .Timeout (schema .TimeoutUpdate ))
0 commit comments