alicloud_oss_bucket_object
更新時間:
Provides a resource to put a object(content or file) to a oss bucket.
Example Usage
Uploading a file to a bucket
resource "random_integer" "default" {
max = 99999
min = 10000
}
resource "alicloud_oss_bucket" "default" {
bucket = "terraform-example-${random_integer.default.result}"
}
resource "alicloud_oss_bucket_acl" "default" {
bucket = alicloud_oss_bucket.default.bucket
acl = "private"
}
resource "alicloud_oss_bucket_object" "default" {
bucket = alicloud_oss_bucket.default.bucket
key = "example_key"
source = "./main.tf"
}
Uploading a content to a bucket
resource "random_integer" "default" {
max = 99999
min = 10000
}
resource "alicloud_oss_bucket" "default" {
bucket = "terraform-example-${random_integer.default.result}"
}
resource "alicloud_oss_bucket_acl" "default" {
bucket = alicloud_oss_bucket.default.bucket
acl = "private"
}
resource "alicloud_oss_bucket_object" "default" {
bucket = alicloud_oss_bucket.default.bucket
key = "example_key"
content = "the content that you want to upload."
}
Argument Reference
-> Note: If you specify content_encoding
you are responsible for encoding the body appropriately (i.e. source
and content
both expect already encoded/compressed bytes)
The following arguments are supported:
bucket
- (Required, ForceNew) The name of the bucket to put the file in.key
- (Required, ForceNew) The name of the object once it is in the bucket.source
- (Optional) The path to the source file being uploaded to the bucket.content
- (Optional unlesssource
given) The literal content being uploaded to the bucket.acl
- (Optional) The canned ACL to apply. Defaults to "private".content_type
- (Optional) A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input.cache_control
- (Optional) Specifies caching behavior along the request/reply chain. Read RFC2616 Cache-Control for further details.content_disposition
- (Optional) Specifies presentational information for the object. Read RFC2616 Content-Disposition for further details.content_encoding
- (Optional) Specifies what content encodings 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 RFC2616 Content-Encoding for further details.content_md5
- (Optional) The MD5 value of the content. Read MD5 for computing method.expires
- (Optional) Specifies expire date for the the request/response. Read RFC2616 Expires for further details.server_side_encryption
- (Optional) Specifies server-side encryption of the object in OSS. Valid values areAES256
,KMS
. Default value isAES256
.kms_key_id
- (Optional, Available in 1.62.1+) Specifies the primary key managed by KMS. This parameter is valid when the value ofserver_side_encryption
is set to KMS.
Either source
or content
must be provided to specify the bucket content.
These two arguments are mutually-exclusive.
Attributes Reference
The following attributes are exported
id
- thekey
of the resource supplied above.content_length
- the content length of request.etag
- the ETag generated for the object (an MD5 sum of the object content).version_id
- A unique version ID value for the object, if bucket versioning is enabled.
文檔內容是否對您有幫助?