1. Packages
  2. Cloudflare Provider
  3. API Docs
  4. R2BucketCors
Cloudflare v6.1.2 published on Monday, Apr 28, 2025 by Pulumi

cloudflare.R2BucketCors

Explore with Pulumi AI

cloudflare logo
Cloudflare v6.1.2 published on Monday, Apr 28, 2025 by Pulumi

    Example Usage

    Coming soon!
    
    Coming soon!
    
    Coming soon!
    
    Coming soon!
    
    Coming soon!
    
    resources:
      exampleR2BucketCors:
        type: cloudflare:R2BucketCors
        name: example_r2_bucket_cors
        properties:
          accountId: 023e105f4ecef8ad9ca31a8372d0c353
          bucketName: example-bucket
          rules:
            - allowed:
                methods:
                  - GET
                origins:
                  - http://localhost:3000
                headers:
                  - x-requested-by
              id: Allow Local Development
              expose_headers:
                - Content-Encoding
              max_age_seconds: 3600
    

    Create R2BucketCors Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new R2BucketCors(name: string, args: R2BucketCorsArgs, opts?: CustomResourceOptions);
    @overload
    def R2BucketCors(resource_name: str,
                     args: R2BucketCorsArgs,
                     opts: Optional[ResourceOptions] = None)
    
    @overload
    def R2BucketCors(resource_name: str,
                     opts: Optional[ResourceOptions] = None,
                     account_id: Optional[str] = None,
                     bucket_name: Optional[str] = None,
                     jurisdiction: Optional[str] = None,
                     rules: Optional[Sequence[R2BucketCorsRuleArgs]] = None)
    func NewR2BucketCors(ctx *Context, name string, args R2BucketCorsArgs, opts ...ResourceOption) (*R2BucketCors, error)
    public R2BucketCors(string name, R2BucketCorsArgs args, CustomResourceOptions? opts = null)
    public R2BucketCors(String name, R2BucketCorsArgs args)
    public R2BucketCors(String name, R2BucketCorsArgs args, CustomResourceOptions options)
    
    type: cloudflare:R2BucketCors
    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 R2BucketCorsArgs
    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 R2BucketCorsArgs
    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 R2BucketCorsArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args R2BucketCorsArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args R2BucketCorsArgs
    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 r2bucketCorsResource = new Cloudflare.R2BucketCors("r2bucketCorsResource", new()
    {
        AccountId = "string",
        BucketName = "string",
        Jurisdiction = "string",
        Rules = new[]
        {
            new Cloudflare.Inputs.R2BucketCorsRuleArgs
            {
                Allowed = new Cloudflare.Inputs.R2BucketCorsRuleAllowedArgs
                {
                    Methods = new[]
                    {
                        "string",
                    },
                    Origins = new[]
                    {
                        "string",
                    },
                    Headers = new[]
                    {
                        "string",
                    },
                },
                ExposeHeaders = new[]
                {
                    "string",
                },
                Id = "string",
                MaxAgeSeconds = 0,
            },
        },
    });
    
    example, err := cloudflare.NewR2BucketCors(ctx, "r2bucketCorsResource", &cloudflare.R2BucketCorsArgs{
    	AccountId:    pulumi.String("string"),
    	BucketName:   pulumi.String("string"),
    	Jurisdiction: pulumi.String("string"),
    	Rules: cloudflare.R2BucketCorsRuleArray{
    		&cloudflare.R2BucketCorsRuleArgs{
    			Allowed: &cloudflare.R2BucketCorsRuleAllowedArgs{
    				Methods: pulumi.StringArray{
    					pulumi.String("string"),
    				},
    				Origins: pulumi.StringArray{
    					pulumi.String("string"),
    				},
    				Headers: pulumi.StringArray{
    					pulumi.String("string"),
    				},
    			},
    			ExposeHeaders: pulumi.StringArray{
    				pulumi.String("string"),
    			},
    			Id:            pulumi.String("string"),
    			MaxAgeSeconds: pulumi.Float64(0),
    		},
    	},
    })
    
    var r2bucketCorsResource = new R2BucketCors("r2bucketCorsResource", R2BucketCorsArgs.builder()
        .accountId("string")
        .bucketName("string")
        .jurisdiction("string")
        .rules(R2BucketCorsRuleArgs.builder()
            .allowed(R2BucketCorsRuleAllowedArgs.builder()
                .methods("string")
                .origins("string")
                .headers("string")
                .build())
            .exposeHeaders("string")
            .id("string")
            .maxAgeSeconds(0)
            .build())
        .build());
    
    r2bucket_cors_resource = cloudflare.R2BucketCors("r2bucketCorsResource",
        account_id="string",
        bucket_name="string",
        jurisdiction="string",
        rules=[{
            "allowed": {
                "methods": ["string"],
                "origins": ["string"],
                "headers": ["string"],
            },
            "expose_headers": ["string"],
            "id": "string",
            "max_age_seconds": 0,
        }])
    
    const r2bucketCorsResource = new cloudflare.R2BucketCors("r2bucketCorsResource", {
        accountId: "string",
        bucketName: "string",
        jurisdiction: "string",
        rules: [{
            allowed: {
                methods: ["string"],
                origins: ["string"],
                headers: ["string"],
            },
            exposeHeaders: ["string"],
            id: "string",
            maxAgeSeconds: 0,
        }],
    });
    
    type: cloudflare:R2BucketCors
    properties:
        accountId: string
        bucketName: string
        jurisdiction: string
        rules:
            - allowed:
                headers:
                    - string
                methods:
                    - string
                origins:
                    - string
              exposeHeaders:
                - string
              id: string
              maxAgeSeconds: 0
    

    R2BucketCors 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 R2BucketCors resource accepts the following input properties:

    AccountId string
    Account ID
    BucketName string
    Name of the bucket
    Jurisdiction string
    Jurisdiction of the bucket
    Rules List<R2BucketCorsRule>
    AccountId string
    Account ID
    BucketName string
    Name of the bucket
    Jurisdiction string
    Jurisdiction of the bucket
    Rules []R2BucketCorsRuleArgs
    accountId String
    Account ID
    bucketName String
    Name of the bucket
    jurisdiction String
    Jurisdiction of the bucket
    rules List<R2BucketCorsRule>
    accountId string
    Account ID
    bucketName string
    Name of the bucket
    jurisdiction string
    Jurisdiction of the bucket
    rules R2BucketCorsRule[]
    account_id str
    Account ID
    bucket_name str
    Name of the bucket
    jurisdiction str
    Jurisdiction of the bucket
    rules Sequence[R2BucketCorsRuleArgs]
    accountId String
    Account ID
    bucketName String
    Name of the bucket
    jurisdiction String
    Jurisdiction of the bucket
    rules List<Property Map>

    Outputs

    All input properties are implicitly available as output properties. Additionally, the R2BucketCors 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 R2BucketCors Resource

    Get an existing R2BucketCors 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?: R2BucketCorsState, opts?: CustomResourceOptions): R2BucketCors
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            account_id: Optional[str] = None,
            bucket_name: Optional[str] = None,
            jurisdiction: Optional[str] = None,
            rules: Optional[Sequence[R2BucketCorsRuleArgs]] = None) -> R2BucketCors
    func GetR2BucketCors(ctx *Context, name string, id IDInput, state *R2BucketCorsState, opts ...ResourceOption) (*R2BucketCors, error)
    public static R2BucketCors Get(string name, Input<string> id, R2BucketCorsState? state, CustomResourceOptions? opts = null)
    public static R2BucketCors get(String name, Output<String> id, R2BucketCorsState state, CustomResourceOptions options)
    resources:  _:    type: cloudflare:R2BucketCors    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.
    The following state arguments are supported:
    AccountId string
    Account ID
    BucketName string
    Name of the bucket
    Jurisdiction string
    Jurisdiction of the bucket
    Rules List<R2BucketCorsRule>
    AccountId string
    Account ID
    BucketName string
    Name of the bucket
    Jurisdiction string
    Jurisdiction of the bucket
    Rules []R2BucketCorsRuleArgs
    accountId String
    Account ID
    bucketName String
    Name of the bucket
    jurisdiction String
    Jurisdiction of the bucket
    rules List<R2BucketCorsRule>
    accountId string
    Account ID
    bucketName string
    Name of the bucket
    jurisdiction string
    Jurisdiction of the bucket
    rules R2BucketCorsRule[]
    account_id str
    Account ID
    bucket_name str
    Name of the bucket
    jurisdiction str
    Jurisdiction of the bucket
    rules Sequence[R2BucketCorsRuleArgs]
    accountId String
    Account ID
    bucketName String
    Name of the bucket
    jurisdiction String
    Jurisdiction of the bucket
    rules List<Property Map>

    Supporting Types

    R2BucketCorsRule, R2BucketCorsRuleArgs

    Allowed R2BucketCorsRuleAllowed
    Object specifying allowed origins, methods and headers for this CORS rule.
    ExposeHeaders List<string>
    Specifies the headers that can be exposed back, and accessed by, the JavaScript making the cross-origin request. If you need to access headers beyond the safelisted response headers, such as Content-Encoding or cf-cache-status, you must specify it here.
    Id string
    Identifier for this rule
    MaxAgeSeconds double
    Specifies the amount of time (in seconds) browsers are allowed to cache CORS preflight responses. Browsers may limit this to 2 hours or less, even if the maximum value (86400) is specified.
    Allowed R2BucketCorsRuleAllowed
    Object specifying allowed origins, methods and headers for this CORS rule.
    ExposeHeaders []string
    Specifies the headers that can be exposed back, and accessed by, the JavaScript making the cross-origin request. If you need to access headers beyond the safelisted response headers, such as Content-Encoding or cf-cache-status, you must specify it here.
    Id string
    Identifier for this rule
    MaxAgeSeconds float64
    Specifies the amount of time (in seconds) browsers are allowed to cache CORS preflight responses. Browsers may limit this to 2 hours or less, even if the maximum value (86400) is specified.
    allowed R2BucketCorsRuleAllowed
    Object specifying allowed origins, methods and headers for this CORS rule.
    exposeHeaders List<String>
    Specifies the headers that can be exposed back, and accessed by, the JavaScript making the cross-origin request. If you need to access headers beyond the safelisted response headers, such as Content-Encoding or cf-cache-status, you must specify it here.
    id String
    Identifier for this rule
    maxAgeSeconds Double
    Specifies the amount of time (in seconds) browsers are allowed to cache CORS preflight responses. Browsers may limit this to 2 hours or less, even if the maximum value (86400) is specified.
    allowed R2BucketCorsRuleAllowed
    Object specifying allowed origins, methods and headers for this CORS rule.
    exposeHeaders string[]
    Specifies the headers that can be exposed back, and accessed by, the JavaScript making the cross-origin request. If you need to access headers beyond the safelisted response headers, such as Content-Encoding or cf-cache-status, you must specify it here.
    id string
    Identifier for this rule
    maxAgeSeconds number
    Specifies the amount of time (in seconds) browsers are allowed to cache CORS preflight responses. Browsers may limit this to 2 hours or less, even if the maximum value (86400) is specified.
    allowed R2BucketCorsRuleAllowed
    Object specifying allowed origins, methods and headers for this CORS rule.
    expose_headers Sequence[str]
    Specifies the headers that can be exposed back, and accessed by, the JavaScript making the cross-origin request. If you need to access headers beyond the safelisted response headers, such as Content-Encoding or cf-cache-status, you must specify it here.
    id str
    Identifier for this rule
    max_age_seconds float
    Specifies the amount of time (in seconds) browsers are allowed to cache CORS preflight responses. Browsers may limit this to 2 hours or less, even if the maximum value (86400) is specified.
    allowed Property Map
    Object specifying allowed origins, methods and headers for this CORS rule.
    exposeHeaders List<String>
    Specifies the headers that can be exposed back, and accessed by, the JavaScript making the cross-origin request. If you need to access headers beyond the safelisted response headers, such as Content-Encoding or cf-cache-status, you must specify it here.
    id String
    Identifier for this rule
    maxAgeSeconds Number
    Specifies the amount of time (in seconds) browsers are allowed to cache CORS preflight responses. Browsers may limit this to 2 hours or less, even if the maximum value (86400) is specified.

    R2BucketCorsRuleAllowed, R2BucketCorsRuleAllowedArgs

    Methods List<string>
    Specifies the value for the Access-Control-Allow-Methods header R2 sets when requesting objects in a bucket from a browser.
    Origins List<string>
    Specifies the value for the Access-Control-Allow-Origin header R2 sets when requesting objects in a bucket from a browser.
    Headers List<string>
    Specifies the value for the Access-Control-Allow-Headers header R2 sets when requesting objects in this bucket from a browser. Cross-origin requests that include custom headers (e.g. x-user-id) should specify these headers as AllowedHeaders.
    Methods []string
    Specifies the value for the Access-Control-Allow-Methods header R2 sets when requesting objects in a bucket from a browser.
    Origins []string
    Specifies the value for the Access-Control-Allow-Origin header R2 sets when requesting objects in a bucket from a browser.
    Headers []string
    Specifies the value for the Access-Control-Allow-Headers header R2 sets when requesting objects in this bucket from a browser. Cross-origin requests that include custom headers (e.g. x-user-id) should specify these headers as AllowedHeaders.
    methods List<String>
    Specifies the value for the Access-Control-Allow-Methods header R2 sets when requesting objects in a bucket from a browser.
    origins List<String>
    Specifies the value for the Access-Control-Allow-Origin header R2 sets when requesting objects in a bucket from a browser.
    headers List<String>
    Specifies the value for the Access-Control-Allow-Headers header R2 sets when requesting objects in this bucket from a browser. Cross-origin requests that include custom headers (e.g. x-user-id) should specify these headers as AllowedHeaders.
    methods string[]
    Specifies the value for the Access-Control-Allow-Methods header R2 sets when requesting objects in a bucket from a browser.
    origins string[]
    Specifies the value for the Access-Control-Allow-Origin header R2 sets when requesting objects in a bucket from a browser.
    headers string[]
    Specifies the value for the Access-Control-Allow-Headers header R2 sets when requesting objects in this bucket from a browser. Cross-origin requests that include custom headers (e.g. x-user-id) should specify these headers as AllowedHeaders.
    methods Sequence[str]
    Specifies the value for the Access-Control-Allow-Methods header R2 sets when requesting objects in a bucket from a browser.
    origins Sequence[str]
    Specifies the value for the Access-Control-Allow-Origin header R2 sets when requesting objects in a bucket from a browser.
    headers Sequence[str]
    Specifies the value for the Access-Control-Allow-Headers header R2 sets when requesting objects in this bucket from a browser. Cross-origin requests that include custom headers (e.g. x-user-id) should specify these headers as AllowedHeaders.
    methods List<String>
    Specifies the value for the Access-Control-Allow-Methods header R2 sets when requesting objects in a bucket from a browser.
    origins List<String>
    Specifies the value for the Access-Control-Allow-Origin header R2 sets when requesting objects in a bucket from a browser.
    headers List<String>
    Specifies the value for the Access-Control-Allow-Headers header R2 sets when requesting objects in this bucket from a browser. Cross-origin requests that include custom headers (e.g. x-user-id) should specify these headers as AllowedHeaders.

    Package Details

    Repository
    Cloudflare pulumi/pulumi-cloudflare
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the cloudflare Terraform Provider.
    cloudflare logo
    Cloudflare v6.1.2 published on Monday, Apr 28, 2025 by Pulumi