ksyun_ks3_bucket

最近更新时间:2019-12-23 11:27:22

ksyun_ks3_bucket

Provides a resource to create a KS3 bucket and set its attributes.

Note: The bucket namespace is shared by all KS3 users and each bucket must have a unique name.

Example Usage

Creating a bucket

resource "ksyun_ks3" "bucket-create" {
  bucket = "ks3-bucket-create"
}

Changing the bucket ACL

resource "ksyun_ks3" "bucket-acl" {
  bucket = "ks3-bucket-acl"
  acl    = "private"
}

Enabling bucket logging

resource "ksyun_ks3" "bucket-target" {
  bucket = "ks3-bucket-target"
  acl    = "public-read"
}

resource "ksyun_ks3" "bucket-logging" {
  bucket = "ks3-bucket-logging"

  logging {
    target_bucket = "${ksyun_ks3.bucket-target.id}"
  }
}

Setting the bucket CORS

resource "ksyun_ks3" "bucket-cors" {
  bucket = "ks3-bucket-cors"
  acl    = "public-read"

  cors_rule {
    allowed_header = ["*"]
    allowed_method = ["PUT", "POST"]
    allowed_origin = ["https://www.example.com"]
    expose_header  = ["ETag"]
    max_age_seconds = 3000
  }
}

Argument Reference

The following arguments are supported:

  • bucket - (Required) The name of the bucket. If omitted, Terraform will assign a random, unique name.
  • acl - (Optional) The canned ACL to apply. The default value is private.
  • cors_rule - (Optional) A rule of Cross-Origin Resource Sharing.
    • allowed_header - (Optional) A list of allowed headers.
    • allowed_method - (Required) A list of allowed methods. Valid values are GET, PUT, POST, DELETE, and HEAD.
    • allowed_origin - (Required) A list of allowed origins.
    • expose_header - (Optional) Whether or not to expose the header in the response.
    • max_age_seconds - (Optional) The time duration, in seconds, that the browser can cache the response for a preflight request.
  • logging - (Optional) Bucket logging settings.
    • target_bucket - (Required) The name of the bucket that will receive the log objects.
    • target_prefix - (Optional) The key prefix for the log objects.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - The name of the bucket.
  • type - The storage type of the bucket.

Import

KS3 bucket can be imported using the bucket name, e.g.

$ terraform import ksyun_ks3.example bucket-12345678

金山云,开启您的云计算之旅

注册有礼