Skip to content

Commit 30ede80

Browse files
martinstibbeZuhairahmedjwilliams-mongozach-carr
authored
Release staging v.1.9.0 (#1143)
* INTMDB-767: Update TF docs to lower case for frequency types (#1131) * Update cloud_backup_schedule.html.markdown * Update cloud_backup_schedule.html.markdown * Update resource_mongodbatlas_cloud_backup_schedule_test.go * Removing disk_size_gb examples (#1133) * removing disk_size_gb examples Since we have stopped including this optional disk_size_gb parameter in current cluster examples, went back to clean up previous examples as well * Delete main.tf * Create main.tf * Update main.tf * Update main.tf * Update main.tf * Update main.tf * Update main.tf * Update main.tf * Update atlas_cluster.tf * Update atlas.tf * Update cluster.tf * Update atlas-cluster.tf * Update atlas-cluster.tf * Update atlas-cluster.tf * Update atlas-cluster.tf * Update atlas-cluster.tf * Update atlas-cluster.tf * Update atlas-cluster.tf * Update atlas-cluster.tf * Update atlas-cluster.tf * Update atlas-cluster.tf * Update atlas-cluster.tf * Update atlas-cluster.tf * Update atlas-cluster.tf * Update atlas-cluster.tf * DOCSP-28948: addressing user feedback on search index resource docs (#1137) * INTMDB-587: New Feature: Backup Compliance Policy Support (#1127) * Add support for mongodbatlas_backup_compliance_policy * Update SDK * Preliminary Documentation * Add tests for BackupCompliancePolicy * Update website/docs/r/backup_compliance_policy.html.markdown Co-authored-by: Zuhair Ahmed <[email protected]> * Update mongodbatlas/resource_mongodbatlas_backup_compliance_policy.go Co-authored-by: Zuhair Ahmed <[email protected]> * Update website/docs/d/backup_compliance_policy.html.markdown Co-authored-by: Zuhair Ahmed <[email protected]> * Update website/docs/d/backup_compliance_policy.html.markdown Co-authored-by: Zuhair Ahmed <[email protected]> * Update website/docs/r/backup_compliance_policy.html.markdown Co-authored-by: Zuhair Ahmed <[email protected]> * Update website/docs/d/backup_compliance_policy.html.markdown Co-authored-by: Zuhair Ahmed <[email protected]> * Update website/docs/r/backup_compliance_policy.html.markdown Co-authored-by: Zuhair Ahmed <[email protected]> * Update website/docs/r/backup_compliance_policy.html.markdown Co-authored-by: Zuhair Ahmed <[email protected]> * Update website/docs/d/backup_compliance_policy.html.markdown Co-authored-by: Zuhair Ahmed <[email protected]> * Update website/docs/d/backup_compliance_policy.html.markdown Co-authored-by: Zuhair Ahmed <[email protected]> * Update Email * Trim line length * Update SDK * doc updates to related resources * Update website/docs/r/advanced_cluster.html.markdown * Update website/docs/r/advanced_cluster.html.markdown * Update website/docs/r/advanced_cluster.html.markdown * Update website/docs/r/backup_compliance_policy.html.markdown * Update website/docs/r/cloud_backup_schedule.html.markdown * Update website/docs/r/cloud_backup_snapshot.html.markdown * Update website/docs/r/cluster.html.markdown * Update website/docs/r/project.html.markdown * Update website/docs/r/backup_compliance_policy.html.markdown * Update website/docs/d/backup_compliance_policy.html.markdown * Update website/docs/r/backup_compliance_policy.html.markdown * cluster termination note * Restructure parameters * Remove unused expandScheduledPolicyItems Update Docs tests * Update examples * Update docs with requested changes * Update docs * Remove reference_minute_of_hour parameter not used in backup policy * Update backup_compliance_policy.html.markdown * Update backup_compliance_policy.html.markdown * Docs updates * Lowercase lint error * Update website/docs/r/backup_compliance_policy.html.markdown * Update website/docs/r/cluster.html.markdown * Update website/docs/r/backup_compliance_policy.html.markdown * Update website/docs/r/backup_compliance_policy.html.markdown * Update website/docs/r/advanced_cluster.html.markdown * Update website/docs/r/cloud_backup_schedule.html.markdown * Update website/docs/r/cloud_backup_snapshot.html.markdown * Update website/docs/r/advanced_cluster.html.markdown * Update website/docs/r/cloud_backup_snapshot.html.markdown * Update website/docs/r/cluster.html.markdown * Update website/docs/r/project.html.markdown * Update website/docs/d/backup_compliance_policy.html.markdown * Update website/docs/d/backup_compliance_policy.html.markdown Co-authored-by: zach-carr <[email protected]> * Update website/docs/r/backup_compliance_policy.html.markdown Co-authored-by: zach-carr <[email protected]> * Update website/docs/d/backup_compliance_policy.html.markdown Co-authored-by: zach-carr <[email protected]> * Update website/docs/d/backup_compliance_policy.html.markdown Co-authored-by: zach-carr <[email protected]> * Update website/docs/d/backup_compliance_policy.html.markdown Co-authored-by: zach-carr <[email protected]> * Update website/docs/r/advanced_cluster.html.markdown Co-authored-by: zach-carr <[email protected]> * Update website/docs/r/advanced_cluster.html.markdown Co-authored-by: zach-carr <[email protected]> * Update website/docs/r/advanced_cluster.html.markdown Co-authored-by: zach-carr <[email protected]> * Update website/docs/r/backup_compliance_policy.html.markdown Co-authored-by: zach-carr <[email protected]> * Update website/docs/r/backup_compliance_policy.html.markdown Co-authored-by: zach-carr <[email protected]> * Update website/docs/r/cluster.html.markdown * Update website/docs/r/cloud_backup_snapshot.html.markdown * Update website/docs/r/cloud_backup_schedule.html.markdown * Update mongodbatlas/resource_mongodbatlas_backup_compliance_policy_test.go Co-authored-by: zach-carr <[email protected]> * Update website/docs/r/backup_compliance_policy.html.markdown * Update website/docs/r/backup_compliance_policy.html.markdown --------- Co-authored-by: Zuhair Ahmed <[email protected]> Co-authored-by: zach-carr <[email protected]> * Update resource_mongodbatlas_project.go to detect null boolean values (#1145) * Update resource_mongodbatlas_project.go * Update resource_mongodbatlas_project.go * Update resource_mongodbatlas_project.go --------- Co-authored-by: Zuhair Ahmed <[email protected]> Co-authored-by: John Williams <[email protected]> Co-authored-by: zach-carr <[email protected]>
1 parent 6f5f686 commit 30ede80

32 files changed

+1596
-62
lines changed

examples/aws-privatelink-endpoint/cluster/atlas-cluster.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ resource "mongodbatlas_cluster" "aws_private_connection" {
2020
provider_instance_size_name = "M10"
2121

2222
depends_on = [mongodbatlas_privatelink_endpoint_service.pe_east_service]
23-
}
23+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/mwielbut/pointy v1.1.0
1414
github.com/spf13/cast v1.5.0
1515
github.com/zclconf/go-cty v1.13.1
16-
go.mongodb.org/atlas v0.24.0
16+
go.mongodb.org/atlas v0.25.0
1717
go.mongodb.org/realm v0.1.0
1818
golang.org/x/exp v0.0.0-20221208152030-732eee02a75a
1919
)

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,8 @@ github.com/zclconf/go-cty v1.13.1 h1:0a6bRwuiSHtAmqCqNOE+c2oHgepv0ctoxU4FUe43kwc
482482
github.com/zclconf/go-cty v1.13.1/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0=
483483
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8=
484484
go.mongodb.org/atlas v0.12.0/go.mod h1:wVCnHcm/7/IfTjEB6K8K35PLG70yGz8BdkRwX0oK9/M=
485-
go.mongodb.org/atlas v0.23.1 h1:nQjqIzAizf4uaD7lECpVF6kldnZvJnmCTDrqkS4hVyc=
486-
go.mongodb.org/atlas v0.23.1/go.mod h1:XTjsxWgoOSwaZrQUvhTEuwjymxnF0r12RPibZuW1Uts=
487-
go.mongodb.org/atlas v0.24.0 h1:n9ibqbxrtFOInLD6MhNupK9GKFmaH08rLwU5qnr4mpA=
488-
go.mongodb.org/atlas v0.24.0/go.mod h1:L4BKwVx/OeEhOVjCSdgo90KJm4469iv7ZLzQms/EPTg=
485+
go.mongodb.org/atlas v0.25.0 h1:K+b9iU8TXuRByTUnL+wEwj+wx3L0UDUgXNDX/a7B0gU=
486+
go.mongodb.org/atlas v0.25.0/go.mod h1:L4BKwVx/OeEhOVjCSdgo90KJm4469iv7ZLzQms/EPTg=
489487
go.mongodb.org/realm v0.1.0 h1:zJiXyLaZrznQ+Pz947ziSrDKUep39DO4SfA0Fzx8M4M=
490488
go.mongodb.org/realm v0.1.0/go.mod h1:4Vj6iy+Puo1TDERcoh4XZ+pjtwbOzPpzqy3Cwe8ZmDM=
491489
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
package mongodbatlas
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"net/http"
7+
8+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
9+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
10+
matlas "go.mongodb.org/atlas/mongodbatlas"
11+
)
12+
13+
func dataSourceMongoDBAtlasBackupCompliancePolicy() *schema.Resource {
14+
return &schema.Resource{
15+
ReadContext: dataSourceMongoDBAtlasBackupCompliancePolicyRead,
16+
Schema: map[string]*schema.Schema{
17+
"project_id": {
18+
Type: schema.TypeString,
19+
Required: true,
20+
},
21+
"authorized_email": {
22+
Type: schema.TypeString,
23+
Computed: true,
24+
},
25+
"copy_protection_enabled": {
26+
Type: schema.TypeBool,
27+
Computed: true,
28+
},
29+
"encryption_at_rest_enabled": {
30+
Type: schema.TypeBool,
31+
Computed: true,
32+
},
33+
"on_demand_policy_item": {
34+
Type: schema.TypeList,
35+
MaxItems: 1,
36+
Optional: true,
37+
Elem: &schema.Resource{
38+
Schema: map[string]*schema.Schema{
39+
"id": {
40+
Type: schema.TypeString,
41+
Computed: true,
42+
},
43+
"frequency_interval": {
44+
Type: schema.TypeInt,
45+
Computed: true,
46+
},
47+
"frequency_type": {
48+
Type: schema.TypeString,
49+
Computed: true,
50+
},
51+
"retention_unit": {
52+
Type: schema.TypeString,
53+
Computed: true,
54+
},
55+
"retention_value": {
56+
Type: schema.TypeInt,
57+
Computed: true,
58+
},
59+
},
60+
},
61+
},
62+
"pit_enabled": {
63+
Type: schema.TypeBool,
64+
Computed: true,
65+
},
66+
"state": {
67+
Type: schema.TypeString,
68+
Computed: true,
69+
},
70+
"updated_date": {
71+
Type: schema.TypeString,
72+
Computed: true,
73+
},
74+
"updated_user": {
75+
Type: schema.TypeString,
76+
Computed: true,
77+
},
78+
"restore_window_days": {
79+
Type: schema.TypeInt,
80+
Computed: true,
81+
},
82+
"policy_item_hourly": {
83+
Type: schema.TypeList,
84+
MaxItems: 1,
85+
Optional: true,
86+
Elem: &schema.Resource{
87+
Schema: map[string]*schema.Schema{
88+
"id": {
89+
Type: schema.TypeString,
90+
Computed: true,
91+
},
92+
"frequency_type": {
93+
Type: schema.TypeString,
94+
Computed: true,
95+
},
96+
"frequency_interval": {
97+
Type: schema.TypeInt,
98+
Required: true,
99+
},
100+
"retention_value": {
101+
Type: schema.TypeInt,
102+
Required: true,
103+
},
104+
"retention_unit": {
105+
Type: schema.TypeString,
106+
Required: true,
107+
},
108+
},
109+
},
110+
},
111+
"policy_item_daily": {
112+
Type: schema.TypeList,
113+
MaxItems: 1,
114+
Optional: true,
115+
Elem: &schema.Resource{
116+
Schema: map[string]*schema.Schema{
117+
"id": {
118+
Type: schema.TypeString,
119+
Computed: true,
120+
},
121+
"frequency_type": {
122+
Type: schema.TypeString,
123+
Computed: true,
124+
},
125+
"frequency_interval": {
126+
Type: schema.TypeInt,
127+
Required: true,
128+
},
129+
"retention_unit": {
130+
Type: schema.TypeString,
131+
Required: true,
132+
},
133+
"retention_value": {
134+
Type: schema.TypeInt,
135+
Required: true,
136+
},
137+
},
138+
},
139+
},
140+
"policy_item_weekly": {
141+
Type: schema.TypeList,
142+
Optional: true,
143+
Elem: &schema.Resource{
144+
Schema: map[string]*schema.Schema{
145+
"id": {
146+
Type: schema.TypeString,
147+
Computed: true,
148+
},
149+
"frequency_type": {
150+
Type: schema.TypeString,
151+
Computed: true,
152+
},
153+
"frequency_interval": {
154+
Type: schema.TypeInt,
155+
Required: true,
156+
},
157+
"retention_unit": {
158+
Type: schema.TypeString,
159+
Required: true,
160+
},
161+
"retention_value": {
162+
Type: schema.TypeInt,
163+
Required: true,
164+
},
165+
},
166+
},
167+
},
168+
"policy_item_monthly": {
169+
Type: schema.TypeList,
170+
Optional: true,
171+
Elem: &schema.Resource{
172+
Schema: map[string]*schema.Schema{
173+
"id": {
174+
Type: schema.TypeString,
175+
Computed: true,
176+
},
177+
"frequency_type": {
178+
Type: schema.TypeString,
179+
Computed: true,
180+
},
181+
"frequency_interval": {
182+
Type: schema.TypeInt,
183+
Required: true,
184+
},
185+
"retention_unit": {
186+
Type: schema.TypeString,
187+
Required: true,
188+
},
189+
"retention_value": {
190+
Type: schema.TypeInt,
191+
Required: true,
192+
},
193+
},
194+
},
195+
},
196+
},
197+
}
198+
}
199+
200+
func dataSourceMongoDBAtlasBackupCompliancePolicyRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
201+
conn := meta.(*MongoDBClient).Atlas
202+
203+
projectID := d.Get("project_id").(string)
204+
205+
backupPolicy, resp, err := conn.BackupCompliancePolicy.Get(ctx, projectID)
206+
if resp != nil && resp.StatusCode == http.StatusNotFound || backupPolicy.ProjectID == "" {
207+
return nil
208+
}
209+
if err != nil {
210+
return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicyRead, projectID, err))
211+
}
212+
213+
if err := d.Set("authorized_email", backupPolicy.AuthorizedEmail); err != nil {
214+
return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "authorized_email", projectID, err))
215+
}
216+
217+
if err := d.Set("state", backupPolicy.State); err != nil {
218+
return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "state", projectID, err))
219+
}
220+
221+
if err := d.Set("restore_window_days", backupPolicy.RestoreWindowDays); err != nil {
222+
return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "restore_window_days", projectID, err))
223+
}
224+
225+
if err := d.Set("pit_enabled", backupPolicy.PitEnabled); err != nil {
226+
return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "pit_enabled", projectID, err))
227+
}
228+
229+
if err := d.Set("copy_protection_enabled", backupPolicy.CopyProtectionEnabled); err != nil {
230+
return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "copy_protection_enabled", projectID, err))
231+
}
232+
233+
if err := d.Set("encryption_at_rest_enabled", backupPolicy.EncryptionAtRestEnabled); err != nil {
234+
return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "encryption_at_rest_enabled", projectID, err))
235+
}
236+
237+
if err := d.Set("updated_date", backupPolicy.UpdatedDate); err != nil {
238+
return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "updated_date", projectID, err))
239+
}
240+
241+
if err := d.Set("updated_user", backupPolicy.UpdatedUser); err != nil {
242+
return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "updated_user", projectID, err))
243+
}
244+
245+
if err := d.Set("on_demand_policy_item", flattenOnDemandBackupPolicyItem(backupPolicy.OnDemandPolicyItem)); err != nil {
246+
return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "policies", projectID, err))
247+
}
248+
249+
if err := d.Set("policy_item_hourly", flattenBackupPolicyItems(backupPolicy.ScheduledPolicyItems, snapshotScheduleHourly)); err != nil {
250+
return diag.Errorf(errorSnapshotBackupPolicySetting, "policy_item_hourly", projectID, err)
251+
}
252+
253+
if err := d.Set("policy_item_daily", flattenBackupPolicyItems(backupPolicy.ScheduledPolicyItems, snapshotScheduleDaily)); err != nil {
254+
return diag.Errorf(errorSnapshotBackupPolicySetting, "policy_item_daily", projectID, err)
255+
}
256+
257+
if err := d.Set("policy_item_weekly", flattenBackupPolicyItems(backupPolicy.ScheduledPolicyItems, snapshotScheduleWeekly)); err != nil {
258+
return diag.Errorf(errorSnapshotBackupPolicySetting, "policy_item_weekly", projectID, err)
259+
}
260+
261+
if err := d.Set("policy_item_monthly", flattenBackupPolicyItems(backupPolicy.ScheduledPolicyItems, snapshotScheduleMonthly)); err != nil {
262+
return diag.Errorf(errorSnapshotBackupPolicySetting, "policy_item_monthly", projectID, err)
263+
}
264+
265+
d.SetId(encodeStateID(map[string]string{
266+
"project_id": projectID,
267+
}))
268+
269+
return nil
270+
}
271+
272+
func flattenBackupPolicyItems(items []matlas.ScheduledPolicyItem, frequencyType string) []map[string]interface{} {
273+
policyItems := make([]map[string]interface{}, 0)
274+
for _, v := range items {
275+
if frequencyType == v.FrequencyType {
276+
policyItems = append(policyItems, map[string]interface{}{
277+
"id": v.ID,
278+
"frequency_interval": v.FrequencyInterval,
279+
"frequency_type": v.FrequencyType,
280+
"retention_unit": v.RetentionUnit,
281+
"retention_value": v.RetentionValue,
282+
})
283+
}
284+
}
285+
return policyItems
286+
}

0 commit comments

Comments
 (0)