Skip to content

Commit 71f9457

Browse files
Alexandra YeoMeharwadeDivya
authored andcommitted
Added - Support for FSS Policy-Based Snapshots
1 parent a01b286 commit 71f9457

31 files changed

+2003
-45
lines changed

examples/storage/fss/data_sources.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,15 @@ data "oci_file_storage_replication_targets" "test_replication_targets" {
107107
#id = var.replication_target_id
108108
#state = var.replication_target_state
109109
}
110+
111+
# Gets a list of filesystem snapshot policies in a compartment and availability domain
112+
data "oci_file_storage_filesystem_snapshot_policies" "filesystem_snapshot_policies" {
113+
#Required
114+
availability_domain = data.oci_identity_availability_domain.ad.name
115+
compartment_id = var.compartment_ocid
116+
117+
#Optional
118+
#display_name = var.filesystem_snapshot_policy_display_name
119+
#id = var.filesystem_snapshot_policy_id
120+
#state = var.filesystem_snapshot_policy_state
121+
}

examples/storage/fss/file_system.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,19 @@ resource "oci_file_storage_file_system" "my_fs_2" {
3333
}
3434
}
3535

36+
resource "oci_file_storage_file_system" "my_file_system_with_fs_snapshot_policy" {
37+
#Required
38+
availability_domain = data.oci_identity_availability_domain.ad.name
39+
compartment_id = var.compartment_ocid
40+
41+
#Optional
42+
display_name = var.file_system_with_snapshot_policy_display_name
43+
filesystem_snapshot_policy_id = oci_file_storage_filesystem_snapshot_policy.my_filesystem_snapshot_policy.id
44+
# defined_tags = {
45+
# "example-tag-namespace-all.example-tag" = "value"
46+
# }
47+
48+
freeform_tags = {
49+
"Department" = "Accounting"
50+
}
51+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
resource "oci_file_storage_filesystem_snapshot_policy" "my_filesystem_snapshot_policy" {
4+
#Required
5+
availability_domain = data.oci_identity_availability_domain.ad.name
6+
compartment_id = var.compartment_ocid
7+
8+
#Optional
9+
# defined_tags = map(oci_identity_tag_namespace.tag-namespace1.name.oci_identity_tag.tag1.name, var.filesystem_snapshot_policy_defined_tags_value)
10+
display_name = var.filesystem_snapshot_policy_display_name
11+
freeform_tags = var.filesystem_snapshot_policy_freeform_tags
12+
policy_prefix = var.filesystem_snapshot_policy_policy_prefix
13+
schedules {
14+
#Required
15+
period = "YEARLY"
16+
time_zone = var.filesystem_snapshot_policy_schedules_time_zone
17+
18+
#Optional
19+
day_of_month = var.filesystem_snapshot_policy_schedules_day_of_month
20+
hour_of_day = var.filesystem_snapshot_policy_schedules_hour_of_day
21+
month = var.filesystem_snapshot_policy_schedules_month
22+
retention_duration_in_seconds = var.filesystem_snapshot_policy_schedules_retention_duration_in_seconds
23+
schedule_prefix = "yearly-schedule"
24+
# Commented out time_schedule_start as the date given should be a time in the future
25+
# time_schedule_start = "2096-01-02T15:04:05Z"
26+
}
27+
}

examples/storage/fss/snapshot.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ resource "oci_file_storage_snapshot" "my_snapshot" {
99
# "example-tag-namespace-all.example-tag" = "value"
1010
# }
1111

12+
# Optional
1213
freeform_tags = {
1314
"Department" = "Finance"
1415
}
16+
# Commented out expiration_time as the date given should be a time in the future
17+
# expiration_time = "2096-01-02T15:04:05Z"
1518
}
1619

examples/storage/fss/variables.tf

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ variable "file_system_simple_display_name" {
5050
default= "my_fs_simple"
5151
}
5252

53+
variable "file_system_with_snapshot_policy_display_name" {
54+
default = "my_fs_with_snapshot_policy"
55+
}
56+
5357
variable "mount_target_1_display_name" {
5458
default = "my_mount_target_1"
5559
}
@@ -123,3 +127,50 @@ locals {
123127
mount_target_1_ip_address = data.oci_core_private_ips.ip_mount_target1.private_ips[0]["ip_address"]
124128
}
125129

130+
variable "filesystem_snapshot_policy_display_name" {
131+
default = "media-policy-1"
132+
}
133+
134+
variable "filesystem_snapshot_policy_freeform_tags" {
135+
default = { "Department" = "Finance" }
136+
}
137+
138+
variable "filesystem_snapshot_policy_id" {
139+
default = "id"
140+
}
141+
142+
variable "filesystem_snapshot_policy_policy_prefix" {
143+
default = "mp1"
144+
}
145+
146+
variable "filesystem_snapshot_policy_schedules_day_of_month" {
147+
default = 10
148+
}
149+
150+
variable "filesystem_snapshot_policy_schedules_hour_of_day" {
151+
default = 10
152+
}
153+
154+
variable "filesystem_snapshot_policy_schedules_month" {
155+
default = "JANUARY"
156+
}
157+
158+
variable "filesystem_snapshot_policy_schedules_day_of_week" {
159+
default = "MONDAY"
160+
}
161+
162+
variable "filesystem_snapshot_policy_schedules_retention_duration_in_seconds" {
163+
default = 7200
164+
}
165+
166+
variable "filesystem_snapshot_policy_schedules_schedule_prefix" {
167+
default = "schedulePrefix"
168+
}
169+
170+
variable "filesystem_snapshot_policy_schedules_time_zone" {
171+
default = "UTC"
172+
}
173+
174+
variable "filesystem_snapshot_policy_state" {
175+
default = "ACTIVE"
176+
}

internal/integrationtest/file_storage_file_system_test.go

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,34 @@ var (
3131
FileStorageFileSystem2RequiredOnlyResource = acctest.GenerateResourceFromRepresentationMap("oci_file_storage_file_system", "test_file_system2", acctest.Required, acctest.Create, FileStorageFileSystemRepresentation)
3232

3333
FileStorageFileStorageFileSystemDataSourceRepresentation = map[string]interface{}{
34-
"availability_domain": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}`},
35-
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
36-
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `media-files-1`, Update: `displayName2`},
37-
"id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_file_storage_file_system.test_file_system2.id}`},
38-
"parent_file_system_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_file_storage_file_system.test_file_system.id}`},
39-
"source_snapshot_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_file_storage_snapshot.test_snapshot.id}`},
40-
"state": acctest.Representation{RepType: acctest.Optional, Create: `ACTIVE`},
41-
"filter": acctest.RepresentationGroup{RepType: acctest.Required, Group: FileStorageFileSystemDataSourceFilterRepresentation}}
34+
"availability_domain": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}`},
35+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
36+
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `media-files-1`, Update: `displayName2`},
37+
"filesystem_snapshot_policy_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_file_storage_filesystem_snapshot_policy.test_filesystem_snapshot_policy.id}`},
38+
"id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_file_storage_file_system.test_file_system2.id}`},
39+
"parent_file_system_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_file_storage_file_system.test_file_system.id}`},
40+
"source_snapshot_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_file_storage_snapshot.test_snapshot.id}`},
41+
"state": acctest.Representation{RepType: acctest.Optional, Create: `ACTIVE`},
42+
"filter": acctest.RepresentationGroup{RepType: acctest.Required, Group: FileStorageFileSystemDataSourceFilterRepresentation}}
4243
FileStorageFileSystemDataSourceFilterRepresentation = map[string]interface{}{
4344
"name": acctest.Representation{RepType: acctest.Required, Create: `id`},
4445
"values": acctest.Representation{RepType: acctest.Required, Create: []string{`${oci_file_storage_file_system.test_file_system2.id}`}},
4546
}
4647

