Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Object Storage service #439

Merged
merged 78 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
55daed1
chore: Upgrade Go version to v1.21
Geun-Oh Sep 6, 2024
5045963
chore: Install AWS SDK for Object Storage API
Geun-Oh Aug 20, 2024
a25060f
feat: Add S3 Client configuration
Geun-Oh Aug 20, 2024
e1ab32e
feat: Add Object Storage Resources
Geun-Oh Aug 20, 2024
0b9aac9
feat: Add objectstorage_bucket resource
Geun-Oh Aug 20, 2024
39f5027
feat: Add objectstorage_bucket_acl resource
Geun-Oh Aug 20, 2024
fbadb00
feat: Add objectstorage_object resource
Geun-Oh Aug 20, 2024
b17b322
feat: Add objectstorage_object_acl resource
Geun-Oh Aug 20, 2024
607ab82
fix: add "_bucket" suffix to bucket resource
Geun-Oh Aug 20, 2024
6527e61
feat: Add examples of object storage
Geun-Oh Aug 20, 2024
e8281b4
docs: Add initial documentation of object storage
Geun-Oh Aug 20, 2024
2b5d7c4
feat: add type casting function for nested listValue
Geun-Oh Aug 20, 2024
62f82f9
feat: Add BucketRegion to bucket chema
Geun-Oh Aug 20, 2024
56fd61f
fix: Add detailed schema of grants & type casting method
Geun-Oh Aug 20, 2024
20535fd
chore: Add error exception
Geun-Oh Aug 20, 2024
6c0312c
feat: Add regex validator for resource id
Geun-Oh Aug 21, 2024
4210c55
chore: remove redundant EOL
Geun-Oh Aug 21, 2024
648346b
fix: Remove BucketName, BucketRegion from schema(doesn't provided)
Geun-Oh Aug 21, 2024
a72837a
refactor: Add TrimForIDParsing util
Geun-Oh Aug 21, 2024
fccf4f3
feat: Add temporary file creation logic
Geun-Oh Aug 21, 2024
1cda6ee
feat: Add aclOptions for testing
Geun-Oh Aug 21, 2024
c4777f4
fix: Removed Unavailable object acl
Geun-Oh Aug 21, 2024
f2c5f37
feat: Add Bucket data source
Geun-Oh Aug 21, 2024
dbd38eb
fix: Add new bucket creation for independant testing
Geun-Oh Aug 21, 2024
d4883cb
fix: aws.String => ncloud.String
Geun-Oh Aug 21, 2024
d5c5dce
chore: fix typo
Geun-Oh Aug 21, 2024
22c3e67
chore: change string value with constants
Geun-Oh Aug 21, 2024
915d9a3
refactor: expand TrimForParsing to parse vairous strings (not only ID)
Geun-Oh Aug 21, 2024
84a8961
feat: use region info from initial configuration
Geun-Oh Aug 21, 2024
683ad3a
refactor: Set bucket id same as bucket name
Geun-Oh Aug 21, 2024
6833fa0
fix: Add detailed string validator with regex for bucket_name
Geun-Oh Aug 22, 2024
71b5af9
feat: Add NewObjectDataSource data source
Geun-Oh Aug 22, 2024
fa48ca7
refactor: Move ObjectIDParser to object.go
Geun-Oh Aug 22, 2024
18ceaa1
refactor: Set Object Resource ID with new format
Geun-Oh Aug 22, 2024
be14cd8
feat: set independent object testing
Geun-Oh Aug 26, 2024
b2cfe51
feat: Add Owner info & Creation Date to bucket data source
Geun-Oh Aug 26, 2024
cdfd09e
feat: Add OwnerID & OwnerDisplayname at object_acl attribute
Geun-Oh Aug 26, 2024
25a20d3
fix: set bucket_id & object_id w/o NRN
Geun-Oh Aug 27, 2024
f1f63dd
docs: Add documentation of object storage resources
Geun-Oh Aug 27, 2024
2539602
feat: Change format - make resource id with '/' in object storage - o…
Geun-Oh Aug 29, 2024
0ee7edc
feat: Add objectstorage_object_copy
Geun-Oh Aug 29, 2024
f6689bf
fix: Change to do not use pointer method
Geun-Oh Aug 29, 2024
c543c7b
docs: Add data source documentation of bucket
Geun-Oh Sep 2, 2024
ea89d83
docs: Add object_storage_object.md in data-source
Geun-Oh Sep 2, 2024
e0d703e
docs: Add object_storage_object_copy.md
Geun-Oh Sep 2, 2024
2b30533
feat: Add CreationDate attribute to bucket
Geun-Oh Sep 2, 2024
715bec6
fix: fix logic to check whether output is nil
Geun-Oh Sep 2, 2024
9b62134
fix: Add format of creationDate
Geun-Oh Sep 2, 2024
c976aae
feat: Delete panic from object_copy Update
Geun-Oh Sep 4, 2024
4c3451e
feat: Remove endpoint from Config struct
Geun-Oh Sep 4, 2024
824611b
fix: Remove Optional keyword from creation_date(computed)
Geun-Oh Sep 4, 2024
4383dab
refactor: set bucket unique value from bucket_id to bucket_name
Geun-Oh Sep 4, 2024
358a3f2
fix: Remove unused headbucket
Geun-Oh Sep 5, 2024
15ec540
feat: Add bucket ID (since it uses id for default)
Geun-Oh Sep 5, 2024
bd9b740
feat: Add attributes based on HeadObjectOutput
Geun-Oh Sep 5, 2024
733c8aa
feat: Add endpoint abstract logic
Geun-Oh Sep 5, 2024
c7f5574
refactor: Move post fetch logic into refreshFromOutput
Geun-Oh Sep 5, 2024
bd4e8a0
feat: Add genEndpointWithCode (region, site)
Geun-Oh Sep 6, 2024
3c4b35c
feat: Add optional endpoint configuration
Geun-Oh Sep 6, 2024
dd88aba
feat: Add region formatting logic
Geun-Oh Sep 6, 2024
93994ba
feat: Add Optional variables compatible with aws sdk in object-kind r…
Geun-Oh Sep 6, 2024
ac78205
docs: Update docs with additional attributes
Geun-Oh Sep 6, 2024
f8da863
fix: Remove Object Encryption logic entirely
Geun-Oh Sep 6, 2024
efef7d6
feat: Add site variable in example tf code
Geun-Oh Sep 6, 2024
881475a
chore: Add Error with Diagnostics
Geun-Oh Sep 6, 2024
892eeed
refactor: remove endpoint from providerConfig
Geun-Oh Sep 6, 2024
f609de4
chore: add missed packages
Geun-Oh Sep 6, 2024
1108afa
fix: fix endpoint env to optional
Geun-Oh Sep 9, 2024
220ebfb
fix: Parse bucket info after pulling plan data
Geun-Oh Sep 9, 2024
dda5654
refactor: Abstract BucketNameValidator
Geun-Oh Sep 9, 2024
fd1e5b2
Merge branch 'main' into feat/object-storage
Geun-Oh Sep 9, 2024
417c8bb
fix: Remove optional from creation_date
Geun-Oh Sep 10, 2024
7c35540
fix: Change serverless environment => platform independent
Geun-Oh Sep 10, 2024
8c0637b
fix: change id with object_url
Geun-Oh Sep 10, 2024
6533c35
feat: Add attribute documentation
Geun-Oh Sep 10, 2024
f5a49cc
feat: Add update logic to object_acl
Geun-Oh Sep 10, 2024
b916b86
feat: Add update logic to bucket_acl
Geun-Oh Sep 10, 2024
99b8f0a
fix: Fix typo
Geun-Oh Sep 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions docs/data-sources/object_storage_bucket.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
subcategory: "Object Storage"
---

# Data Source: ncloud_objectstorage_bucket

Prvides information about a bucket.

~> **NOTE:** This resources operates in serverless environment. Does not need VPC configuration.
Geun-Oh marked this conversation as resolved.
Show resolved Hide resolved

## Example Usage

```terraform
data "ncloud_objectstorage_bucket" "test-bucket" {
bucket_name = "your-bucket"
}
```

## Argument Reference

The following arguments are required:

* `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.

## Attribute Reference

This data source exports the following attributes in addition to the arguments above:

* `owner_id` - ID of target bucket owner.
* `owner_displayname` - Display name of target bucket owner.
* `creation_date` - Date information of when this bucket created.
46 changes: 46 additions & 0 deletions docs/data-sources/object_storage_object.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
subcategory: "Object Storage"
---

# Data Source: ncloud_objectstorage_object

Prvides information about a object.

~> **NOTE:** This resources operates in serverless environment. Does not need VPC configuration.

## Example Usage

```terraform
data "ncloud_objectstorage_object" "test" {
object_id = ncloud_objectstorage_object.testing_object.id
}
```

## Argument Reference

The following arguments are required:

* `object_id` - (Required) Object id to get. same as "\${bucket_name}/${object_key}".

## Attribute Reference

~> **NOTE:** Since Ncloud Object Stroage uses S3 Compatible SDK, these arguments are served as best-effort.

This data source exports the following attributes in addition to the arguments above:

* `bucket` - Name of bucket where object belongs.
* `key` - Key of object.
* `source` - Path that informs where does object is located in bucket.
* `content_language` - Language the content is in e.g., en-US or en-GB.
* `content_length` - How long the object is.
* `content_type` - Type of the object.
* `body` - Saved content of the object.
* `bucket_key_enabled` - Whether this resource uses Ncloud KMS Keys for SSE.
* `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.
* `accept_ranges` - Indicates that a range of bytes was specified.
* `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).
* `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.
* `last_modified` - Date and time when the object was last modified.
* `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.
* `version_id` - Unique version ID value for the object, if bucket versioning is enabled.
* `website_redirect_location` - Target URL for website redirect.
52 changes: 52 additions & 0 deletions docs/resources/object_storage_bucket.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
subcategory: "Object Storage"
---


# Resource: ncloud_objectstorage_bucket

Provides Object Storage Bucket service resource.

~> **NOTE:** This resources operates in serverless environment. Does not need VPC configuration.

## Example Usage

```terraform
provider "ncloud" {
support_vpc = true
access_key = var.access_key
secret_key = var.secret_key
region = var.region
}

resource "ncloud_objectstorage_bucket" "testing_bucket" {
bucket_name = "your-bucket-name"
}
```

## Argument Reference

The following arguments are supported:

* `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.

Geun-Oh marked this conversation as resolved.
Show resolved Hide resolved
## Import

### `terraform import` command

* Object Storage Bucket can be imported using the `bucket_name`. For example:

```console
$ terraform import ncloud_objectstorage_object.rsc_name bucket-name
```

### `import` block

* 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:

```terraform
import {
to = ncloud_objectstorage_object.rsc_name
bucket_name = "bucket-name"
}
```
58 changes: 58 additions & 0 deletions docs/resources/object_storage_bucket_acl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
subcategory: "Object Storage"
---


# Resource: ncloud_objectstorage_bucket_acl

Provides Object Storage Bucket ACL service resource.

~> **NOTE:** This resources operates in serverless environment. Does not need VPC configuration.

## Example Usage

```terraform
provider "ncloud" {
support_vpc = true
access_key = var.access_key
secret_key = var.secret_key
region = var.region
}

resource "ncloud_objectstorage_bucket" "testing_bucket" {
bucket_name = "your-bucket-name"
}

resource "ncloud_objectstorage_bucket_acl" "testing_acl" {
bucket_name = ncloud_objectstorage_bucket.testing_bucket.bucket_name
rule = "RULL_TO_APPLY"
}
```

## Argument Reference

The following arguments are supported:

* `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.
* `rule` - (Required) Rule to apply. Value must be one of "private", "public-read", "public-read-write", "authenticated-read".

## Import

### `terraform import` command

* Object Storage Bucket ACL can be imported using the `bucket_name`. For example:

```console
$ terraform import ncloud_objectstorage_bucket_acl.rsc_name bucket_acl_bucket-name
```

### `import` block

* 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:

```terraform
import {
to = ncloud_objectstorage_bucket_acl.rsc_name
bucket_name = "bucket_acl_bucket-name"
}
```
82 changes: 82 additions & 0 deletions docs/resources/object_storage_object.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
subcategory: "Object Storage"
---


# Resource: ncloud_objectstorage_object

Provides Object Storage Object service resource.

~> **NOTE:** This resources operates in serverless environment. Does not need VPC configuration.

## Example Usage

```terraform
provider "ncloud" {
support_vpc = true
access_key = var.access_key
secret_key = var.secret_key
region = var.region
}

resource "ncloud_objectstorage_bucket" "testing_bucket" {
bucket_name = "your-bucket-name"
}

resource "ncloud_objectstorage_object" "testing_object" {
bucket = ncloud_objectstorage_bucket.testing_bucket.bucket_name
key = "your-object-key"
source = "path/to/file"
}
```

## Argument Reference

The following arguments are required:

* `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.
* `key` - (Required) Full path to the object inside the bucket.
* `source` - (Required) Path to the file you want to upload.

The following arguments are optional:

* `bucket_key_enabled` - (Optional) Whether this resource uses Ncloud KMS Keys for SSE.
* `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.
* `content_language` - (Optional) Language the content is in e.g., en-US or en-GB.
* `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.
* `website_redirect_location` - (Optional) Target URL for website redirect.

## Attribute Reference.

~> **NOTE:** Since Ncloud Object Stroage uses S3 Compatible SDK, these arguments are served as best-effort.

This resource exports the following attributes in addition to the arguments above:

* `accept_ranges` - Indicates that a range of bytes was specified.
* `content_length` - Size of the body in bytes.
* `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).
* `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.
* `last_modified` - Date and time when the object was last modified.
* `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.
* `version_id` - Unique version ID value for the object, if bucket versioning is enabled.

## Import

### `terraform import` command

* Object Storage Object can be imported using the `id`. For example:

```console
$ terraform import ncloud_objectstorage_object.rsc_name bucket-name/key
```

### `import` block

* 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:

```terraform
import {
to = ncloud_objectstorage_object.rsc_name
id = "bucket-name/key"
}
```
64 changes: 64 additions & 0 deletions docs/resources/object_storage_object_acl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
subcategory: "Object Storage"
---


# Resource: ncloud_objectstorage_object_acl

Provides Object Storage Object ACL service resource.

~> **NOTE:** This resources operates in serverless environment. Does not need VPC configuration.

## Example Usage

```terraform
provider "ncloud" {
support_vpc = true
access_key = var.access_key
secret_key = var.secret_key
region = var.region
}

resource "ncloud_objectstorage_bucket" "testing_bucket" {
bucket_name = "your-bucket-name"
}

resource "ncloud_objectstorage_object" "testing_object" {
bucket = ncloud_objectstorage_bucket.testing_bucket.bucket_name
key = "your-object-key"
source = "path/to/file"
}

resource "ncloud_objectstorage_object_acl" "testing_acl" {
object_id = ncloud_objectstorage_object.testing_object.id
rule = "RULL_TO_APPLY"
}
```

## Argument Reference

The following arguments are supported:

* `object_id` - (Required) Target object id to create.
* `rule` - (Required) Rule to apply. Value must be one of "private", "public-read", "public-read-write", "authenticated-read".

## Import

### `terraform import` command

* Object Storage Object ACL can be imported using the `id`. For example:

```console
$ terraform import ncloud_objectstorage_object_acl.rsc_name object_acl_objectID
```

### `import` block

* 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:

```terraform
import {
to = ncloud_objectstorage_object_acl.rsc_name
id = "object_acl_objectID"
}
```
Loading