alicloud_oss_bucket_cors

Provides a OSS Bucket Cors resource. Cross-Origin Resource Sharing (CORS) allows web applications to access resources in other regions.

For information about OSS Bucket Cors and how to use it, see What is Bucket Cors.

Example Usage

Basic Usage

variable "name" {
  default = "terraform-example"
}

provider "alicloud" {
  region = "cn-hangzhou"
}

resource "alicloud_oss_bucket" "CreateBucket" {
  storage_class = "Standard"
  bucket        = var.name
  lifecycle {
    ignore_changes = [
      cors_rule,
    ]
  }
}


resource "alicloud_oss_bucket_cors" "default" {
  bucket        = alicloud_oss_bucket.CreateBucket.bucket
  response_vary = true
  cors_rule {
    allowed_methods = ["GET"]
    allowed_origins = ["*"]
    allowed_headers = ["x-oss-test", "x-oss-abc"]
    expose_header   = ["x-oss-request-id"]
    max_age_seconds = "1000"
  }
}

Argument Reference

The following arguments are supported:

cors_rule

The cors_rule supports the following:

Attributes Reference

The following attributes are exported:

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

Import

OSS Bucket Cors can be imported using the id, e.g.

$ terraform import alicloud_oss_bucket_cors.example <id>