Skip to content

Commit 980d557

Browse files
author
ccushing
committed
Add objectstore namespace metadata
* consolidate object store examples into one
1 parent ec50afc commit 980d557

17 files changed

+649
-240
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* This example shows how to manage a bucket
3+
*/
4+
5+
resource "oci_objectstorage_bucket" "bucket1" {
6+
compartment_id = "${var.compartment_ocid}"
7+
namespace = "${data.oci_objectstorage_namespace.ns.namespace}"
8+
name = "tf-example-bucket"
9+
access_type = "NoPublicAccess"
10+
}
11+
12+
data "oci_objectstorage_bucket_summaries" "buckets1" {
13+
compartment_id = "${var.compartment_ocid}"
14+
namespace = "${data.oci_objectstorage_namespace.ns.namespace}"
15+
filter {
16+
name = "name"
17+
values = ["${oci_objectstorage_bucket.bucket1.name}"]
18+
}
19+
}
20+
21+
output buckets {
22+
value = "${data.oci_objectstorage_bucket_summaries.buckets1.bucket_summaries}"
23+
}

docs/examples/object_storage/file_upload/file_upload.tf

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* This example file shows how to read and output the object storage namespace and namespace_metadata.
3+
*/
4+
5+
data "oci_objectstorage_namespace" "ns" {
6+
}
7+
8+
output namespace {
9+
value = "${data.oci_objectstorage_namespace.ns.namespace}"
10+
}
11+
12+
13+
resource "oci_objectstorage_namespace_metadata" "namespace-metadata1" {
14+
namespace = "${data.oci_objectstorage_namespace.ns.namespace}"
15+
default_s3compartment_id = "${var.compartment_ocid}"
16+
default_swift_compartment_id = "${var.compartment_ocid}"
17+
}
18+
19+
data oci_objectstorage_namespace_metadata namespace-metadata1 {
20+
namespace = "${data.oci_objectstorage_namespace.ns.namespace}"
21+
}
22+
23+
output namespace-metadata {
24+
value = <<EOF
25+
26+
namespace = ${data.oci_objectstorage_namespace_metadata.namespace-metadata1.namespace}
27+
default_s3compartment_id = ${data.oci_objectstorage_namespace_metadata.namespace-metadata1.default_s3compartment_id}
28+
default_swift_compartment_id = ${data.oci_objectstorage_namespace_metadata.namespace-metadata1.default_swift_compartment_id}
29+
EOF
30+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* This example demonstrates object store object management. It uses Terraforms built-in `file` function to upload a file.
2+
*
3+
* WARNING: This should only be used with small files. The file helper does stringification so large files
4+
* may cause terraform to slow, become unresponsive or exceed allowed memory usage.
5+
*/
6+
7+
resource "oci_objectstorage_object" "object1" {
8+
namespace = "${data.oci_objectstorage_namespace.ns.namespace}"
9+
bucket = "${oci_objectstorage_bucket.bucket1.name}"
10+
object = "index.html"
11+
content_language = "en-US"
12+
content_type = "text/html"
13+
content = "${file("index.html")}"
14+
}
15+
16+
data "oci_objectstorage_object_head" "object-head1" {
17+
namespace = "${data.oci_objectstorage_namespace.ns.namespace}"
18+
bucket = "${oci_objectstorage_bucket.bucket1.name}"
19+
object = "${oci_objectstorage_object.object1.object}"
20+
}
21+
22+
data "oci_objectstorage_objects" "objects1" {
23+
namespace = "${data.oci_objectstorage_namespace.ns.namespace}"
24+
bucket = "${oci_objectstorage_bucket.bucket1.name}"
25+
}
26+
27+
output object-head-data {
28+
value = <<EOF
29+
30+
object = ${data.oci_objectstorage_object_head.object-head1.object}
31+
content-length = ${data.oci_objectstorage_object_head.object-head1.content-length}
32+
content-type = ${data.oci_objectstorage_object_head.object-head1.content-type}
33+
EOF
34+
}
35+
36+
output objects {
37+
value = "${data.oci_objectstorage_objects.objects1.objects}"
38+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* This example shows how to create preauthenticated requests for objects and buckets.
3+
*/
4+
5+
resource "oci_objectstorage_preauthrequest" "bucket-par" {
6+
namespace = "${data.oci_objectstorage_namespace.ns.namespace}"
7+
bucket = "${oci_objectstorage_bucket.bucket1.name}"
8+
name = "parOnBucket"
9+
access_type = "AnyObjectWrite" //Other configurations accepted are ObjectWrite, ObjectReadWrite
10+
time_expires = "2020-12-10T23:00:00Z"
11+
}
12+
13+
resource "oci_objectstorage_preauthrequest" "object-par" {
14+
namespace = "${data.oci_objectstorage_namespace.ns.namespace}"
15+
bucket = "${oci_objectstorage_bucket.bucket1.name}"
16+
object = "${oci_objectstorage_object.object1.object}"
17+
name = "object-par"
18+
access_type = "ObjectRead" // ObjectRead, ObjectWrite, ObjectReadWrite, AnyObjectWrite
19+
time_expires = "2020-12-29T23:00:00Z"
20+
}
21+
22+
output "par_request_url" {
23+
value = "https://objectstorage.${var.region}.oraclecloud.com${oci_objectstorage_preauthrequest.object-par.access_uri}"
24+
}

docs/examples/object_storage/preauthrequests/preauthreq.tf

Lines changed: 0 additions & 71 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* This example file shows how to configure the oci provider to target the a single region.
3+
*/
4+
5+
// These variables would commonly be defined as environment variables or sourced in a .env file
6+
variable "tenancy_ocid" {}
7+
variable "user_ocid" {}
8+
variable "fingerprint" {}
9+
variable "private_key_path" {}
10+
variable "compartment_ocid" {}
11+
variable "region" { default = "us-ashburn-1" }
12+
13+
14+
provider "oci" {
15+
region = "${var.region}"
16+
tenancy_ocid = "${var.tenancy_ocid}"
17+
user_ocid = "${var.user_ocid}"
18+
fingerprint = "${var.fingerprint}"
19+
private_key_path = "${var.private_key_path}"
20+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# ___ ____ _ ____ _ _____
2+
# / _ \| _ \ / \ / ___| | | ____|
3+
# | | | | |_) | / _ \| | | | | _|
4+
# | |_| | _ < / ___ | |___| |___| |___
5+
# \___/|_| \_/_/ \_\____|_____|_____|
6+
***
7+
8+
## Object Storage Resource and Datasource Examples
9+
10+
This example demonstrates the following Object Storage concepts:
11+
* Creating Objects and buckets
12+
* Defining Preauthenticated Requests for objects and buckets
13+
* Accessing and modifying object store namespace metatdata
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# oci_object_storage_namespace_metadata
2+
3+
## NamespaceMetadata Resource
4+
5+
### NamespaceMetadata Reference
6+
7+
The following attributes are exported:
8+
9+
* `default_s3compartment_id` - The default compartment ID for an S3 client.
10+
* `default_swift_compartment_id` - The default compartment ID for a Swift client.
11+
* `namespace` - The namespace to which the metadata belongs.
12+
13+
14+
15+
### Create Operation
16+
17+
18+
The following arguments are supported:
19+
20+
* `default_s3compartment_id` - (Optional) The default compartment ID for an S3 client.
21+
* `default_swift_compartment_id` - (Optional) The default compartment ID for a Swift client.
22+
* `namespace` - (Required) The namespace to which the metadata belongs.
23+
24+
### Update Operation
25+
Change the default Swift/S3 compartmentId of user's namespace into the user-defined compartmentId. Upon doing
26+
this, all subsequent bucket creations will use the new default compartment, but no previously created
27+
buckets will be modified. A user must have the NAMESPACE_UPDATE permission to make changes to the default
28+
compartments for S3 and Swift.
29+
30+
31+
The following arguments support updates:
32+
* `default_s3compartment_id` - The default compartment ID for an S3 client.
33+
* `default_swift_compartment_id` - The default compartment ID for a Swift client.
34+
35+
36+
** IMPORTANT **
37+
Any change to a property that does not support update will force the destruction and recreation of the resource with the new property values
38+
39+
### Example Usage
40+
41+
```hcl
42+
resource "oci_objectstorage_namespace_metadata" "test_namespace_metadata" {
43+
namespace = "${var.bucket_namespace}"
44+
default_s3compartment_id = "${var.default_s3compartment_id}"
45+
default_swift_compartment_id = "${var.default_swift_compartment_id}"
46+
}
47+
```
48+
49+
# oci_object_storage_namespace_metadata
50+
51+
## NamespaceMetadata DataSource
52+
53+
Gets a single namespace_metadata
54+
55+
### Get Operation
56+
Namespaces are unique. Namespaces are either the tenancy name or a random string automatically generated during
57+
account creation. You cannot edit a namespace.
58+
59+
The following arguments are supported:
60+
* `namespace` - (Required) The namespace to which the metadata belongs.
61+
62+
63+
The following attributes are exported:
64+
* `default_s3compartment_id` - The default compartment ID for an S3 client.
65+
* `default_swift_compartment_id` - The default compartment ID for a Swift client.
66+
* `namespace` - The namespace to which the metadata belongs.
67+
68+
69+
### Example Usage
70+
71+
```hcl
72+
data "oci_objectstorage_namespace_metadata" "test_namespace_metadata" {
73+
namespace = "${var.bucket_namespace}"
74+
}
75+
```

0 commit comments

Comments
 (0)