Skip to content

Commit ca8e2c0

Browse files
parwezakohashim
authored andcommitted
Adding export options to export for bettter access control
1 parent d2f93a6 commit ca8e2c0

19 files changed

+403
-29
lines changed

docs/examples/storage/fss/data_sources.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ data "oci_identity_availability_domains" "ADs" {
66
# Gets the list of file systems in the compartment
77
data "oci_file_storage_file_systems" "file_systems" {
88
#Required
9-
availability_domain = "${var.availability_domain}"
9+
availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.AD - 1],"name")}"
1010
compartment_id = "${var.compartment_ocid}"
1111

1212
#Optional fields. Used by the service to filter the results when returning data to the client.
@@ -18,7 +18,7 @@ data "oci_file_storage_file_systems" "file_systems" {
1818
# Gets the list of mount targets in the compartment
1919
data "oci_file_storage_mount_targets" "mount_targets" {
2020
#Required
21-
availability_domain = "${var.availability_domain}"
21+
availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.AD - 1],"name")}"
2222
compartment_id = "${var.compartment_ocid}"
2323

2424
#Optional fields. Used by the service to filter the results when returning data to the client.
@@ -53,7 +53,7 @@ data "oci_file_storage_snapshots" "snapshots" {
5353
# Gets a list of export sets in a compartment and availability domain
5454
data "oci_file_storage_export_sets" "export_sets" {
5555
#Required
56-
availability_domain = "${var.availability_domain}"
56+
availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.AD - 1],"name")}"
5757
compartment_id = "${var.compartment_ocid}"
5858

5959
#Optional fields. Used by the service to filter the results when returning data to the client.

docs/examples/storage/fss/export.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ resource "oci_file_storage_export" "my_export_fs1_mt1" {
33
export_set_id = "${oci_file_storage_export_set.my_export_set_1.id}"
44
file_system_id = "${oci_file_storage_file_system.my_fs_1.id}"
55
path = "${var.export_path_fs1_mt1}"
6+
7+
export_options = [
8+
{
9+
source = "0.0.0.0/0"
10+
access = "READ_ONLY"
11+
identity_squash = "NONE"
12+
require_privileged_source_port = false
13+
}
14+
]
615
}
716

817
resource "oci_file_storage_export" "my_export_fs1_mt2" {

docs/examples/storage/fss/file_system.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
resource "oci_file_storage_file_system" "my_fs_1" {
22
#Required
3-
availability_domain = "${var.availability_domain}"
3+
availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.AD - 1],"name")}"
44
compartment_id = "${var.compartment_ocid}"
55

66
#Optional
@@ -9,7 +9,7 @@ resource "oci_file_storage_file_system" "my_fs_1" {
99

1010
resource "oci_file_storage_file_system" "my_fs_2" {
1111
#Required
12-
availability_domain = "${var.availability_domain}"
12+
availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.AD - 1],"name")}"
1313
compartment_id = "${var.compartment_ocid}"
1414

1515
#Optional

docs/examples/storage/fss/instance.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
resource "oci_core_instance" "my_instance" {
2-
availability_domain = "${var.availability_domain}"
2+
availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.AD - 1],"name")}"
33
compartment_id = "${var.compartment_ocid}"
44
display_name = "my instance with FSS access"
55
hostname_label = "myinstance"
66
image = "${var.instance_image_ocid[var.region]}"
77
shape = "${var.instance_shape}"
88
subnet_id = "${oci_core_subnet.my_subnet.id}"
99
metadata {
10-
ssh_authorized_keys = "${file(var.ssh_public_key)}"
10+
ssh_authorized_keys = "${var.ssh_public_key}"
1111
}
1212
timeouts {
1313
create = "60m"
@@ -23,7 +23,7 @@ resource "null_resource" "mount_fss_on_instance" {
2323
timeout = "15m"
2424
host = "${oci_core_instance.my_instance.public_ip}"
2525
user = "opc"
26-
private_key = "${file(var.ssh_private_key)}"
26+
private_key = "${var.ssh_private_key}"
2727
}
2828
inline = [
2929
"sudo yum -y install nfs-utils > nfs-utils-install.log",

docs/examples/storage/fss/mount_target.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
resource "oci_file_storage_mount_target" "my_mount_target_1" {
22
#Required
3-
availability_domain = "${var.availability_domain}"
3+
availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.AD - 1],"name")}"
44
compartment_id = "${var.compartment_ocid}"
55
subnet_id = "${oci_core_subnet.my_subnet.id}"
66

