1. Packages
  2. Digitalocean Provider
  3. API Docs
  4. getSpacesBucketObject
DigitalOcean v4.33.0 published on Thursday, Sep 26, 2024 by Pulumi

digitalocean.getSpacesBucketObject

Explore with Pulumi AI

digitalocean logo
DigitalOcean v4.33.0 published on Thursday, Sep 26, 2024 by Pulumi

    The Spaces object data source allows access to the metadata and optionally (see below) content of an object stored inside a Spaces bucket.

    Note: The content of an object (body field) is available only for objects which have a human-readable Content-Type (text/* and application/json). This is to prevent printing unsafe characters and potentially downloading large amount of data which would be thrown away in favor of metadata.

    Example Usage

    The following example retrieves a text object (which must have a Content-Type value starting with text/) and uses it as the user_data for a Droplet:

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const bootstrapScript = digitalocean.getSpacesBucketObject({
        bucket: "ourcorp-deploy-config",
        region: "nyc3",
        key: "droplet-bootstrap-script.sh",
    });
    const web = new digitalocean.Droplet("web", {
        image: "ubuntu-18-04-x64",
        name: "web-1",
        region: digitalocean.Region.NYC2,
        size: digitalocean.DropletSlug.DropletS1VCPU1GB,
        userData: bootstrapScript.then(bootstrapScript => bootstrapScript.body),
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    bootstrap_script = digitalocean.get_spaces_bucket_object(bucket="ourcorp-deploy-config",
        region="nyc3",
        key="droplet-bootstrap-script.sh")
    web = digitalocean.Droplet("web",
        image="ubuntu-18-04-x64",
        name="web-1",
        region=digitalocean.Region.NYC2,
        size=digitalocean.DropletSlug.DROPLET_S1_VCPU1_GB,
        user_data=bootstrap_script.body)
    
    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 {
    		bootstrapScript, err := digitalocean.LookupSpacesBucketObject(ctx, &digitalocean.LookupSpacesBucketObjectArgs{
    			Bucket: "ourcorp-deploy-config",
    			Region: "nyc3",
    			Key:    "droplet-bootstrap-script.sh",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = digitalocean.NewDroplet(ctx, "web", &digitalocean.DropletArgs{
    			Image:    pulumi.String("ubuntu-18-04-x64"),
    			Name:     pulumi.String("web-1"),
    			Region:   pulumi.String(digitalocean.RegionNYC2),
    			Size:     pulumi.String(digitalocean.DropletSlugDropletS1VCPU1GB),
    			UserData: pulumi.String(bootstrapScript.Body),
    		})
    		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 bootstrapScript = DigitalOcean.GetSpacesBucketObject.Invoke(new()
        {
            Bucket = "ourcorp-deploy-config",
            Region = "nyc3",
            Key = "droplet-bootstrap-script.sh",
        });
    
        var web = new DigitalOcean.Droplet("web", new()
        {
            Image = "ubuntu-18-04-x64",
            Name = "web-1",
            Region = DigitalOcean.Region.NYC2,
            Size = DigitalOcean.DropletSlug.DropletS1VCPU1GB,
            UserData = bootstrapScript.Apply(getSpacesBucketObjectResult => getSpacesBucketObjectResult.Body),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.digitalocean.DigitaloceanFunctions;
    import com.pulumi.digitalocean.inputs.GetSpacesBucketObjectArgs;
    import com.pulumi.digitalocean.Droplet;
    import com.pulumi.digitalocean.DropletArgs;
    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) {
            final var bootstrapScript = DigitaloceanFunctions.getSpacesBucketObject(GetSpacesBucketObjectArgs.builder()
                .bucket("ourcorp-deploy-config")
                .region("nyc3")
                .key("droplet-bootstrap-script.sh")
                .build());
    
            var web = new Droplet("web", DropletArgs.builder()
                .image("ubuntu-18-04-x64")
                .name("web-1")
                .region("nyc2")
                .size("s-1vcpu-1gb")
                .userData(bootstrapScript.applyValue(getSpacesBucketObjectResult -> getSpacesBucketObjectResult.body()))
                .build());
    
        }
    }
    
    resources:
      web:
        type: digitalocean:Droplet
        properties:
          image: ubuntu-18-04-x64
          name: web-1
          region: nyc2
          size: s-1vcpu-1gb
          userData: ${bootstrapScript.body}
    variables:
      bootstrapScript:
        fn::invoke:
          Function: digitalocean:getSpacesBucketObject
          Arguments:
            bucket: ourcorp-deploy-config
            region: nyc3
            key: droplet-bootstrap-script.sh
    

    Using getSpacesBucketObject

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getSpacesBucketObject(args: GetSpacesBucketObjectArgs, opts?: InvokeOptions): Promise<GetSpacesBucketObjectResult>
    function getSpacesBucketObjectOutput(args: GetSpacesBucketObjectOutputArgs, opts?: InvokeOptions): Output<GetSpacesBucketObjectResult>
    def get_spaces_bucket_object(bucket: Optional[str] = None,
                                 key: Optional[str] = None,
                                 range: Optional[str] = None,
                                 region: Optional[str] = None,
                                 version_id: Optional[str] = None,
                                 opts: Optional[InvokeOptions] = None) -> GetSpacesBucketObjectResult
    def get_spaces_bucket_object_output(bucket: Optional[pulumi.Input[str]] = None,
                                 key: Optional[pulumi.Input[str]] = None,
                                 range: Optional[pulumi.Input[str]] = None,
                                 region: Optional[pulumi.Input[str]] = None,
                                 version_id: Optional[pulumi.Input[str]] = None,
                                 opts: Optional[InvokeOptions] = None) -> Output[GetSpacesBucketObjectResult]
    func LookupSpacesBucketObject(ctx *Context, args *LookupSpacesBucketObjectArgs, opts ...InvokeOption) (*LookupSpacesBucketObjectResult, error)
    func LookupSpacesBucketObjectOutput(ctx *Context, args *LookupSpacesBucketObjectOutputArgs, opts ...InvokeOption) LookupSpacesBucketObjectResultOutput

    > Note: This function is named LookupSpacesBucketObject in the Go SDK.

    public static class GetSpacesBucketObject 
    {
        public static Task<GetSpacesBucketObjectResult> InvokeAsync(GetSpacesBucketObjectArgs args, InvokeOptions? opts = null)
        public static Output<GetSpacesBucketObjectResult> Invoke(GetSpacesBucketObjectInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetSpacesBucketObjectResult> getSpacesBucketObject(GetSpacesBucketObjectArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: digitalocean:index/getSpacesBucketObject:getSpacesBucketObject
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Bucket string
    The name of the bucket to read the object from.
    Key string
    The full path to the object inside the bucket
    Region string
    The slug of the region where the bucket is stored.
    Range string
    VersionId string
    Specific version ID of the object returned (defaults to latest version)
    Bucket string
    The name of the bucket to read the object from.
    Key string
    The full path to the object inside the bucket
    Region string
    The slug of the region where the bucket is stored.
    Range string
    VersionId string
    Specific version ID of the object returned (defaults to latest version)
    bucket String
    The name of the bucket to read the object from.
    key String
    The full path to the object inside the bucket
    region String
    The slug of the region where the bucket is stored.
    range String
    versionId String
    Specific version ID of the object returned (defaults to latest version)
    bucket string
    The name of the bucket to read the object from.
    key string
    The full path to the object inside the bucket
    region string
    The slug of the region where the bucket is stored.
    range string
    versionId string
    Specific version ID of the object returned (defaults to latest version)
    bucket str
    The name of the bucket to read the object from.
    key str
    The full path to the object inside the bucket
    region str
    The slug of the region where the bucket is stored.
    range str
    version_id str
    Specific version ID of the object returned (defaults to latest version)
    bucket String
    The name of the bucket to read the object from.
    key String
    The full path to the object inside the bucket
    region String
    The slug of the region where the bucket is stored.
    range String
    versionId String
    Specific version ID of the object returned (defaults to latest version)

    getSpacesBucketObject Result

    The following output properties are available:

    Body string
    Object data (see limitations above to understand cases in which this field is actually available)
    Bucket string
    CacheControl string
    Specifies caching behavior along the request/reply chain.
    ContentDisposition string
    Specifies presentational information for the object.
    ContentEncoding string
    Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field.
    ContentLanguage string
    The language the content is in.
    ContentLength int
    Size of the body in bytes.
    ContentType string
    A standard MIME type describing the format of the object data.
    Etag string
    ETag generated for the object (an MD5 sum of the object content in case it's not encrypted)
    Expiration string
    If the object expiration is configured (see object lifecycle management), the field includes this header. It includes the expiry-date and rule-id key value pairs providing object expiration information. The value of the rule-id is URL encoded.
    Expires string
    The date and time at which the object is no longer cacheable.
    Id string
    The provider-assigned unique ID for this managed resource.
    Key string
    LastModified string
    Last modified date of the object in RFC1123 format (e.g. Mon, 02 Jan 2006 15:04:05 MST)
    Metadata Dictionary<string, string>
    A map of metadata stored with the object in Spaces
    Region string
    VersionId string
    The latest version ID of the object returned.
    WebsiteRedirectLocation string
    If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Spaces stores the value of this header in the object metadata.
    Range string
    Body string
    Object data (see limitations above to understand cases in which this field is actually available)
    Bucket string
    CacheControl string
    Specifies caching behavior along the request/reply chain.
    ContentDisposition string
    Specifies presentational information for the object.
    ContentEncoding string
    Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field.
    ContentLanguage string
    The language the content is in.
    ContentLength int
    Size of the body in bytes.
    ContentType string
    A standard MIME type describing the format of the object data.
    Etag string
    ETag generated for the object (an MD5 sum of the object content in case it's not encrypted)
    Expiration string
    If the object expiration is configured (see object lifecycle management), the field includes this header. It includes the expiry-date and rule-id key value pairs providing object expiration information. The value of the rule-id is URL encoded.
    Expires string
    The date and time at which the object is no longer cacheable.
    Id string
    The provider-assigned unique ID for this managed resource.
    Key string
    LastModified string
    Last modified date of the object in RFC1123 format (e.g. Mon, 02 Jan 2006 15:04:05 MST)
    Metadata map[string]string
    A map of metadata stored with the object in Spaces
    Region string
    VersionId string
    The latest version ID of the object returned.
    WebsiteRedirectLocation string
    If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Spaces stores the value of this header in the object metadata.
    Range string
    body String
    Object data (see limitations above to understand cases in which this field is actually available)
    bucket String
    cacheControl String
    Specifies caching behavior along the request/reply chain.
    contentDisposition String
    Specifies presentational information for the object.
    contentEncoding String
    Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field.
    contentLanguage String
    The language the content is in.
    contentLength Integer
    Size of the body in bytes.
    contentType String
    A standard MIME type describing the format of the object data.
    etag String
    ETag generated for the object (an MD5 sum of the object content in case it's not encrypted)
    expiration String
    If the object expiration is configured (see object lifecycle management), the field includes this header. It includes the expiry-date and rule-id key value pairs providing object expiration information. The value of the rule-id is URL encoded.
    expires String
    The date and time at which the object is no longer cacheable.
    id String
    The provider-assigned unique ID for this managed resource.
    key String
    lastModified String
    Last modified date of the object in RFC1123 format (e.g. Mon, 02 Jan 2006 15:04:05 MST)
    metadata Map<String,String>
    A map of metadata stored with the object in Spaces
    region String
    versionId String
    The latest version ID of the object returned.
    websiteRedirectLocation String
    If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Spaces stores the value of this header in the object metadata.
    range String
    body string
    Object data (see limitations above to understand cases in which this field is actually available)
    bucket string
    cacheControl string
    Specifies caching behavior along the request/reply chain.
    contentDisposition string
    Specifies presentational information for the object.
    contentEncoding string
    Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field.
    contentLanguage string
    The language the content is in.
    contentLength number
    Size of the body in bytes.
    contentType string
    A standard MIME type describing the format of the object data.
    etag string
    ETag generated for the object (an MD5 sum of the object content in case it's not encrypted)
    expiration string
    If the object expiration is configured (see object lifecycle management), the field includes this header. It includes the expiry-date and rule-id key value pairs providing object expiration information. The value of the rule-id is URL encoded.
    expires string
    The date and time at which the object is no longer cacheable.
    id string
    The provider-assigned unique ID for this managed resource.
    key string
    lastModified string
    Last modified date of the object in RFC1123 format (e.g. Mon, 02 Jan 2006 15:04:05 MST)
    metadata {[key: string]: string}
    A map of metadata stored with the object in Spaces
    region string
    versionId string
    The latest version ID of the object returned.
    websiteRedirectLocation string
    If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Spaces stores the value of this header in the object metadata.
    range string
    body str
    Object data (see limitations above to understand cases in which this field is actually available)
    bucket str
    cache_control str
    Specifies caching behavior along the request/reply chain.
    content_disposition str
    Specifies presentational information for the object.
    content_encoding str
    Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field.
    content_language str
    The language the content is in.
    content_length int
    Size of the body in bytes.
    content_type str
    A standard MIME type describing the format of the object data.
    etag str
    ETag generated for the object (an MD5 sum of the object content in case it's not encrypted)
    expiration str
    If the object expiration is configured (see object lifecycle management), the field includes this header. It includes the expiry-date and rule-id key value pairs providing object expiration information. The value of the rule-id is URL encoded.
    expires str
    The date and time at which the object is no longer cacheable.
    id str
    The provider-assigned unique ID for this managed resource.
    key str
    last_modified str
    Last modified date of the object in RFC1123 format (e.g. Mon, 02 Jan 2006 15:04:05 MST)
    metadata Mapping[str, str]
    A map of metadata stored with the object in Spaces
    region str
    version_id str
    The latest version ID of the object returned.
    website_redirect_location str
    If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Spaces stores the value of this header in the object metadata.
    range str
    body String
    Object data (see limitations above to understand cases in which this field is actually available)
    bucket String
    cacheControl String
    Specifies caching behavior along the request/reply chain.
    contentDisposition String
    Specifies presentational information for the object.
    contentEncoding String
    Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field.
    contentLanguage String
    The language the content is in.
    contentLength Number
    Size of the body in bytes.
    contentType String
    A standard MIME type describing the format of the object data.
    etag String
    ETag generated for the object (an MD5 sum of the object content in case it's not encrypted)
    expiration String
    If the object expiration is configured (see object lifecycle management), the field includes this header. It includes the expiry-date and rule-id key value pairs providing object expiration information. The value of the rule-id is URL encoded.
    expires String
    The date and time at which the object is no longer cacheable.
    id String
    The provider-assigned unique ID for this managed resource.
    key String
    lastModified String
    Last modified date of the object in RFC1123 format (e.g. Mon, 02 Jan 2006 15:04:05 MST)
    metadata Map<String>
    A map of metadata stored with the object in Spaces
    region String
    versionId String
    The latest version ID of the object returned.
    websiteRedirectLocation String
    If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Spaces stores the value of this header in the object metadata.
    range String

    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.33.0 published on Thursday, Sep 26, 2024 by Pulumi