Performing Basic Operations
Application Scenario
Object Storage Service (OBS) is a cloud storage service optimized for storing data of any type and size. It provides unlimited, secure, and highly reliable storage capabilities at a low cost. It is suitable for various data storage scenarios, such as enterprise-level backup/archiving, video on demand (VoD), and video surveillance.
Related Resources
Procedure
- Create an OBS bucket.
- Create the main.tf file, enter the following information, and save the file:
resource "huaweicloud_obs_bucket" "myexample" { bucket = "myexample-bucket" acl = "private" tags = { type = "bucket" env = "Test" } }
- Run terraform init to initialize the environment.
- Run terraform plan to view resources.
- After you confirm that the resource information is correct, run terraform apply to start OBS bucket creation.
- Run terraform show to view the created OBS bucket.
- Create the main.tf file, enter the following information, and save the file:
- Upload objects.
- Objects can be uploaded through data flows or source files. Add the following information to the main.tf file:
# Upload an object through data flows. resource "huaweicloud_obs_bucket_object" "myobject1" { bucket = huaweicloud_obs_bucket.myexample.bucket key = "myobject1" content = "content of myobject1" content_type = "application/xml" } # Upload an object through a source file. resource "huaweicloud_obs_bucket_object" "myobject2" { bucket = huaweicloud_obs_bucket.myexample.bucket key = "myobject2" source = "hello.txt" } # Upload an object through a source file and enable server-side encryption. resource "huaweicloud_obs_bucket_object" "myobject3" { bucket = huaweicloud_obs_bucket.myexample.bucket key = "myobject3" source = "hello.txt" encryption = true }
- Run terraform plan to view resources.
- After you confirm that the resource information is correct, run terraform apply to start resource creation.
- Run terraform show to view the uploaded objects.
- Objects can be uploaded through data flows or source files. Add the following information to the main.tf file:
Resource Name |
Parameter |
Description |
---|---|---|
huaweicloud_obs_bucket |
bucket |
(Mandatory) OBS bucket name. An OBS bucket name:
|
acl |
(Optional) OBS bucket access control policy. |
|
tags |
(Optional) Bucket tag. |
|
huaweicloud_obs_bucket_object |
bucket |
(Mandatory) Bucket name. |
key |
(Mandatory) Object name. |
|
source |
(Optional) Path to the source file of the object. |
|
content |
(Optional) Data flow of the object. |
|
content_type |
(Optional) MIME type of the object. |
|
encryption |
(Optional) Whether to enable server-side encryption using keys hosted by KMS (SSE-KMS). |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.