@@ -10,7 +10,7 @@ resource "oci_file_storage_mount_target" "my_mount_target_1" {
1010

1111
resource "oci_file_storage_mount_target" "my_mount_target_2" {
1212
#Required
13-
availability_domain = "${var.availability_domain}"
13+
availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.AD - 1],"name")}"
1414
compartment_id = "${var.compartment_ocid}"
1515
subnet_id = "${oci_core_subnet.my_subnet.id}"
1616

docs/examples/storage/fss/network.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ resource "oci_core_route_table" "my_route_table" {
2323
}
2424

2525
resource "oci_core_subnet" "my_subnet" {
26-
availability_domain = "${var.availability_domain}"
26+
availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.AD - 1],"name")}"
2727
cidr_block = "${var.my_subnet_cidr}"
2828
display_name = "mysubnet"
2929
dns_label = "mysubnet"

docs/examples/storage/fss/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ variable "api_public_key" {
1414
default = "-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4fGHcxbEs3VaWoKaGUiPHGZ5ILiOXCcWN4nOgLr6CSzUjtgjmN3aA6rsT2mYiD+M5EecDbEUMectUhNtLl5LPABN9kpjuR0zxCJXvYYQiCBtdjb1/YxrZI9T/9Jtd+cTabCahJHR/cR8jFmvO4cKJCa/0+Y00zvktrqniHIn3edGAKC4Ttlwj/1NqT0ZVePMXg3rWHPsIW6ONfdn6FNfMet8Qa8K3C9xVvzImlYx8PQBy/44Ilu5T3A+puwb2QMeZnQZGDALOY4MvrBTTA1TdjFpg1NChj2rGYzreysqlnKFu+1qg64wel39kHkppz4Fv2vaLXF9qIeDjeo3G4sHQIDAQAB-----END PUBLIC KEY-----"
1515
}
1616

17+
# Choose an Availability Domain
18+
variable "AD" {
19+
default = "1"
20+
}
21+
1722
variable "my_vcn-cidr" {
1823
default = "10.0.0.0/16"
1924
}

docs/file_storage/exports.md

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66

77
The following attributes are exported:
88

9+
* `export_options` - Policies that apply to NFS requests made through this export. `exportOptions` contains a sequential list of `ClientOptions`. Each `ClientOptions` item defines the export options that are applied to a specified set of clients. For each NFS request, the first `ClientOptions` option in the list whose `source` attribute matches the source IP address of the request is applied. If a client source IP address does not match the `source` property of any `ClientOptions` in the list, then the export will be invisible to that client. This export will not be returned by `MOUNTPROC_EXPORT` calls made by the client and any attempt to mount or access the file system through this export will result in an error. **Exports without defined `ClientOptions` are invisible to all clients.** If one export is invisible to a particular client, associated file systems may still be accessible through other exports on the same or different mount targets. To completely deny client access to a file system, be sure that the client source IP address is not included in any export for any mount target associated with the file system.
10+
* `access` - Type of access to grant clients using the file system through this export. If unspecified defaults to `READ_ONLY`.
11+
* `anonymous_gid` - GID value to remap to when squashing a client GID (see identitySquash for more details.) If unspecified defaults to `65534`.
12+
* `anonymous_uid` - UID value to remap to when squashing a client UID (see identitySquash for more details.) If unspecified, defaults to `65534`.
13+
* `identity_squash` - Used when clients accessing the file system through this export have their UID and GID remapped to 'anonymousUid' and 'anonymousGid'. If `ALL`, all users and groups are remapped; if `ROOT`, only the root user and group (UID/GID 0) are remapped; if `NONE`, no remapping is done. If unspecified, defaults to `ROOT`.
14+
* `require_privileged_source_port` - If `true`, clients accessing the file system through this export must connect from a privileged source port. If unspecified, defaults to `true`.
15+
* `source` - Clients these options should apply to. Must be a either single IPv4 address or single IPv4 CIDR block. **Note:** Access will also be limited by any applicable VCN security rules and the ability to route IP packets to the mount target. Mount targets do not have Internet-routable IP addresses.
916
* `export_set_id` - The OCID of this export's export set.
1017
* `file_system_id` - The OCID of this export's file system.
1118
* `id` - The OCID of this export.
@@ -22,16 +29,30 @@ file system.
2229

2330
The following arguments are supported:
2431

32+
* `export_options` - (Optional) Export options for the new export. If left unspecified, defaults to: [ { "source" : "0.0.0.0/0", "requirePrivilegedSourcePort" : false, "access" : "READ_WRITE", "identitySquash" : "NONE" } ] **Note:** Mount targets do not have Internet-routable IP addresses. Therefore they will not be reachable from the Internet, even if an associated `ClientOptions` item has a source of `0.0.0.0/0`. **If set to the empty array then the export will not be visible to any clients.** The export's `exportOptions` can be changed after creation using the `UpdateExport` operation.
33+
* `access` - (Optional) Type of access to grant clients using the file system through this export. If unspecified defaults to `READ_ONLY`.
34+
* `anonymous_gid` - (Optional) GID value to remap to when squashing a client GID (see identitySquash for more details.) If unspecified defaults to `65534`.
35+
* `anonymous_uid` - (Optional) UID value to remap to when squashing a client UID (see identitySquash for more details.) If unspecified, defaults to `65534`.
36+
* `identity_squash` - (Optional) Used when clients accessing the file system through this export have their UID and GID remapped to 'anonymousUid' and 'anonymousGid'. If `ALL`, all users and groups are remapped; if `ROOT`, only the root user and group (UID/GID 0) are remapped; if `NONE`, no remapping is done. If unspecified, defaults to `ROOT`.
37+
* `require_privileged_source_port` - (Optional) If `true`, clients accessing the file system through this export must connect from a privileged source port. If unspecified, defaults to `true`.
38+
* `source` - (Required) Clients these options should apply to. Must be a either single IPv4 address or single IPv4 CIDR block. **Note:** Access will also be limited by any applicable VCN security rules and the ability to route IP packets to the mount target. Mount targets do not have Internet-routable IP addresses.
2539
* `export_set_id` - (Required) The OCID of this export's export set.
2640
* `file_system_id` - (Required) The OCID of this export's file system.
2741
* `path` - (Required) Path used to access the associated file system. Avoid entering confidential information. Example: `/mediafiles`
2842

2943

3044
### Update Operation
31-
45+
Updates the specified export's information.
3246

3347
The following arguments support updates:
34-
* NO arguments in this resource support updates
48+
* `export_options` - Export options for the new export. If left unspecified, defaults to: [ { "source" : "0.0.0.0/0", "requirePrivilegedSourcePort" : false, "access" : "READ_WRITE", "identitySquash" : "NONE" } ] **Note:** Mount targets do not have Internet-routable IP addresses. Therefore they will not be reachable from the Internet, even if an associated `ClientOptions` item has a source of `0.0.0.0/0`. **If set to the empty array then the export will not be visible to any clients.** The export's `exportOptions` can be changed after creation using the `UpdateExport` operation.
49+
* `access` - Type of access to grant clients using the file system through this export. If unspecified defaults to `READ_ONLY`.
50+
* `anonymous_gid` - GID value to remap to when squashing a client GID (see identitySquash for more details.) If unspecified defaults to `65534`.
51+
* `anonymous_uid` - UID value to remap to when squashing a client UID (see identitySquash for more details.) If unspecified, defaults to `65534`.
52+
* `identity_squash` - Used when clients accessing the file system through this export have their UID and GID remapped to 'anonymousUid' and 'anonymousGid'. If `ALL`, all users and groups are remapped; if `ROOT`, only the root user and group (UID/GID 0) are remapped; if `NONE`, no remapping is done. If unspecified, defaults to `ROOT`.
53+
* `require_privileged_source_port` - If `true`, clients accessing the file system through this export must connect from a privileged source port. If unspecified, defaults to `true`.
54+
* `source` - Clients these options should apply to. Must be a either single IPv4 address or single IPv4 CIDR block. **Note:** Access will also be limited by any applicable VCN security rules and the ability to route IP packets to the mount target. Mount targets do not have Internet-routable IP addresses.
55+
3556

