@@ -32,28 +32,22 @@ func ResourceSnapshot() *schema.Resource {
32
32
},
33
33
SchemaVersion : 0 ,
34
34
Schema : map [string ]* schema.Schema {
35
- "id " : {
35
+ "name " : {
36
36
Type : schema .TypeString ,
37
+ Optional : true ,
37
38
Computed : true ,
38
- Description : "Unique identifier of the snapshot" ,
39
+ Description : "Name of the snapshot" ,
39
40
},
40
41
"instance_id" : {
41
42
Type : schema .TypeString ,
42
43
Required : true ,
43
44
Description : "The ID of the instance from which the snapshot was created" ,
44
45
},
45
- "name" : {
46
- Type : schema .TypeString ,
47
- Optional : true ,
48
- Computed : true ,
49
- Description : "Name of the snapshot" ,
50
- },
51
46
"instance_name" : {
52
47
Type : schema .TypeString ,
53
48
Computed : true ,
54
49
Description : "Name of the instance from which the snapshot was created" ,
55
50
},
56
-
57
51
"size" : {
58
52
Type : schema .TypeInt ,
59
53
Computed : true ,
@@ -134,7 +128,6 @@ func ResourceSnapshotRead(ctx context.Context, d *schema.ResourceData, m interfa
134
128
if err != nil {
135
129
return diag .FromErr (err )
136
130
}
137
- _ = d .Set ("id" , snapshot .ID )
138
131
_ = d .Set ("instance_id" , zonal .NewIDString (zone , snapshot .InstanceID ))
139
132
_ = d .Set ("name" , snapshot .Name )
140
133
_ = d .Set ("instance_name" , snapshot .InstanceName )
@@ -164,19 +157,26 @@ func ResourceSnapshotUpdate(ctx context.Context, d *schema.ResourceData, m inter
164
157
Region : region ,
165
158
}
166
159
160
+ hasChanged := false
161
+
167
162
if d .HasChange ("name" ) {
168
163
newName := types .ExpandOrGenerateString (d .Get ("name" ), "snapshot" )
169
164
updateReq .Name = & newName
165
+ hasChanged = true
170
166
}
171
167
172
168
if d .HasChange ("expires_at" ) {
173
169
updateReq .ExpiresAt = types .ExpandTimePtr (d .Get ("expires_at" ))
170
+ hasChanged = true
174
171
}
175
172
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
+ }
179
178
}
179
+
180
180
instanceID := locality .ExpandID (d .Get ("instance_id" ).(string ))
181
181
182
182
_ , err = waitForSnapshot (ctx , mongodbAPI , region , instanceID , snapshotID , d .Timeout (schema .TimeoutUpdate ))
0 commit comments