4748
FileStorageFileSystemRepresentation = map[string]interface{}{
48-
"availability_domain": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}`},
49-
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
50-
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
51-
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `media-files-1`, Update: `displayName2`},
52-
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}, Update: map[string]string{"Department": "Accounting"}},
53-
"source_snapshot_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_file_storage_snapshot.test_snapshot.id}`},
54-
"kms_key_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_kms_key.kms_key_id_for_create.id}`, Update: `${oci_kms_key.kms_key_id_for_update.id}`},
55-
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreDefinedTagsDifferencesRepresentation},
49+
"availability_domain": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}`},
50+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
51+
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
52+
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `media-files-1`, Update: `displayName2`},
53+
"filesystem_snapshot_policy_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_file_storage_filesystem_snapshot_policy.test_filesystem_snapshot_policy.id}`},
54+
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}, Update: map[string]string{"Department": "Accounting"}},
55+
"kms_key_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_kms_key.kms_key_id_for_create.id}`, Update: `${oci_kms_key.kms_key_id_for_update.id}`},
56+
"source_snapshot_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_file_storage_snapshot.test_snapshot.id}`},
57+
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreDefinedTagsDifferencesRepresentation},
5658
}
5759

5860
FileStorageFileSystemResourceDependencies = acctest.GenerateResourceFromRepresentationMap("oci_file_storage_file_system", "test_file_system", acctest.Required, acctest.Create, FileStorageFileSystemRepresentation) +
61+
acctest.GenerateResourceFromRepresentationMap("oci_file_storage_filesystem_snapshot_policy", "test_filesystem_snapshot_policy", acctest.Required, acctest.Create, FileStorageFilesystemSnapshotPolicyRepresentation) +
5962
acctest.GenerateResourceFromRepresentationMap("oci_file_storage_snapshot", "test_snapshot", acctest.Required, acctest.Create, FileStorageSnapshotRepresentation) +
6063
AvailabilityDomainConfig +
6164
DefinedTagsDependencies +
@@ -121,6 +124,7 @@ func TestFileStorageFileSystemResource_basic(t *testing.T) {
121124
resource.TestCheckResourceAttrSet(resourceName, "availability_domain"),
122125
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
123126
resource.TestCheckResourceAttr(resourceName, "display_name", "media-files-1"),
127+
resource.TestCheckResourceAttrSet(resourceName, "filesystem_snapshot_policy_id"),
124128
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
125129
resource.TestCheckResourceAttrSet(resourceName, "id"),
126130
resource.TestCheckResourceAttrSet(resourceName, "kms_key_id"),
@@ -152,6 +156,7 @@ func TestFileStorageFileSystemResource_basic(t *testing.T) {
152156
resource.TestCheckResourceAttrSet(resourceName, "availability_domain"),
153157
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentIdU),
154158
resource.TestCheckResourceAttr(resourceName, "display_name", "media-files-1"),
159+
resource.TestCheckResourceAttrSet(resourceName, "filesystem_snapshot_policy_id"),
155160
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
156161
resource.TestCheckResourceAttrSet(resourceName, "id"),
157162
resource.TestCheckResourceAttrSet(resourceName, "kms_key_id"),
@@ -178,6 +183,7 @@ func TestFileStorageFileSystemResource_basic(t *testing.T) {
178183
resource.TestCheckResourceAttrSet(resourceName, "availability_domain"),
179184
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
180185
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName2"),
186+
resource.TestCheckResourceAttrSet(resourceName, "filesystem_snapshot_policy_id"),
181187
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
182188
resource.TestCheckResourceAttrSet(resourceName, "id"),
183189
resource.TestCheckResourceAttrSet(resourceName, "kms_key_id"),
@@ -205,6 +211,7 @@ func TestFileStorageFileSystemResource_basic(t *testing.T) {
205211
resource.TestCheckResourceAttrSet(datasourceName, "availability_domain"),
206212
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),
207213
resource.TestCheckResourceAttr(datasourceName, "display_name", "displayName2"),
214+
resource.TestCheckResourceAttrSet(datasourceName, "filesystem_snapshot_policy_id"),
208215
resource.TestCheckResourceAttrSet(datasourceName, "id"),
209216
resource.TestCheckResourceAttrSet(datasourceName, "parent_file_system_id"),
210217
resource.TestCheckResourceAttrSet(datasourceName, "source_snapshot_id"),

0 commit comments

Comments
 (0)