3657
** IMPORTANT **
3758
Any change to a property that does not support update will force the destruction and recreation of the resource with the new property values
@@ -41,9 +62,22 @@ Any change to a property that does not support update will force the destruction
4162
```hcl
4263
resource "oci_file_storage_export" "test_export" {
4364
#Required
44-
export_set_id = "${oci_file_storage_mount_target.test_mount_target.export_set_id}"
65+
export_set_id = "${oci_file_storage_export_set.test_export_set.id}"
4566
file_system_id = "${oci_file_storage_file_system.test_file_system.id}"
4667
path = "${var.export_path}"
68+
69+
#Optional
70+
export_options {
71+
#Required
72+
source = "${var.export_export_options_source}"
73+
74+
#Optional
75+
access = "${var.export_export_options_access}"
76+
anonymous_gid = "${var.export_export_options_anonymous_gid}"
77+
anonymous_uid = "${var.export_export_options_anonymous_uid}"
78+
identity_squash = "${var.export_export_options_identity_squash}"
79+
require_privileged_source_port = "${var.export_export_options_require_privileged_source_port}"
80+
}
4781
}
4882
```
4983

@@ -83,4 +117,4 @@ data "oci_file_storage_exports" "test_exports" {
83117
id = "${var.export_id}"
84118
state = "${var.export_state}"
85119
}
86-
```
120+
```

docs/file_storage/file_systems.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The following attributes are exported:
1010
* `compartment_id` - The OCID of the compartment that contains the file system.
1111
* `display_name` - A user-friendly name. It does not have to be unique, and it is changeable. Avoid entering confidential information. Example: `My file system`
1212
* `id` - The OCID of the file system.
13-
* `metered_bytes` - The number of bytes consumed by the file system, including any snapshots. This number reflects the metered size of the file system and is updated asynchronously with respect to updates to the file system.
13+
* `metered_bytes` - The number of bytes consumed by the file system, including any snapshots. This number reflects the metered size of the file system and is updated asynchronously with respect to updates to the file system.
1414
* `state` - The current state of the file system.
1515
* `time_created` - The date and time the file system was created, expressed in [RFC 3339](https://tools.ietf.org/rfc/rfc3339) timestamp format. Example: `2016-08-25T21:10:29.600Z`
1616

@@ -112,4 +112,4 @@ data "oci_file_storage_file_systems" "test_file_systems" {
112112
id = "${var.file_system_id}"
113113
state = "${var.file_system_state}"
114114
}
115-
```
115+
```

docs/file_storage/mount_targets.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ Mount targets have one or more private IP addresses that you can
3131
provide as the host portion of remote target parameters in
3232
client mount commands. These private IP addresses are listed
3333
in the privateIpIds property of the mount target and are highly available. Mount
34-
targets also consume additional IP addresses in their subnet.
34+
targets also consume additional IP addresses in their subnet.
3535
Do not use /30 or smaller subnets for mount target creation because they
36-
do not have sufficient available IP addresses.
37-
Allow at least three IP addresses for each mount target.
36+
do not have sufficient available IP addresses.
37+
Allow at least three IP addresses for each mount target.
3838

3939
For information about access control and compartments, see
4040
[Overview of the IAM
@@ -127,4 +127,4 @@ data "oci_file_storage_mount_targets" "test_mount_targets" {
127127
id = "${var.mount_target_id}"
128128
state = "${var.mount_target_state}"
129129
}
130-
```
130+
```

0 commit comments

Comments
 (0)