DigitalOcean

v4.16.0 published on Wednesday, Sep 28, 2022 by Pulumi

getSpacesBucketObject

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

using System.Collections.Generic;
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",
        Region = "nyc2",
        Size = "s-1vcpu-1gb",
        UserData = bootstrapScript.Apply(getSpacesBucketObjectResult => getSpacesBucketObjectResult.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, &GetSpacesBucketObjectArgs{
			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"),
			Region:   pulumi.String("nyc2"),
			Size:     pulumi.String("s-1vcpu-1gb"),
			UserData: pulumi.String(bootstrapScript.Body),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
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")
            .region("nyc2")
            .size("s-1vcpu-1gb")
            .userData(bootstrapScript.applyValue(getSpacesBucketObjectResult -> getSpacesBucketObjectResult.body()))
            .build());

    }
}
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",
    region="nyc2",
    size="s-1vcpu-1gb",
    user_data=bootstrap_script.body)
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",
    region: "nyc2",
    size: "s-1vcpu-1gb",
    userData: bootstrapScript.then(bootstrapScript => bootstrapScript.body),
});
resources:
  web:
    type: digitalocean:Droplet
    properties:
      image: ubuntu-18-04-x64
      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, object>

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]interface{}

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,Object>

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]: any}

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, Any]

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<Any>

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
https://github.com/pulumi/pulumi-digitalocean
License
Apache-2.0
Notes

This Pulumi package is based on the digitalocean Terraform Provider.