digitalocean.getSpacesBucketObject
Explore with Pulumi AI
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-readableContent-Type
(text/*
andapplication/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 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)
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
- Cache
Control string - Specifies caching behavior along the request/reply chain.
- Content
Disposition string - Specifies presentational information for the object.
- Content
Encoding 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.
- Content
Language string - The language the content is in.
- Content
Length int - Size of the body in bytes.
- Content
Type 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
- Last
Modified 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
- Version
Id string - The latest version ID of the object returned.
- Website
Redirect stringLocation - 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
- Cache
Control string - Specifies caching behavior along the request/reply chain.
- Content
Disposition string - Specifies presentational information for the object.
- Content
Encoding 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.
- Content
Language string - The language the content is in.
- Content
Length int - Size of the body in bytes.
- Content
Type 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
- Last
Modified 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
- Version
Id string - The latest version ID of the object returned.
- Website
Redirect stringLocation - 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
- cache
Control String - Specifies caching behavior along the request/reply chain.
- content
Disposition String - Specifies presentational information for the object.
- content
Encoding 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.
- content
Language String - The language the content is in.
- content
Length Integer - Size of the body in bytes.
- content
Type 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
- last
Modified 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
- version
Id String - The latest version ID of the object returned.
- website
Redirect StringLocation - 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
- cache
Control string - Specifies caching behavior along the request/reply chain.
- content
Disposition string - Specifies presentational information for the object.
- content
Encoding 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.
- content
Language string - The language the content is in.
- content
Length number - Size of the body in bytes.
- content
Type 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
- last
Modified 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
- version
Id string - The latest version ID of the object returned.
- website
Redirect stringLocation - 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_ strlocation - 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
- cache
Control String - Specifies caching behavior along the request/reply chain.
- content
Disposition String - Specifies presentational information for the object.
- content
Encoding 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.
- content
Language String - The language the content is in.
- content
Length Number - Size of the body in bytes.
- content
Type 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
- last
Modified 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
- version
Id String - The latest version ID of the object returned.
- website
Redirect StringLocation - 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.