Skip to content

Commit e2e4cf4

Browse files
authored
feat: Add Object Storage service (#439)
* chore: Upgrade Go version to v1.21 chore: Upgrade Go version to v1.21 chore: upgrade Go to v1.21 ci: Set go version 1.21 in GitHub Actions ci: Upgrade actions version (checkout, setup-go, ci-lint) ci: Upgrade golangci-lint v1.59 * chore: Install AWS SDK for Object Storage API * feat: Add S3 Client configuration * feat: Add Object Storage Resources * feat: Add objectstorage_bucket resource * feat: Add objectstorage_bucket_acl resource * feat: Add objectstorage_object resource * feat: Add objectstorage_object_acl resource * fix: add "_bucket" suffix to bucket resource * feat: Add examples of object storage * docs: Add initial documentation of object storage * feat: add type casting function for nested listValue * feat: Add BucketRegion to bucket chema * fix: Add detailed schema of grants & type casting method * chore: Add error exception * feat: Add regex validator for resource id * chore: remove redundant EOL * fix: Remove BucketName, BucketRegion from schema(doesn't provided) * refactor: Add TrimForIDParsing util * feat: Add temporary file creation logic * feat: Add aclOptions for testing * fix: Removed Unavailable object acl * feat: Add Bucket data source * fix: Add new bucket creation for independant testing * fix: aws.String => ncloud.String * chore: fix typo * chore: change string value with constants * refactor: expand TrimForParsing to parse vairous strings (not only ID) * feat: use region info from initial configuration * refactor: Set bucket id same as bucket name * fix: Add detailed string validator with regex for bucket_name * feat: Add NewObjectDataSource data source * refactor: Move ObjectIDParser to object.go * refactor: Set Object Resource ID with new format * feat: set independent object testing * feat: Add Owner info & Creation Date to bucket data source * feat: Add OwnerID & OwnerDisplayname at object_acl attribute * fix: set bucket_id & object_id w/o NRN * docs: Add documentation of object storage resources * feat: Change format - make resource id with '/' in object storage - object * feat: Add objectstorage_object_copy * fix: Change to do not use pointer method * docs: Add data source documentation of bucket * docs: Add object_storage_object.md in data-source * docs: Add object_storage_object_copy.md * feat: Add CreationDate attribute to bucket * fix: fix logic to check whether output is nil * fix: Add format of creationDate * feat: Delete panic from object_copy Update * feat: Remove endpoint from Config struct * fix: Remove Optional keyword from creation_date(computed) * refactor: set bucket unique value from bucket_id to bucket_name * fix: Remove unused headbucket * feat: Add bucket ID (since it uses id for default) * feat: Add attributes based on HeadObjectOutput * feat: Add endpoint abstract logic * refactor: Move post fetch logic into refreshFromOutput * feat: Add genEndpointWithCode (region, site) * feat: Add optional endpoint configuration * feat: Add region formatting logic * feat: Add Optional variables compatible with aws sdk in object-kind resource * docs: Update docs with additional attributes * fix: Remove Object Encryption logic entirely * feat: Add site variable in example tf code * chore: Add Error with Diagnostics * refactor: remove endpoint from providerConfig * chore: add missed packages * fix: fix endpoint env to optional * fix: Parse bucket info after pulling plan data * refactor: Abstract BucketNameValidator * fix: Remove optional from creation_date * fix: Change serverless environment => platform independent * fix: change id with object_url * feat: Add attribute documentation * feat: Add update logic to object_acl * feat: Add update logic to bucket_acl * fix: Fix typo Revert "fix: Fix typo" This reverts commit 37c7737. fix: Fix typo
1 parent 4ffdd3a commit e2e4cf4

30 files changed

+3631
-116
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
subcategory: "Object Storage"
3+
---
4+
5+
# Data Source: ncloud_objectstorage_bucket
6+
7+
Prvides information about a bucket.
8+
9+
~> **NOTE:** This resource is platform independent. Does not need VPC configuration.
10+
11+
## Example Usage
12+
13+
```terraform
14+
data "ncloud_objectstorage_bucket" "test-bucket" {
15+
bucket_name = "your-bucket"
16+
}
17+
```
18+
19+
## Argument Reference
20+
21+
The following arguments are required:
22+
23+
* `id` - Unique ID for bucket. Since bucket name is already unique in specific region, ID is same as `bucket_name`.
24+
* `bucket_name` - (Required) Bucket name to create. Bucket name must be between 3 and 63 characters long, can contain lowercase letters, numbers, periods, and hyphens. It must start and end with a letter or number, and cannot have consecutive periods.
25+
* `creation_date` - Date of when this bucket created.
26+
27+
## Attribute Reference
28+
29+
This data source exports the following attributes in addition to the arguments above:
30+
31+
* `owner_id` - ID of target bucket owner.
32+
* `owner_displayname` - Display name of target bucket owner.
33+
* `creation_date` - Date information of when this bucket created.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
subcategory: "Object Storage"
3+
---
4+
5+
# Data Source: ncloud_objectstorage_object
6+
7+
Prvides information about a object.
8+
9+
~> **NOTE:** This resource is platform independent. Does not need VPC configuration.
10+
11+
## Example Usage
12+
13+
```terraform
14+
data "ncloud_objectstorage_object" "test" {
15+
object_id = ncloud_objectstorage_object.testing_object.id
16+
}
17+
```
18+
19+
## Argument Reference
20+
21+
The following arguments are required:
22+
23+
* `object_id` - (Required) Object id to get. same as "\${bucket_name}/${object_key}".
24+
25+
## Attribute Reference
26+
27+
~> **NOTE:** Since Ncloud Object Stroage uses S3 Compatible SDK, these arguments are served as best-effort.
28+
29+
This data source exports the following attributes in addition to the arguments above:
30+
31+
* `bucket` - Name of bucket where object belongs.
32+
* `key` - Key of object.
33+
* `source` - Path that informs where does object is located in bucket.
34+
* `content_language` - Language the content is in e.g., en-US or en-GB.
35+
* `content_length` - How long the object is.
36+
* `content_type` - Type of the object.
37+
* `body` - Saved content of the object.
38+
* `bucket_key_enabled` - Whether this resource uses Ncloud KMS Keys for SSE.
39+
* `content_encoding` - Content encodings that have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field. Read [w3c content encoding](https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11) for further information.
40+
* `accept_ranges` - Indicates that a range of bytes was specified.
41+
* `etag` - ETag generated for the object (an MD5 sum of the object content). For plaintext objects or objects encrypted with an AWS-managed key, the hash is an MD5 digest of the object data. For objects encrypted with a KMS key or objects created by either the Multipart Upload or Part Copy operation, the hash is not an MD5 digest, regardless of the method of encryption. More information on possible values can be found on [Common Response Headers](https://docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonResponseHeaders.html).
42+
* `expiration` - the object expiration is configured, the response includes this header. It includes the expiry-date and rule-id key-value pairs providing object expiration information. The value of the rule-id is URL-encoded.
43+
* `last_modified` - Date and time when the object was last modified.
44+
* `parts_count` - The count of parts this object has. This value is only returned if you specify partNumber in your request and the object was uploaded as a multipart upload.
45+
* `version_id` - Unique version ID value for the object, if bucket versioning is enabled.
46+
* `website_redirect_location` - Target URL for website redirect.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
subcategory: "Object Storage"
3+
---
4+
5+
6+
# Resource: ncloud_objectstorage_bucket
7+
8+
Provides Object Storage Bucket service resource.
9+
10+
~> **NOTE:** This resource is platform independent. Does not need VPC configuration.
11+
12+
## Example Usage
13+
14+
```terraform
15+
provider "ncloud" {
16+
support_vpc = true
17+
access_key = var.access_key
18+
secret_key = var.secret_key
19+
region = var.region
20+
}
21+
22+
resource "ncloud_objectstorage_bucket" "testing_bucket" {
23+
bucket_name = "your-bucket-name"
24+
}
25+
```
26+
27+
## Argument Reference
28+
29+
The following arguments are supported:
30+
31+
* `id` - Unique ID for bucket. Since bucket name is already unique in specific region, ID is same as `bucket_name`.
32+
* `bucket_name` - (Required) Bucket name to create. Bucket name must be between 3 and 63 characters long, can contain lowercase letters, numbers, periods, and hyphens. It must start and end with a letter or number, and cannot have consecutive periods.
33+
* `creation_date` - Date of when this bucket created.
34+
35+
## Import
36+
37+
### `terraform import` command
38+
39+
* Object Storage Bucket can be imported using the `bucket_name`. For example:
40+
41+
```console
42+
$ terraform import ncloud_objectstorage_object.rsc_name bucket-name
43+
```
44+
45+
### `import` block
46+
47+
* In Terraform v1.5.0 and later, use a [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Object Storage Bucket using the `id`. For example:
48+
49+
```terraform
50+
import {
51+
to = ncloud_objectstorage_object.rsc_name
52+
bucket_name = "bucket-name"
53+
}
54+
```
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
subcategory: "Object Storage"
3+
---
4+
5+
6+
# Resource: ncloud_objectstorage_bucket_acl
7+
8+
Provides Object Storage Bucket ACL service resource.
9+
10+
~> **NOTE:** This resource is platform independent. Does not need VPC configuration.
11+
12+
## Example Usage
13+
14+
```terraform
15+
provider "ncloud" {
16+
support_vpc = true
17+
access_key = var.access_key
18+
secret_key = var.secret_key
19+
region = var.region
20+
}
21+
22+
resource "ncloud_objectstorage_bucket" "testing_bucket" {
23+
bucket_name = "your-bucket-name"
24+
}
25+
26+
resource "ncloud_objectstorage_bucket_acl" "testing_acl" {
27+
bucket_name = ncloud_objectstorage_bucket.testing_bucket.bucket_name
28+
rule = "RULL_TO_APPLY"
29+
}
30+
```
31+
32+
## Argument Reference
33+
34+
The following arguments are supported:
35+
36+
* `id` - Unique ID for bucket. Has format of `bucket_acl_${bucket_name}`.
37+
* `bucket_name` - (Required) Target bucket id to create(same as bucket name). Bucket name must be between 3 and 63 characters long, can contain lowercase letters, numbers, periods, and hyphens. It must start and end with a letter or number, and cannot have consecutive periods.
38+
* `rule` - (Required) Rule to apply. Value must be one of "private", "public-read", "public-read-write", "authenticated-read".
39+
* `grants` - List of member who grants this rule. Consists of `grantee`, `permission`. Individual `grantee` has `type`, `display_name`, `email-address`, `id`, `uri` attributes.
40+
* `owner` - Who owns this ACL.
41+
42+
## Import
43+
44+
### `terraform import` command
45+
46+
* Object Storage Bucket ACL can be imported using the `bucket_name`. For example:
47+
48+
```console
49+
$ terraform import ncloud_objectstorage_bucket_acl.rsc_name bucket_acl_bucket-name
50+
```
51+
52+
### `import` block
53+
54+
* In Terraform v1.5.0 and later, use a [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Object Storage Bucket ACL using the `id`. For example:
55+
56+
```terraform
57+
import {
58+
to = ncloud_objectstorage_bucket_acl.rsc_name
59+
bucket_name = "bucket_acl_bucket-name"
60+
}
61+
```
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
subcategory: "Object Storage"
3+
---
4+
5+
6+
# Resource: ncloud_objectstorage_object
7+
8+
Provides Object Storage Object service resource.
9+
10+
~> **NOTE:** This resource is platform independent. Does not need VPC configuration.
11+
12+
## Example Usage
13+
14+
```terraform
15+
provider "ncloud" {
16+
support_vpc = true
17+
access_key = var.access_key
18+
secret_key = var.secret_key
19+
region = var.region
20+
}
21+
22+
resource "ncloud_objectstorage_bucket" "testing_bucket" {
23+
bucket_name = "your-bucket-name"
24+
}
25+
26+
resource "ncloud_objectstorage_object" "testing_object" {
27+
bucket = ncloud_objectstorage_bucket.testing_bucket.bucket_name
28+
key = "your-object-key"
29+
source = "path/to/file"
30+
}
31+
```
32+
33+
## Argument Reference
34+
35+
The following arguments are required:
36+
37+
* `bucket` - (Required) Name of the bucket to read the object from. Bucket name must be between 3 and 63 characters long, can contain lowercase letters, numbers, periods, and hyphens. It must start and end with a letter or number, and cannot have consecutive periods.
38+
* `key` - (Required) Full path to the object inside the bucket.
39+
* `source` - (Required) Path to the file you want to upload.
40+
41+
The following arguments are optional:
42+
43+
* `bucket_key_enabled` - (Optional) Whether this resource uses Ncloud KMS Keys for SSE.
44+
* `content_encoding` - (Optional) Content encodings that have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field. Read [w3c content encoding](https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11) for further information.
45+
* `content_language` - (Optional) Language the content is in e.g., en-US or en-GB.
46+
* `content_type` - (Optional) Standard MIME type describing the format of the object data, e.g., application/octet-stream. All Valid MIME Types are valid for this input.
47+
* `website_redirect_location` - (Optional) Target URL for website redirect.
48+
49+
## Attribute Reference.
50+
51+
~> **NOTE:** Since Ncloud Object Stroage uses S3 Compatible SDK, these arguments are served as best-effort.
52+
53+
This resource exports the following attributes in addition to the arguments above:
54+
55+
* `accept_ranges` - Indicates that a range of bytes was specified.
56+
* `content_length` - Size of the body in bytes.
57+
* `etag` - ETag generated for the object (an MD5 sum of the object content). For plaintext objects or objects encrypted with an AWS-managed key, the hash is an MD5 digest of the object data. For objects encrypted with a KMS key or objects created by either the Multipart Upload or Part Copy operation, the hash is not an MD5 digest, regardless of the method of encryption. More information on possible values can be found on [Common Response Headers](https://docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonResponseHeaders.html).
58+
* `expiration` - the object expiration is configured, the response includes this header. It includes the expiry-date and rule-id key-value pairs providing object expiration information. The value of the rule-id is URL-encoded.
59+
* `last_modified` - Date and time when the object was last modified.
60+
* `parts_count` - The count of parts this object has. This value is only returned if you specify partNumber in your request and the object was uploaded as a multipart upload.
61+
* `version_id` - Unique version ID value for the object, if bucket versioning is enabled.
62+
63+
## Import
64+
65+
### `terraform import` command
66+
67+
* Object Storage Object can be imported using the `id`. For example:
68+
69+
```console
70+
$ terraform import ncloud_objectstorage_object.rsc_name bucket-name/key
71+
```
72+
73+
### `import` block
74+
75+
* In Terraform v1.5.0 and later, use a [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Object Storage Object using the `id`. For example:
76+
77+
```terraform
78+
import {
79+
to = ncloud_objectstorage_object.rsc_name
80+
id = "bucket-name/key"
81+
}
82+
```
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
subcategory: "Object Storage"
3+
---
4+
5+
6+
# Resource: ncloud_objectstorage_object_acl
7+
8+
Provides Object Storage Object ACL service resource.
9+
10+
~> **NOTE:** This resource is platform independent. Does not need VPC configuration.
11+
12+
## Example Usage
13+
14+
```terraform
15+
provider "ncloud" {
16+
support_vpc = true
17+
access_key = var.access_key
18+
secret_key = var.secret_key
19+
region = var.region
20+
}
21+
22+
resource "ncloud_objectstorage_bucket" "testing_bucket" {
23+
bucket_name = "your-bucket-name"
24+
}
25+
26+
resource "ncloud_objectstorage_object" "testing_object" {
27+
bucket = ncloud_objectstorage_bucket.testing_bucket.bucket_name
28+
key = "your-object-key"
29+
source = "path/to/file"
30+
}
31+
32+
resource "ncloud_objectstorage_object_acl" "testing_acl" {
33+
object_id = ncloud_objectstorage_object.testing_object.id
34+
rule = "RULL_TO_APPLY"
35+
}
36+
```
37+
38+
## Argument Reference
39+
40+
The following arguments are supported:
41+
42+
* `id` - Unique ID for ACL. Has format of `object_acl_${object_id}`.
43+
* `object_id` - (Required) Target object id to create.
44+
* `rule` - (Required) Rule to apply. Value must be one of "private", "public-read", "public-read-write", "authenticated-read".
45+
* `grants` - List of member who grants this rule. Consists of `grantee`, `permission`. Individual `grantee` has `type`, `display_name`, `email-address`, `id`, `uri` attributes.
46+
* `owner_id` - ID of owner.
47+
* `owner_displayname` - Name of owner.
48+
49+
## Import
50+
51+
### `terraform import` command
52+
53+
* Object Storage Object ACL can be imported using the `id`. For example:
54+
55+
```console
56+
$ terraform import ncloud_objectstorage_object_acl.rsc_name object_acl_objectID
57+
```
58+
59+
### `import` block
60+
61+
* In Terraform v1.5.0 and later, use a [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Object Storage Bucket ACL using the `id`. For example:
62+
63+
```terraform
64+
import {
65+
to = ncloud_objectstorage_object_acl.rsc_name
66+
id = "object_acl_objectID"
67+
}
68+
```

0 commit comments

Comments
 (0)