1. Packages
  2. Digitalocean Provider
  3. API Docs
  4. SpacesBucketCorsConfiguration
DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi

digitalocean.SpacesBucketCorsConfiguration

Explore with Pulumi AI

digitalocean logo
DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi

    Example Usage

    Create a Key in a Spaces Bucket

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const foobar = new digitalocean.SpacesBucket("foobar", {
        name: "foobar",
        region: digitalocean.Region.NYC3,
    });
    const test = new digitalocean.SpacesBucketCorsConfiguration("test", {
        bucket: foobar.id,
        region: "nyc3",
        corsRules: [{
            allowedHeaders: ["*"],
            allowedMethods: [
                "PUT",
                "POST",
            ],
            allowedOrigins: ["https://s3-website-test.hashicorp.com"],
            exposeHeaders: ["ETag"],
            maxAgeSeconds: 3000,
        }],
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    foobar = digitalocean.SpacesBucket("foobar",
        name="foobar",
        region=digitalocean.Region.NYC3)
    test = digitalocean.SpacesBucketCorsConfiguration("test",
        bucket=foobar.id,
        region="nyc3",
        cors_rules=[{
            "allowed_headers": ["*"],
            "allowed_methods": [
                "PUT",
                "POST",
            ],
            "allowed_origins": ["https://s3-website-test.hashicorp.com"],
            "expose_headers": ["ETag"],
            "max_age_seconds": 3000,
        }])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		foobar, err := digitalocean.NewSpacesBucket(ctx, "foobar", &digitalocean.SpacesBucketArgs{
    			Name:   pulumi.String("foobar"),
    			Region: pulumi.String(digitalocean.RegionNYC3),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = digitalocean.NewSpacesBucketCorsConfiguration(ctx, "test", &digitalocean.SpacesBucketCorsConfigurationArgs{
    			Bucket: foobar.ID(),
    			Region: pulumi.String("nyc3"),
    			CorsRules: digitalocean.SpacesBucketCorsConfigurationCorsRuleArray{
    				&digitalocean.SpacesBucketCorsConfigurationCorsRuleArgs{
    					AllowedHeaders: pulumi.StringArray{
    						pulumi.String("*"),
    					},
    					AllowedMethods: pulumi.StringArray{
    						pulumi.String("PUT"),
    						pulumi.String("POST"),
    					},
    					AllowedOrigins: pulumi.StringArray{
    						pulumi.String("https://s3-website-test.hashicorp.com"),
    					},
    					ExposeHeaders: pulumi.StringArray{
    						pulumi.String("ETag"),
    					},
    					MaxAgeSeconds: pulumi.Int(3000),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using DigitalOcean = Pulumi.DigitalOcean;
    
    return await Deployment.RunAsync(() => 
    {
        var foobar = new DigitalOcean.SpacesBucket("foobar", new()
        {
            Name = "foobar",
            Region = DigitalOcean.Region.NYC3,
        });
    
        var test = new DigitalOcean.SpacesBucketCorsConfiguration("test", new()
        {
            Bucket = foobar.Id,
            Region = "nyc3",
            CorsRules = new[]
            {
                new DigitalOcean.Inputs.SpacesBucketCorsConfigurationCorsRuleArgs
                {
                    AllowedHeaders = new[]
                    {
                        "*",
                    },
                    AllowedMethods = new[]
                    {
                        "PUT",
                        "POST",
                    },
                    AllowedOrigins = new[]
                    {
                        "https://s3-website-test.hashicorp.com",
                    },
                    ExposeHeaders = new[]
                    {
                        "ETag",
                    },
                    MaxAgeSeconds = 3000,
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.digitalocean.SpacesBucket;
    import com.pulumi.digitalocean.SpacesBucketArgs;
    import com.pulumi.digitalocean.SpacesBucketCorsConfiguration;
    import com.pulumi.digitalocean.SpacesBucketCorsConfigurationArgs;
    import com.pulumi.digitalocean.inputs.SpacesBucketCorsConfigurationCorsRuleArgs;
    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 foobar = new SpacesBucket("foobar", SpacesBucketArgs.builder()
                .name("foobar")
                .region("nyc3")
                .build());
    
            var test = new SpacesBucketCorsConfiguration("test", SpacesBucketCorsConfigurationArgs.builder()
                .bucket(foobar.id())
                .region("nyc3")
                .corsRules(SpacesBucketCorsConfigurationCorsRuleArgs.builder()
                    .allowedHeaders("*")
                    .allowedMethods(                
                        "PUT",
                        "POST")
                    .allowedOrigins("https://s3-website-test.hashicorp.com")
                    .exposeHeaders("ETag")
                    .maxAgeSeconds(3000)
                    .build())
                .build());
    
        }
    }
    
    resources:
      foobar:
        type: digitalocean:SpacesBucket
        properties:
          name: foobar
          region: nyc3
      test:
        type: digitalocean:SpacesBucketCorsConfiguration
        properties:
          bucket: ${foobar.id}
          region: nyc3
          corsRules:
            - allowedHeaders:
                - '*'
              allowedMethods:
                - PUT
                - POST
              allowedOrigins:
                - https://s3-website-test.hashicorp.com
              exposeHeaders:
                - ETag
              maxAgeSeconds: 3000
    

    Create SpacesBucketCorsConfiguration Resource

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

    Constructor syntax

    new SpacesBucketCorsConfiguration(name: string, args: SpacesBucketCorsConfigurationArgs, opts?: CustomResourceOptions);
    @overload
    def SpacesBucketCorsConfiguration(resource_name: str,
                                      args: SpacesBucketCorsConfigurationArgs,
                                      opts: Optional[ResourceOptions] = None)
    
    @overload
    def SpacesBucketCorsConfiguration(resource_name: str,
                                      opts: Optional[ResourceOptions] = None,
                                      bucket: Optional[str] = None,
                                      cors_rules: Optional[Sequence[SpacesBucketCorsConfigurationCorsRuleArgs]] = None,
                                      region: Optional[str] = None)
    func NewSpacesBucketCorsConfiguration(ctx *Context, name string, args SpacesBucketCorsConfigurationArgs, opts ...ResourceOption) (*SpacesBucketCorsConfiguration, error)
    public SpacesBucketCorsConfiguration(string name, SpacesBucketCorsConfigurationArgs args, CustomResourceOptions? opts = null)
    public SpacesBucketCorsConfiguration(String name, SpacesBucketCorsConfigurationArgs args)
    public SpacesBucketCorsConfiguration(String name, SpacesBucketCorsConfigurationArgs args, CustomResourceOptions options)
    
    type: digitalocean:SpacesBucketCorsConfiguration
    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 SpacesBucketCorsConfigurationArgs
    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 SpacesBucketCorsConfigurationArgs
    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 SpacesBucketCorsConfigurationArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SpacesBucketCorsConfigurationArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args SpacesBucketCorsConfigurationArgs
    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 spacesBucketCorsConfigurationResource = new DigitalOcean.SpacesBucketCorsConfiguration("spacesBucketCorsConfigurationResource", new()
    {
        Bucket = "string",
        CorsRules = new[]
        {
            new DigitalOcean.Inputs.SpacesBucketCorsConfigurationCorsRuleArgs
            {
                AllowedMethods = new[]
                {
                    "string",
                },
                AllowedOrigins = new[]
                {
                    "string",
                },
                AllowedHeaders = new[]
                {
                    "string",
                },
                ExposeHeaders = new[]
                {
                    "string",
                },
                Id = "string",
                MaxAgeSeconds = 0,
            },
        },
        Region = "string",
    });
    
    example, err := digitalocean.NewSpacesBucketCorsConfiguration(ctx, "spacesBucketCorsConfigurationResource", &digitalocean.SpacesBucketCorsConfigurationArgs{
    	Bucket: pulumi.String("string"),
    	CorsRules: digitalocean.SpacesBucketCorsConfigurationCorsRuleArray{
    		&digitalocean.SpacesBucketCorsConfigurationCorsRuleArgs{
    			AllowedMethods: pulumi.StringArray{
    				pulumi.String("string"),
    			},
    			AllowedOrigins: pulumi.StringArray{
    				pulumi.String("string"),
    			},
    			AllowedHeaders: pulumi.StringArray{
    				pulumi.String("string"),
    			},
    			ExposeHeaders: pulumi.StringArray{
    				pulumi.String("string"),
    			},
    			Id:            pulumi.String("string"),
    			MaxAgeSeconds: pulumi.Int(0),
    		},
    	},
    	Region: pulumi.String("string"),
    })
    
    var spacesBucketCorsConfigurationResource = new SpacesBucketCorsConfiguration("spacesBucketCorsConfigurationResource", SpacesBucketCorsConfigurationArgs.builder()
        .bucket("string")
        .corsRules(SpacesBucketCorsConfigurationCorsRuleArgs.builder()
            .allowedMethods("string")
            .allowedOrigins("string")
            .allowedHeaders("string")
            .exposeHeaders("string")
            .id("string")
            .maxAgeSeconds(0)
            .build())
        .region("string")
        .build());
    
    spaces_bucket_cors_configuration_resource = digitalocean.SpacesBucketCorsConfiguration("spacesBucketCorsConfigurationResource",
        bucket="string",
        cors_rules=[{
            "allowed_methods": ["string"],
            "allowed_origins": ["string"],
            "allowed_headers": ["string"],
            "expose_headers": ["string"],
            "id": "string",
            "max_age_seconds": 0,
        }],
        region="string")
    
    const spacesBucketCorsConfigurationResource = new digitalocean.SpacesBucketCorsConfiguration("spacesBucketCorsConfigurationResource", {
        bucket: "string",
        corsRules: [{
            allowedMethods: ["string"],
            allowedOrigins: ["string"],
            allowedHeaders: ["string"],
            exposeHeaders: ["string"],
            id: "string",
            maxAgeSeconds: 0,
        }],
        region: "string",
    });
    
    type: digitalocean:SpacesBucketCorsConfiguration
    properties:
        bucket: string
        corsRules:
            - allowedHeaders:
                - string
              allowedMethods:
                - string
              allowedOrigins:
                - string
              exposeHeaders:
                - string
              id: string
              maxAgeSeconds: 0
        region: string
    

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

    Bucket string
    The name of the bucket to which to apply the CORS configuration.
    CorsRules List<Pulumi.DigitalOcean.Inputs.SpacesBucketCorsConfigurationCorsRule>
    Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
    Region string
    The region where the bucket resides.
    Bucket string
    The name of the bucket to which to apply the CORS configuration.
    CorsRules []SpacesBucketCorsConfigurationCorsRuleArgs
    Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
    Region string
    The region where the bucket resides.
    bucket String
    The name of the bucket to which to apply the CORS configuration.
    corsRules List<SpacesBucketCorsConfigurationCorsRule>
    Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
    region String
    The region where the bucket resides.
    bucket string
    The name of the bucket to which to apply the CORS configuration.
    corsRules SpacesBucketCorsConfigurationCorsRule[]
    Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
    region string
    The region where the bucket resides.
    bucket str
    The name of the bucket to which to apply the CORS configuration.
    cors_rules Sequence[SpacesBucketCorsConfigurationCorsRuleArgs]
    Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
    region str
    The region where the bucket resides.
    bucket String
    The name of the bucket to which to apply the CORS configuration.
    corsRules List<Property Map>
    Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
    region String
    The region where the bucket resides.

    Outputs

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

    Get an existing SpacesBucketCorsConfiguration 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?: SpacesBucketCorsConfigurationState, opts?: CustomResourceOptions): SpacesBucketCorsConfiguration
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            bucket: Optional[str] = None,
            cors_rules: Optional[Sequence[SpacesBucketCorsConfigurationCorsRuleArgs]] = None,
            region: Optional[str] = None) -> SpacesBucketCorsConfiguration
    func GetSpacesBucketCorsConfiguration(ctx *Context, name string, id IDInput, state *SpacesBucketCorsConfigurationState, opts ...ResourceOption) (*SpacesBucketCorsConfiguration, error)
    public static SpacesBucketCorsConfiguration Get(string name, Input<string> id, SpacesBucketCorsConfigurationState? state, CustomResourceOptions? opts = null)
    public static SpacesBucketCorsConfiguration get(String name, Output<String> id, SpacesBucketCorsConfigurationState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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:
    Bucket string
    The name of the bucket to which to apply the CORS configuration.
    CorsRules List<Pulumi.DigitalOcean.Inputs.SpacesBucketCorsConfigurationCorsRule>
    Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
    Region string
    The region where the bucket resides.
    Bucket string
    The name of the bucket to which to apply the CORS configuration.
    CorsRules []SpacesBucketCorsConfigurationCorsRuleArgs
    Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
    Region string
    The region where the bucket resides.
    bucket String
    The name of the bucket to which to apply the CORS configuration.
    corsRules List<SpacesBucketCorsConfigurationCorsRule>
    Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
    region String
    The region where the bucket resides.
    bucket string
    The name of the bucket to which to apply the CORS configuration.
    corsRules SpacesBucketCorsConfigurationCorsRule[]
    Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
    region string
    The region where the bucket resides.
    bucket str
    The name of the bucket to which to apply the CORS configuration.
    cors_rules Sequence[SpacesBucketCorsConfigurationCorsRuleArgs]
    Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
    region str
    The region where the bucket resides.
    bucket String
    The name of the bucket to which to apply the CORS configuration.
    corsRules List<Property Map>
    Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
    region String
    The region where the bucket resides.

    Supporting Types

    SpacesBucketCorsConfigurationCorsRule, SpacesBucketCorsConfigurationCorsRuleArgs

    AllowedMethods List<string>
    Set of HTTP methods that you allow the origin to execute. Valid values are GET, PUT, HEAD, POST, and DELETE.
    AllowedOrigins List<string>
    Set of origins you want customers to be able to access the bucket from.
    AllowedHeaders List<string>
    Set of Headers that are specified in the Access-Control-Request-Headers header.
    ExposeHeaders List<string>
    Set of headers in the response that you want customers to be able to access from their applications (for example, from a JavaScript XMLHttpRequest object).
    Id string
    Unique identifier for the rule. The value cannot be longer than 255 characters.
    MaxAgeSeconds int
    Time in seconds that your browser is to cache the preflight response for the specified resource.
    AllowedMethods []string
    Set of HTTP methods that you allow the origin to execute. Valid values are GET, PUT, HEAD, POST, and DELETE.
    AllowedOrigins []string
    Set of origins you want customers to be able to access the bucket from.
    AllowedHeaders []string
    Set of Headers that are specified in the Access-Control-Request-Headers header.
    ExposeHeaders []string
    Set of headers in the response that you want customers to be able to access from their applications (for example, from a JavaScript XMLHttpRequest object).
    Id string
    Unique identifier for the rule. The value cannot be longer than 255 characters.
    MaxAgeSeconds int
    Time in seconds that your browser is to cache the preflight response for the specified resource.
    allowedMethods List<String>
    Set of HTTP methods that you allow the origin to execute. Valid values are GET, PUT, HEAD, POST, and DELETE.
    allowedOrigins List<String>
    Set of origins you want customers to be able to access the bucket from.
    allowedHeaders List<String>
    Set of Headers that are specified in the Access-Control-Request-Headers header.
    exposeHeaders List<String>
    Set of headers in the response that you want customers to be able to access from their applications (for example, from a JavaScript XMLHttpRequest object).
    id String
    Unique identifier for the rule. The value cannot be longer than 255 characters.
    maxAgeSeconds Integer
    Time in seconds that your browser is to cache the preflight response for the specified resource.
    allowedMethods string[]
    Set of HTTP methods that you allow the origin to execute. Valid values are GET, PUT, HEAD, POST, and DELETE.
    allowedOrigins string[]
    Set of origins you want customers to be able to access the bucket from.
    allowedHeaders string[]
    Set of Headers that are specified in the Access-Control-Request-Headers header.
    exposeHeaders string[]
    Set of headers in the response that you want customers to be able to access from their applications (for example, from a JavaScript XMLHttpRequest object).
    id string
    Unique identifier for the rule. The value cannot be longer than 255 characters.
    maxAgeSeconds number
    Time in seconds that your browser is to cache the preflight response for the specified resource.
    allowed_methods Sequence[str]
    Set of HTTP methods that you allow the origin to execute. Valid values are GET, PUT, HEAD, POST, and DELETE.
    allowed_origins Sequence[str]
    Set of origins you want customers to be able to access the bucket from.
    allowed_headers Sequence[str]
    Set of Headers that are specified in the Access-Control-Request-Headers header.
    expose_headers Sequence[str]
    Set of headers in the response that you want customers to be able to access from their applications (for example, from a JavaScript XMLHttpRequest object).
    id str
    Unique identifier for the rule. The value cannot be longer than 255 characters.
    max_age_seconds int
    Time in seconds that your browser is to cache the preflight response for the specified resource.
    allowedMethods List<String>
    Set of HTTP methods that you allow the origin to execute. Valid values are GET, PUT, HEAD, POST, and DELETE.
    allowedOrigins List<String>
    Set of origins you want customers to be able to access the bucket from.
    allowedHeaders List<String>
    Set of Headers that are specified in the Access-Control-Request-Headers header.
    exposeHeaders List<String>
    Set of headers in the response that you want customers to be able to access from their applications (for example, from a JavaScript XMLHttpRequest object).
    id String
    Unique identifier for the rule. The value cannot be longer than 255 characters.
    maxAgeSeconds Number
    Time in seconds that your browser is to cache the preflight response for the specified resource.

    Import

    Bucket policies can be imported using the region and bucket attributes (delimited by a comma):

    $ pulumi import digitalocean:index/spacesBucketCorsConfiguration:SpacesBucketCorsConfiguration foobar `region`,`bucket`
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    DigitalOcean pulumi/pulumi-digitalocean
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the digitalocean Terraform Provider.
    digitalocean logo
    DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi