volcengine.tos.BucketCors
Explore with Pulumi AI
Provides a resource to manage tos bucket cors
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as volcengine from "@volcengine/pulumi";
const fooBucket = new volcengine.tos.Bucket("fooBucket", {
bucketName: "tf-acc-test-bucket",
publicAcl: "private",
azRedundancy: "multi-az",
projectName: "default",
tags: [{
key: "k1",
value: "v1",
}],
});
const fooBucketCors = new volcengine.tos.BucketCors("fooBucketCors", {
bucketName: fooBucket.id,
corsRules: [
{
allowedOrigins: ["*"],
allowedMethods: [
"GET",
"POST",
],
allowedHeaders: ["Authorization"],
exposeHeaders: ["x-tos-request-id"],
maxAgeSeconds: 1500,
},
{
allowedOrigins: [
"*",
"https://www.volcengine.com",
],
allowedMethods: [
"POST",
"PUT",
"DELETE",
],
allowedHeaders: ["Authorization"],
exposeHeaders: ["x-tos-request-id"],
maxAgeSeconds: 2000,
responseVary: true,
},
],
});
import pulumi
import pulumi_volcengine as volcengine
foo_bucket = volcengine.tos.Bucket("fooBucket",
bucket_name="tf-acc-test-bucket",
public_acl="private",
az_redundancy="multi-az",
project_name="default",
tags=[volcengine.tos.BucketTagArgs(
key="k1",
value="v1",
)])
foo_bucket_cors = volcengine.tos.BucketCors("fooBucketCors",
bucket_name=foo_bucket.id,
cors_rules=[
volcengine.tos.BucketCorsCorsRuleArgs(
allowed_origins=["*"],
allowed_methods=[
"GET",
"POST",
],
allowed_headers=["Authorization"],
expose_headers=["x-tos-request-id"],
max_age_seconds=1500,
),
volcengine.tos.BucketCorsCorsRuleArgs(
allowed_origins=[
"*",
"https://www.volcengine.com",
],
allowed_methods=[
"POST",
"PUT",
"DELETE",
],
allowed_headers=["Authorization"],
expose_headers=["x-tos-request-id"],
max_age_seconds=2000,
response_vary=True,
),
])
package main
import (
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/volcengine/pulumi-volcengine/sdk/go/volcengine/tos"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
fooBucket, err := tos.NewBucket(ctx, "fooBucket", &tos.BucketArgs{
BucketName: pulumi.String("tf-acc-test-bucket"),
PublicAcl: pulumi.String("private"),
AzRedundancy: pulumi.String("multi-az"),
ProjectName: pulumi.String("default"),
Tags: tos.BucketTagArray{
&tos.BucketTagArgs{
Key: pulumi.String("k1"),
Value: pulumi.String("v1"),
},
},
})
if err != nil {
return err
}
_, err = tos.NewBucketCors(ctx, "fooBucketCors", &tos.BucketCorsArgs{
BucketName: fooBucket.ID(),
CorsRules: tos.BucketCorsCorsRuleArray{
&tos.BucketCorsCorsRuleArgs{
AllowedOrigins: pulumi.StringArray{
pulumi.String("*"),
},
AllowedMethods: pulumi.StringArray{
pulumi.String("GET"),
pulumi.String("POST"),
},
AllowedHeaders: pulumi.StringArray{
pulumi.String("Authorization"),
},
ExposeHeaders: pulumi.StringArray{
pulumi.String("x-tos-request-id"),
},
MaxAgeSeconds: pulumi.Int(1500),
},
&tos.BucketCorsCorsRuleArgs{
AllowedOrigins: pulumi.StringArray{
pulumi.String("*"),
pulumi.String("https://www.volcengine.com"),
},
AllowedMethods: pulumi.StringArray{
pulumi.String("POST"),
pulumi.String("PUT"),
pulumi.String("DELETE"),
},
AllowedHeaders: pulumi.StringArray{
pulumi.String("Authorization"),
},
ExposeHeaders: pulumi.StringArray{
pulumi.String("x-tos-request-id"),
},
MaxAgeSeconds: pulumi.Int(2000),
ResponseVary: pulumi.Bool(true),
},
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Volcengine = Pulumi.Volcengine;
return await Deployment.RunAsync(() =>
{
var fooBucket = new Volcengine.Tos.Bucket("fooBucket", new()
{
BucketName = "tf-acc-test-bucket",
PublicAcl = "private",
AzRedundancy = "multi-az",
ProjectName = "default",
Tags = new[]
{
new Volcengine.Tos.Inputs.BucketTagArgs
{
Key = "k1",
Value = "v1",
},
},
});
var fooBucketCors = new Volcengine.Tos.BucketCors("fooBucketCors", new()
{
BucketName = fooBucket.Id,
CorsRules = new[]
{
new Volcengine.Tos.Inputs.BucketCorsCorsRuleArgs
{
AllowedOrigins = new[]
{
"*",
},
AllowedMethods = new[]
{
"GET",
"POST",
},
AllowedHeaders = new[]
{
"Authorization",
},
ExposeHeaders = new[]
{
"x-tos-request-id",
},
MaxAgeSeconds = 1500,
},
new Volcengine.Tos.Inputs.BucketCorsCorsRuleArgs
{
AllowedOrigins = new[]
{
"*",
"https://www.volcengine.com",
},
AllowedMethods = new[]
{
"POST",
"PUT",
"DELETE",
},
AllowedHeaders = new[]
{
"Authorization",
},
ExposeHeaders = new[]
{
"x-tos-request-id",
},
MaxAgeSeconds = 2000,
ResponseVary = true,
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.volcengine.tos.Bucket;
import com.pulumi.volcengine.tos.BucketArgs;
import com.pulumi.volcengine.tos.inputs.BucketTagArgs;
import com.pulumi.volcengine.tos.BucketCors;
import com.pulumi.volcengine.tos.BucketCorsArgs;
import com.pulumi.volcengine.tos.inputs.BucketCorsCorsRuleArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var fooBucket = new Bucket("fooBucket", BucketArgs.builder()
.bucketName("tf-acc-test-bucket")
.publicAcl("private")
.azRedundancy("multi-az")
.projectName("default")
.tags(BucketTagArgs.builder()
.key("k1")
.value("v1")
.build())
.build());
var fooBucketCors = new BucketCors("fooBucketCors", BucketCorsArgs.builder()
.bucketName(fooBucket.id())
.corsRules(
BucketCorsCorsRuleArgs.builder()
.allowedOrigins("*")
.allowedMethods(
"GET",
"POST")
.allowedHeaders("Authorization")
.exposeHeaders("x-tos-request-id")
.maxAgeSeconds(1500)
.build(),
BucketCorsCorsRuleArgs.builder()
.allowedOrigins(
"*",
"https://www.volcengine.com")
.allowedMethods(
"POST",
"PUT",
"DELETE")
.allowedHeaders("Authorization")
.exposeHeaders("x-tos-request-id")
.maxAgeSeconds(2000)
.responseVary(true)
.build())
.build());
}
}
resources:
fooBucket:
type: volcengine:tos:Bucket
properties:
bucketName: tf-acc-test-bucket
publicAcl: private
azRedundancy: multi-az
projectName: default
tags:
- key: k1
value: v1
fooBucketCors:
type: volcengine:tos:BucketCors
properties:
bucketName: ${fooBucket.id}
corsRules:
- allowedOrigins:
- '*'
allowedMethods:
- GET
- POST
allowedHeaders:
- Authorization
exposeHeaders:
- x-tos-request-id
maxAgeSeconds: 1500
- allowedOrigins:
- '*'
- https://www.volcengine.com
allowedMethods:
- POST
- PUT
- DELETE
allowedHeaders:
- Authorization
exposeHeaders:
- x-tos-request-id
maxAgeSeconds: 2000
responseVary: true
Create BucketCors Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new BucketCors(name: string, args: BucketCorsArgs, opts?: CustomResourceOptions);
@overload
def BucketCors(resource_name: str,
args: BucketCorsArgs,
opts: Optional[ResourceOptions] = None)
@overload
def BucketCors(resource_name: str,
opts: Optional[ResourceOptions] = None,
bucket_name: Optional[str] = None,
cors_rules: Optional[Sequence[BucketCorsCorsRuleArgs]] = None)
func NewBucketCors(ctx *Context, name string, args BucketCorsArgs, opts ...ResourceOption) (*BucketCors, error)
public BucketCors(string name, BucketCorsArgs args, CustomResourceOptions? opts = null)
public BucketCors(String name, BucketCorsArgs args)
public BucketCors(String name, BucketCorsArgs args, CustomResourceOptions options)
type: volcengine:tos:BucketCors
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args BucketCorsArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args BucketCorsArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args BucketCorsArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args BucketCorsArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args BucketCorsArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var bucketCorsResource = new Volcengine.Tos.BucketCors("bucketCorsResource", new()
{
BucketName = "string",
CorsRules = new[]
{
new Volcengine.Tos.Inputs.BucketCorsCorsRuleArgs
{
AllowedMethods = new[]
{
"string",
},
AllowedOrigins = new[]
{
"string",
},
AllowedHeaders = new[]
{
"string",
},
ExposeHeaders = new[]
{
"string",
},
MaxAgeSeconds = 0,
ResponseVary = false,
},
},
});
example, err := tos.NewBucketCors(ctx, "bucketCorsResource", &tos.BucketCorsArgs{
BucketName: pulumi.String("string"),
CorsRules: tos.BucketCorsCorsRuleArray{
&tos.BucketCorsCorsRuleArgs{
AllowedMethods: pulumi.StringArray{
pulumi.String("string"),
},
AllowedOrigins: pulumi.StringArray{
pulumi.String("string"),
},
AllowedHeaders: pulumi.StringArray{
pulumi.String("string"),
},
ExposeHeaders: pulumi.StringArray{
pulumi.String("string"),
},
MaxAgeSeconds: pulumi.Int(0),
ResponseVary: pulumi.Bool(false),
},
},
})
var bucketCorsResource = new BucketCors("bucketCorsResource", BucketCorsArgs.builder()
.bucketName("string")
.corsRules(BucketCorsCorsRuleArgs.builder()
.allowedMethods("string")
.allowedOrigins("string")
.allowedHeaders("string")
.exposeHeaders("string")
.maxAgeSeconds(0)
.responseVary(false)
.build())
.build());
bucket_cors_resource = volcengine.tos.BucketCors("bucketCorsResource",
bucket_name="string",
cors_rules=[{
"allowed_methods": ["string"],
"allowed_origins": ["string"],
"allowed_headers": ["string"],
"expose_headers": ["string"],
"max_age_seconds": 0,
"response_vary": False,
}])
const bucketCorsResource = new volcengine.tos.BucketCors("bucketCorsResource", {
bucketName: "string",
corsRules: [{
allowedMethods: ["string"],
allowedOrigins: ["string"],
allowedHeaders: ["string"],
exposeHeaders: ["string"],
maxAgeSeconds: 0,
responseVary: false,
}],
});
type: volcengine:tos:BucketCors
properties:
bucketName: string
corsRules:
- allowedHeaders:
- string
allowedMethods:
- string
allowedOrigins:
- string
exposeHeaders:
- string
maxAgeSeconds: 0
responseVary: false
BucketCors Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The BucketCors resource accepts the following input properties:
- Bucket
Name string - The name of the bucket.
- Cors
Rules List<BucketCors Cors Rule> - The CORS rules of the bucket.
- Bucket
Name string - The name of the bucket.
- Cors
Rules []BucketCors Cors Rule Args - The CORS rules of the bucket.
- bucket
Name String - The name of the bucket.
- cors
Rules List<BucketCors Cors Rule> - The CORS rules of the bucket.
- bucket
Name string - The name of the bucket.
- cors
Rules BucketCors Cors Rule[] - The CORS rules of the bucket.
- bucket_
name str - The name of the bucket.
- cors_
rules Sequence[BucketCors Cors Rule Args] - The CORS rules of the bucket.
- bucket
Name String - The name of the bucket.
- cors
Rules List<Property Map> - The CORS rules of the bucket.
Outputs
All input properties are implicitly available as output properties. Additionally, the BucketCors resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing BucketCors Resource
Get an existing BucketCors resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: BucketCorsState, opts?: CustomResourceOptions): BucketCors
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
bucket_name: Optional[str] = None,
cors_rules: Optional[Sequence[BucketCorsCorsRuleArgs]] = None) -> BucketCors
func GetBucketCors(ctx *Context, name string, id IDInput, state *BucketCorsState, opts ...ResourceOption) (*BucketCors, error)
public static BucketCors Get(string name, Input<string> id, BucketCorsState? state, CustomResourceOptions? opts = null)
public static BucketCors get(String name, Output<String> id, BucketCorsState state, CustomResourceOptions options)
resources: _: type: volcengine:tos:BucketCors get: id: ${id}
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Bucket
Name string - The name of the bucket.
- Cors
Rules List<BucketCors Cors Rule> - The CORS rules of the bucket.
- Bucket
Name string - The name of the bucket.
- Cors
Rules []BucketCors Cors Rule Args - The CORS rules of the bucket.
- bucket
Name String - The name of the bucket.
- cors
Rules List<BucketCors Cors Rule> - The CORS rules of the bucket.
- bucket
Name string - The name of the bucket.
- cors
Rules BucketCors Cors Rule[] - The CORS rules of the bucket.
- bucket_
name str - The name of the bucket.
- cors_
rules Sequence[BucketCors Cors Rule Args] - The CORS rules of the bucket.
- bucket
Name String - The name of the bucket.
- cors
Rules List<Property Map> - The CORS rules of the bucket.
Supporting Types
BucketCorsCorsRule, BucketCorsCorsRuleArgs
- Allowed
Methods List<string> - The list of HTTP methods that are allowed in a preflight request. Valid values:
PUT
,POST
,DELETE
,GET
,HEAD
. - Allowed
Origins List<string> - The list of origins that are allowed to make requests to the bucket.
- Allowed
Headers List<string> - The list of headers that are allowed in a preflight request.
- Expose
Headers List<string> - The list of headers that are exposed in the response to a preflight request. It is recommended to add two expose headers, X-Tos-Request-Id and ETag.
- Max
Age intSeconds - The maximum amount of time that a preflight request can be cached. Unit: second. Default value: 3600.
- Response
Vary bool - Indicates whether the bucket returns the 'Vary: Origin' header in the response to preflight requests. Default value: false.
- Allowed
Methods []string - The list of HTTP methods that are allowed in a preflight request. Valid values:
PUT
,POST
,DELETE
,GET
,HEAD
. - Allowed
Origins []string - The list of origins that are allowed to make requests to the bucket.
- Allowed
Headers []string - The list of headers that are allowed in a preflight request.
- Expose
Headers []string - The list of headers that are exposed in the response to a preflight request. It is recommended to add two expose headers, X-Tos-Request-Id and ETag.
- Max
Age intSeconds - The maximum amount of time that a preflight request can be cached. Unit: second. Default value: 3600.
- Response
Vary bool - Indicates whether the bucket returns the 'Vary: Origin' header in the response to preflight requests. Default value: false.
- allowed
Methods List<String> - The list of HTTP methods that are allowed in a preflight request. Valid values:
PUT
,POST
,DELETE
,GET
,HEAD
. - allowed
Origins List<String> - The list of origins that are allowed to make requests to the bucket.
- allowed
Headers List<String> - The list of headers that are allowed in a preflight request.
- expose
Headers List<String> - The list of headers that are exposed in the response to a preflight request. It is recommended to add two expose headers, X-Tos-Request-Id and ETag.
- max
Age IntegerSeconds - The maximum amount of time that a preflight request can be cached. Unit: second. Default value: 3600.
- response
Vary Boolean - Indicates whether the bucket returns the 'Vary: Origin' header in the response to preflight requests. Default value: false.
- allowed
Methods string[] - The list of HTTP methods that are allowed in a preflight request. Valid values:
PUT
,POST
,DELETE
,GET
,HEAD
. - allowed
Origins string[] - The list of origins that are allowed to make requests to the bucket.
- allowed
Headers string[] - The list of headers that are allowed in a preflight request.
- expose
Headers string[] - The list of headers that are exposed in the response to a preflight request. It is recommended to add two expose headers, X-Tos-Request-Id and ETag.
- max
Age numberSeconds - The maximum amount of time that a preflight request can be cached. Unit: second. Default value: 3600.
- response
Vary boolean - Indicates whether the bucket returns the 'Vary: Origin' header in the response to preflight requests. Default value: false.
- allowed_
methods Sequence[str] - The list of HTTP methods that are allowed in a preflight request. Valid values:
PUT
,POST
,DELETE
,GET
,HEAD
. - allowed_
origins Sequence[str] - The list of origins that are allowed to make requests to the bucket.
- allowed_
headers Sequence[str] - The list of headers that are allowed in a preflight request.
- expose_
headers Sequence[str] - The list of headers that are exposed in the response to a preflight request. It is recommended to add two expose headers, X-Tos-Request-Id and ETag.
- max_
age_ intseconds - The maximum amount of time that a preflight request can be cached. Unit: second. Default value: 3600.
- response_
vary bool - Indicates whether the bucket returns the 'Vary: Origin' header in the response to preflight requests. Default value: false.
- allowed
Methods List<String> - The list of HTTP methods that are allowed in a preflight request. Valid values:
PUT
,POST
,DELETE
,GET
,HEAD
. - allowed
Origins List<String> - The list of origins that are allowed to make requests to the bucket.
- allowed
Headers List<String> - The list of headers that are allowed in a preflight request.
- expose
Headers List<String> - The list of headers that are exposed in the response to a preflight request. It is recommended to add two expose headers, X-Tos-Request-Id and ETag.
- max
Age NumberSeconds - The maximum amount of time that a preflight request can be cached. Unit: second. Default value: 3600.
- response
Vary Boolean - Indicates whether the bucket returns the 'Vary: Origin' header in the response to preflight requests. Default value: false.
Import
TosBucketCors can be imported using the id, e.g.
$ pulumi import volcengine:tos/bucketCors:BucketCors default resource_id
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- volcengine volcengine/pulumi-volcengine
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
volcengine
Terraform Provider.